Fix the bug when uploading images to NOVA
Change-Id: I92bf1745113ccce515b55ee2dc0238343b03f8e2
This commit is contained in:
parent
2b8fd2de1a
commit
d30dbe1342
14
compute.py
14
compute.py
@ -35,7 +35,8 @@ class Compute(object):
|
|||||||
except novaclient.exceptions.NotFound:
|
except novaclient.exceptions.NotFound:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def upload_image_via_url(self, glance_client, final_image_name, image_url, retry_count=60):
|
def upload_image_via_url(self, creds, glance_client,
|
||||||
|
final_image_name, image_url, retry_count=60):
|
||||||
'''
|
'''
|
||||||
Directly uploads image to Nova via URL if image is not present
|
Directly uploads image to Nova via URL if image is not present
|
||||||
'''
|
'''
|
||||||
@ -78,15 +79,18 @@ class Compute(object):
|
|||||||
# time.sleep(5)
|
# time.sleep(5)
|
||||||
|
|
||||||
# upload in glance
|
# upload in glance
|
||||||
glance_cmd = "glance image-create --name=\"" + str(final_image_name) + \
|
cred = "--os-username %s --os-password %s --os-tenant-name %s --os-auth-url %s" %\
|
||||||
"\" --disk-format=qcow2" + " --container-format=bare " + \
|
(creds['username'], creds['password'], creds['tenant_name'], creds['auth_url'])
|
||||||
" --is-public True --copy-from " + image_url
|
glance_cmd = "glance %s image-create --name=\"%s\" --disk-format=qcow2 "\
|
||||||
|
"--container-format=bare --is-public True --copy-from %s" %\
|
||||||
|
(cred, str(final_image_name), image_url)
|
||||||
if self.config.debug:
|
if self.config.debug:
|
||||||
print "Will update image to glance via CLI: %s" % (glance_cmd)
|
print "Will update image to glance via CLI: %s" % (glance_cmd)
|
||||||
subprocess.check_output(glance_cmd, shell=True)
|
subprocess.check_output(glance_cmd, shell=True)
|
||||||
|
|
||||||
# check for the image in glance
|
# check for the image in glance
|
||||||
glance_check_cmd = "glance image-list --name \"" + str(final_image_name) + "\""
|
glance_check_cmd = "glance %s image-list --name \"%s\"" %\
|
||||||
|
(cred, str(final_image_name))
|
||||||
for retry_attempt in range(retry_count):
|
for retry_attempt in range(retry_count):
|
||||||
result = subprocess.check_output(glance_check_cmd, shell=True)
|
result = subprocess.check_output(glance_check_cmd, shell=True)
|
||||||
if "active" in result:
|
if "active" in result:
|
||||||
|
4
vmtp.py
4
vmtp.py
@ -207,7 +207,7 @@ class VmtpTest(object):
|
|||||||
|
|
||||||
self.image_instance = self.comp.find_image(config.image_name)
|
self.image_instance = self.comp.find_image(config.image_name)
|
||||||
if self.image_instance is None:
|
if self.image_instance is None:
|
||||||
if config.vm_image_url is not None:
|
if config.vm_image_url != "":
|
||||||
print '%s: image for VM not found, uploading it ...' \
|
print '%s: image for VM not found, uploading it ...' \
|
||||||
% (config.image_name)
|
% (config.image_name)
|
||||||
keystone = keystoneclient.Client(**creds)
|
keystone = keystoneclient.Client(**creds)
|
||||||
@ -216,7 +216,7 @@ class VmtpTest(object):
|
|||||||
glance_client = glanceclient.Client(
|
glance_client = glanceclient.Client(
|
||||||
glance_endpoint, token=keystone.auth_token)
|
glance_endpoint, token=keystone.auth_token)
|
||||||
self.comp.upload_image_via_url(
|
self.comp.upload_image_via_url(
|
||||||
glance_client, config.image_name, config.vm_image_url)
|
creds, glance_client, config.image_name, config.vm_image_url)
|
||||||
self.image_instance = self.comp.find_image(config.image_name)
|
self.image_instance = self.comp.find_image(config.image_name)
|
||||||
else:
|
else:
|
||||||
# Exit the pogram
|
# Exit the pogram
|
||||||
|
Loading…
x
Reference in New Issue
Block a user