Fix image handling of StandardUserData heal
This patch fixes vcImageId parameter handling of StandardUserData::heal. Previously the parameter is got from VNFD wrongly if grant response does not contain its information in vimAssets. This patch fixes that the parameter is unchanged if grant response does not contain its information in vimAssets. Closes-Bug: #2006530 Change-Id: I5c7eb7733d253f1b355755cbfc8ca13b0320c541
This commit is contained in:
@@ -75,7 +75,7 @@ def get_param_flavor(vdu_name, flavour_id, vnfd, grant):
|
||||
return vnfd.get_compute_flavor(flavour_id, vdu_name)
|
||||
|
||||
|
||||
def get_param_image(vdu_name, flavour_id, vnfd, grant):
|
||||
def get_param_image(vdu_name, flavour_id, vnfd, grant, fallback_vnfd=True):
|
||||
# try to get from grant
|
||||
if 'vimAssets' in grant:
|
||||
assets = grant['vimAssets']
|
||||
@@ -85,13 +85,18 @@ def get_param_image(vdu_name, flavour_id, vnfd, grant):
|
||||
if image['vnfdSoftwareImageId'] == vdu_name:
|
||||
return image['vimSoftwareImageId']
|
||||
|
||||
# if specified in VNFD, use it
|
||||
if fallback_vnfd:
|
||||
# if this flag is True, VNFD is refered to.
|
||||
# if specified in VNFD, use it.
|
||||
# NOTE: image name is assumed to be unique in the system.
|
||||
# NFVO should be return vimAssets basically.
|
||||
sw_images = vnfd.get_sw_image(flavour_id)
|
||||
for name, image in sw_images.items():
|
||||
if name == vdu_name:
|
||||
return image
|
||||
|
||||
# NOTE: if not found. parameter is set to None.
|
||||
# may be error when stack create
|
||||
sw_images = vnfd.get_sw_image(flavour_id)
|
||||
for name, image in sw_images.items():
|
||||
if name == vdu_name:
|
||||
return image
|
||||
|
||||
|
||||
def get_param_zone(vdu_name, grant_req, grant):
|
||||
|
||||
@@ -480,8 +480,14 @@ class StandardUserData(userdata_utils.AbstractUserData):
|
||||
if 'computeFlavourId' in vdu_value:
|
||||
vdu_value.pop('computeFlavourId')
|
||||
if 'vcImageId' in vdu_value:
|
||||
vdu_value['vcImageId'] = common_script_utils.get_param_image(
|
||||
vdu_name, flavour_id, vnfd, grant)
|
||||
image = common_script_utils.get_param_image(
|
||||
vdu_name, flavour_id, vnfd, grant, fallback_vnfd=False)
|
||||
if image is not None:
|
||||
vdu_value['vcImageId'] = image
|
||||
else:
|
||||
# the case is that this is a storage image and
|
||||
# 'all' is False.
|
||||
vdu_value.pop('vcImageId')
|
||||
if 'locationConstraints' in vdu_value:
|
||||
vdu_value.pop('locationConstraints')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user