Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
HTTP_Bad_Request)
return -HTTP_Bad_Request,
HTTP_Bad_Request)
return -HTTP_Bad_Request,
-def create_or_use_image(mydb, vims, image_dict, rollback_list, only_create_at_vim=False, return_on_error = False):
+def create_or_use_image(mydb, vims, image_dict, rollback_list, only_create_at_vim=False, return_on_error = None):
#look if image exist
if only_create_at_vim:
image_mano_id = image_dict['uuid']
#look if image exist
if only_create_at_vim:
image_mano_id = image_dict['uuid']
+ if return_on_error == None:
+ return_on_error = True
else:
if image_dict['location'] is not None:
images = mydb.get_rows(FROM="images", WHERE={'location':image_dict['location'], 'metadata':image_dict['metadata']})
else:
if image_dict['location'] is not None:
images = mydb.get_rows(FROM="images", WHERE={'location':image_dict['location'], 'metadata':image_dict['metadata']})
if return_on_error:
logger.error("Error creating image at VIM: %s", str(e))
raise
if return_on_error:
logger.error("Error creating image at VIM: %s", str(e))
raise
logger.warn("Error creating image at VIM: %s", str(e))
continue
except vimconn.vimconnException as e:
logger.warn("Error creating image at VIM: %s", str(e))
continue
except vimconn.vimconnException as e:
+ if return_on_error:
+ logger.error("Error contacting VIM to know if the image exists at VIM: %s", str(e))
+ raise
logger.warn("Error contacting VIM to know if the image exists at VIM: %s", str(e))
logger.warn("Error contacting VIM to know if the image exists at VIM: %s", str(e))
continue
#if we reach here, the image has been created or existed
if len(image_db)==0:
continue
#if we reach here, the image has been created or existed
if len(image_db)==0:
return image_vim_id if only_create_at_vim else image_mano_id
return image_vim_id if only_create_at_vim else image_mano_id
-def create_or_use_flavor(mydb, vims, flavor_dict, rollback_list, only_create_at_vim=False, return_on_error = False):
+def create_or_use_flavor(mydb, vims, flavor_dict, rollback_list, only_create_at_vim=False, return_on_error = None):
temp_flavor_dict= {'disk':flavor_dict.get('disk',1),
'ram':flavor_dict.get('ram'),
'vcpus':flavor_dict.get('vcpus'),
temp_flavor_dict= {'disk':flavor_dict.get('disk',1),
'ram':flavor_dict.get('ram'),
'vcpus':flavor_dict.get('vcpus'),
#look if flavor exist
if only_create_at_vim:
flavor_mano_id = flavor_dict['uuid']
#look if flavor exist
if only_create_at_vim:
flavor_mano_id = flavor_dict['uuid']
+ if return_on_error == None:
+ return_on_error = True
else:
flavors = mydb.get_rows(FROM="flavors", WHERE=temp_flavor_dict)
if len(flavors)>=1:
else:
flavors = mydb.get_rows(FROM="flavors", WHERE=temp_flavor_dict)
if len(flavors)>=1:
logger.error("Error creating flavor at VIM %s: %s.", vim["name"], str(e))
raise
logger.warn("Error creating flavor at VIM %s: %s.", vim["name"], str(e))
logger.error("Error creating flavor at VIM %s: %s.", vim["name"], str(e))
raise
logger.warn("Error creating flavor at VIM %s: %s.", vim["name"], str(e))
continue
#if reach here the flavor has been create or exist
if len(flavor_db)==0:
continue
#if reach here the flavor has been create or exist
if len(flavor_db)==0:
myVMDict['name'] = myVMDict['name'][0:255] #limit name length
#create image at vim in case it not exist
image_dict = mydb.get_table_by_uuid_name("images", vm['image_id'])
myVMDict['name'] = myVMDict['name'][0:255] #limit name length
#create image at vim in case it not exist
image_dict = mydb.get_table_by_uuid_name("images", vm['image_id'])
- image_id = create_or_use_image(mydb, {datacenter_id: vim}, image_dict, [], True)
+ image_id = create_or_use_image(mydb, {datacenter_id: vim}, image_dict, [], True)
vm['vim_image_id'] = image_id
#create flavor at vim in case it not exist
vm['vim_image_id'] = image_id
#create flavor at vim in case it not exist
'''
__author__="Alfonso Tierno, Gerardo Garcia, Pablo Montes"
__date__ ="$26-aug-2014 11:09:29$"
'''
__author__="Alfonso Tierno, Gerardo Garcia, Pablo Montes"
__date__ ="$26-aug-2014 11:09:29$"
-__version__="0.4.61-r505"
+__version__="0.4.62-r506"
version_date="Oct 2016"
database_version="0.15" #expected database schema version
version_date="Oct 2016"
database_version="0.15" #expected database schema version