Skip to content

Commit

Permalink
Changes to support glance image-create in liberty
Browse files Browse the repository at this point in the history
Conflicts:
	tcutils/util.py

Change-Id: I3a692a8fd7855fd059c5095999172b02872b420f
  • Loading branch information
Senthilnathan Murugappan committed Mar 26, 2016
1 parent a672084 commit f82f9e2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
7 changes: 6 additions & 1 deletion common/contrail_test_init.py
Expand Up @@ -17,7 +17,7 @@
from fabric.contrib.files import exists

from tcutils.util import *
from tcutils.util import custom_dict, read_config_option
from tcutils.util import custom_dict, read_config_option, get_build_sku
from tcutils.custom_filehandler import *
from tcutils.config.vnc_introspect_utils import VNCApiInspect
from tcutils.config.ds_introspect_utils import VerificationDsSrv
Expand Down Expand Up @@ -574,6 +574,11 @@ def get_mysql_token(self):
return self.mysql_token
# end get_mysql_token

def get_build_sku(self):
return get_build_sku(self.openstack_ip,
self.host_data[self.openstack_ip]['password'],
self.host_data[self.openstack_ip]['username'])

def run_cmd_on_server(self, server_ip, issue_cmd, username=None,
password=None, pty=True):
if server_ip in self.host_data.keys():
Expand Down
10 changes: 8 additions & 2 deletions fixtures/nova_test.py
Expand Up @@ -266,8 +266,14 @@ def copy_and_glance(self, build_path, generic_image_name, image_name, params, im
if '.gz' in build_path:
unzip = ' gunzip | '

cmd = '(source /etc/contrail/openstackrc; wget -O - %s | %s glance image-create --name "%s" \
--is-public True %s)' % (build_path, unzip, generic_image_name, params)
if self.inputs.get_build_sku()[0] < 'l':
cmd = '(source /etc/contrail/openstackrc; wget -O - %s | %s \
glance image-create --name "%s" --is-public True %s)' \
%(build_path, unzip, generic_image_name, params)
else:
cmd = '(source /etc/contrail/openstackrc; wget -O - %s | %s \
glance image-create --name "%s" --visibility public %s)' \
%(build_path, unzip, generic_image_name, params)

self.execute_cmd_with_proxy(cmd)

Expand Down
7 changes: 3 additions & 4 deletions tcutils/util.py
Expand Up @@ -19,7 +19,7 @@
import fcntl
import socket
import struct
from fabric.exceptions import CommandTimeout
from fabric.exceptions import CommandTimeout, NetworkError
from fabric.contrib.files import exists
from fabric.context_managers import settings, hide
import ConfigParser
Expand All @@ -29,8 +29,7 @@
from fabfile import *

log.basicConfig(format='%(levelname)s: %(message)s', level=log.DEBUG)

sku_dict={'2014.1':'icehouse','2014.2':'juno','2015.1':'kilo'}
sku_dict = {'2014.1': 'icehouse', '2014.2': 'juno', '2015.1': 'kilo', '12.0': 'liberty'}

# Code borrowed from http://wiki.python.org/moin/PythonDecoratorLibrary#Retry

Expand Down Expand Up @@ -826,7 +825,7 @@ def get_build_sku(openstack_node_ip, openstack_node_password='c0ntrail123', user
while not build_sku and tries:
try:
output = run_fab_cmd_on_node(host_str, pswd, cmd, timeout=10, as_sudo=True)
build_sku = sku_dict[re.findall("[0-9]{4}.[0-9]+",output)[0]]
build_sku = sku_dict[re.findall("[0-9]+.[0-9]+", output)[0]]
except NetworkError, e:
time.sleep(1)
pass
Expand Down

0 comments on commit f82f9e2

Please sign in to comment.