From: Anurag Dwivedi Date: Wed, 11 Oct 2017 21:11:15 +0000 (-0400) Subject: Bug 372 - Cloud init files do not get applied on Openstack/AWS datacenters X-Git-Tag: v3.0.0rc14~14^2 X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FSO.git;a=commitdiff_plain;h=58f9df1373a7d90da4b15b35ce40b777e6df7c09 Bug 372 - Cloud init files do not get applied on Openstack/AWS datacenters Signed-off-by: Anurag Dwivedi --- diff --git a/models/openmano/python/rift/openmano/rift2openmano.py b/models/openmano/python/rift/openmano/rift2openmano.py index 91ae8a99..e02269bc 100755 --- a/models/openmano/python/rift/openmano/rift2openmano.py +++ b/models/openmano/python/rift/openmano/rift2openmano.py @@ -273,19 +273,19 @@ def rift2openmano_vnfd_nsd(rift_nsd, rift_vnfds, openmano_vnfd_ids, http_api, ri def cloud_init(rift_vnfd_id, vdu, project_name='default'): - """ Populate cloud_init with script from + """ Populate cloud-init with script from either the inline contents or from the file provided """ vnfd_package_store = rift.package.store.VnfdPackageFilesystemStore(logger, project=project_name) cloud_init_msg = None - if 'cloud_init' in vdu: - logger.debug("cloud_init script provided inline %s", vdu['cloud_init']) - cloud_init_msg = vdu['cloud_init'] - elif 'cloud_init_file' in vdu: + if 'cloud-init' in vdu: + logger.debug("cloud-init script provided inline %s", vdu['cloud-init']) + cloud_init_msg = vdu['cloud-init'] + elif 'cloud-init-file' in vdu: # Get cloud-init script contents from the file provided in the cloud_init_file param - logger.debug("cloud_init script provided in file %s", vdu['cloud_init_file']) - filename = vdu['cloud_init_file'] + logger.debug("cloud-init script provided in file %s", vdu['cloud-init-file']) + filename = vdu['cloud-init-file'] vnfd_package_store.refresh() stored_package = vnfd_package_store.get_package(rift_vnfd_id) cloud_init_extractor = rift.package.cloud_init.PackageCloudInitExtractor(logger) @@ -319,37 +319,35 @@ def config_file_init(rift_vnfd_id, vdu, cfg_file, project_name='default'): logger.debug("Current config file msg is {}".format(cfg_file_msg)) return cfg_file_msg -def rift2openmano_vnfd(rift_vnfd, rift_nsd, http_api): +def rift2openmano_vnfd(rift_vnfd, rift_nsd, http_api, project): try: openmano_vnfd_im_body = json.loads(rift_vnfd.from_dict()) # All type_yang leafs renamed to type - vnfd_dict = openmano_vnfd_im_body['vnfd-catalog']['vnfd'][0] if 'vdu' in vnfd_dict: for vdu in vnfd_dict['vdu']: - if 'cloud_init_file' in vdu: + if 'cloud-init-file' in vdu: # Replacing the leaf with the actual contents of the file. # The RO does not have the ability to read files yet. - vdu['cloud_init_file'] = cloud_init(openmano_vnfd_im_body.id, vdu) - elif 'cloud_init' in vdu: - vdu['cloud_init'] = cloud_init(openmano_vnfd_im_body.id, vdu) + vdu['cloud-init-file'] = cloud_init(vnfd_dict['id'], vdu, project) + elif 'cloud-init' in vdu: + vdu['cloud-init'] = cloud_init(vnfd_dict['id'], vdu, project) - if 'supplemental_boot_data' in vdu: - if 'config_file' in vdu['supplemental_boot_data']: - for config_file in vdu['supplemental_boot_data']['config_file']: + if 'supplemental-boot-data' in vdu: + if 'config-file' in vdu['supplemental-boot-data']: + for config_file in vdu['supplemental-boot-data']['config-file']: # Replacing the leaf with the actual contents of the file. # The RO does not have the ability to read files yet. - config_file['source'] = config_file_init(openmano_vnfd_im_body.id, vdu, config_file['source']) + config_file['source'] = config_file_init(vnfd_dict['id'], vdu, config_file['source'], project) openmano_vnfd_api_format = { "vnfd:vnfd-catalog": { "vnfd": [vnfd_dict] } } - openmano_vnfd = http_api.post_vnfd_v3(openmano_vnfd_api_format) return openmano_vnfd diff --git a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/openmano_nsm.py b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/openmano_nsm.py index d6f8483b..9a9efb59 100644 --- a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/openmano_nsm.py +++ b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/openmano_nsm.py @@ -161,7 +161,8 @@ class VnfrConsoleOperdataDtsHandler(object): class OpenmanoVnfr(object): - def __init__(self, log, loop, cli_api, http_api, vnfr, nsd, ssh_key=None): + def __init__(self, project, log, loop, cli_api, http_api, vnfr, nsd, ssh_key=None): + self._project = project self._log = log self._loop = loop self._cli_api = cli_api @@ -195,7 +196,7 @@ class OpenmanoVnfr(object): @property def openmano_vnfd(self): self._log.debug("Converting vnfd %s from rift to openmano", self.vnfd.id) - openmano_vnfd = rift2openmano.rift2openmano_vnfd(self.vnfd, self.nsd, self._http_api) + openmano_vnfd = rift2openmano.rift2openmano_vnfd(self.vnfd, self.nsd, self._http_api, self._project) return openmano_vnfd @property @@ -572,7 +573,7 @@ class OpenmanoNsr(object): @asyncio.coroutine def add_vnfr(self, vnfr): - vnfr = OpenmanoVnfr(self._log, self._loop, self._cli_api, self.http_api, + vnfr = OpenmanoVnfr(self._project, self._log, self._loop, self._cli_api, self.http_api, vnfr, nsd=self.nsd, ssh_key=self._ssh_key) yield from vnfr.create() self._vnfrs.append(vnfr)