diff --git a/NG-RO/osm_ng_ro/ns.py b/NG-RO/osm_ng_ro/ns.py index 624940f5bc4a33b8d6db55ccda52bf89eb885a60..c7780417b962405a9f4e8880bdff023434ad2beb 100644 --- a/NG-RO/osm_ng_ro/ns.py +++ b/NG-RO/osm_ng_ro/ns.py @@ -840,6 +840,14 @@ class Ns(object): if vim_flavor_id: # vim-flavor-id was passed so flavor won't be created return {"find_params": {"vim_flavor_id": vim_flavor_id}} + vim_flavor_name = ( + target_vdur.get("additionalParams", {}) + .get("OSM", {}) + .get("vim_flavor_name") + ) + if vim_flavor_name: # vim-flavor-name was passed so flavor won't be created + return {"find_params": {"vim_flavor_name": vim_flavor_name}} + flavor_data = { "disk": int(target_flavor["storage-gb"]), "ram": int(target_flavor["memory-mb"]), diff --git a/NG-RO/osm_ng_ro/ns_thread.py b/NG-RO/osm_ng_ro/ns_thread.py index 4937964823bc14df0868dd573966246b2c5b4c27..3ef6dda5b713aed4704011fd9a75351413cb5f2d 100644 --- a/NG-RO/osm_ng_ro/ns_thread.py +++ b/NG-RO/osm_ng_ro/ns_thread.py @@ -1270,6 +1270,31 @@ class VimInteractionFlavor(VimInteractionBase): } each_flavor.update(flavor_dict) self.db.set_one("nsrs", {"_id": task["nsr_id"]}, db_nsr) + elif task.get("find_params", {}).get("vim_flavor_name"): + db_nsr = self.db.get_one("nsrs", {"_id": task["nsr_id"]}) + for vnfr_id in db_nsr.get("constituent-vnfr-ref"): + db_vnfr = self.db.get_one("vnfrs", {"_id": vnfr_id}) + for each_flavor in db_nsr["flavor"]: + nsd_flavor_id = each_flavor["id"] + for vdur in db_vnfr["vdur"]: + if vdur.get("ns-flavor-id") == nsd_flavor_id: + if vdur["additionalParams"]["OSM"].get( + "vim_flavor_name" + ): + flavor_name = vdur["additionalParams"]["OSM"][ + "vim_flavor_name" + ] + flavor_details = target_vim.get_flavor( + flavor_name=flavor_name + ) + flavor_dict = { + "memory-mb": flavor_details["ram"], + "storage-gb": flavor_details["disk"], + "vcpu-count": flavor_details["vcpus"], + } + each_flavor.update(flavor_dict) + vim_flavor_id = flavor_details.get("id") + self.db.set_one("nsrs", {"_id": task["nsr_id"]}, db_nsr) elif task.get("find_params", {}).get("flavor_data"): try: flavor_data = task["find_params"]["flavor_data"] diff --git a/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py b/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py index 501c6924e17dff76e3c3316ea03e0624740dbd76..1a9a2566e54e3bc3bdf27966222ce70e94f7539b 100644 --- a/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py +++ b/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py @@ -1258,12 +1258,15 @@ class vimconnector(vimconn.VimConnector): net_dict[net_id] = net return net_dict - def get_flavor(self, flavor_id): + def get_flavor(self, flavor_id=None, flavor_name=None): """Obtain flavor details from the VIM. Returns the flavor dict details""" self.logger.debug("Getting flavor '%s'", flavor_id) try: self._reload_connection() - flavor = self.nova.flavors.find(id=flavor_id) + if flavor_id: + flavor = self.nova.flavors.find(id=flavor_id) + else: + flavor = self.nova.flavors.find(name=flavor_name) return flavor.to_dict() except ( diff --git a/RO-plugin/osm_ro_plugin/vimconn.py b/RO-plugin/osm_ro_plugin/vimconn.py index a46f581aa0b32075e75a20a84f17611249f8b042..f5fe6ccb05f4e4400dbeec9c0798e28454f9fdf2 100644 --- a/RO-plugin/osm_ro_plugin/vimconn.py +++ b/RO-plugin/osm_ro_plugin/vimconn.py @@ -521,7 +521,7 @@ class VimConnector: """ raise VimConnNotImplemented("Should have implemented this") - def get_flavor(self, flavor_id): + def get_flavor(self, flavor_id, flavor_name): """Obtain flavor details from the VIM Returns the flavor dict details {'id':<>, 'name':<>, other vim specific } Raises an exception upon error or if not found diff --git a/releasenotes/notes/feature_11047_Vim_Flavor_Name_as_Ns_Config_Template-b1d8fb772763e699.yaml b/releasenotes/notes/feature_11047_Vim_Flavor_Name_as_Ns_Config_Template-b1d8fb772763e699.yaml new file mode 100644 index 0000000000000000000000000000000000000000..20ee4ba025e4df7ee6310b89d56694ece5061022 --- /dev/null +++ b/releasenotes/notes/feature_11047_Vim_Flavor_Name_as_Ns_Config_Template-b1d8fb772763e699.yaml @@ -0,0 +1,81 @@ +####################################################################################### +# Copyright ETSI Contributors and Others. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +####################################################################################### +--- +prelude: > + Replace this text with content to appear at the top of the section for this + release. All of the prelude content is merged together and then rendered + separately from the items listed in other parts of the file, so the text + needs to be worded so that both the prelude and the other items make sense + when read independently. This may mean repeating some details. Not every + release note requires a prelude. Usually only notes describing major + features or adding release theme details should have a prelude. +features: + - | + List new features here, or remove this section. All of the list items in + this section are combined when the release notes are rendered, so the text + needs to be worded so that it does not depend on any information only + available in another section, such as the prelude. This may mean repeating + some details. +issues: + - | + List known issues here, or remove this section. All of the list items in + this section are combined when the release notes are rendered, so the text + needs to be worded so that it does not depend on any information only + available in another section, such as the prelude. This may mean repeating + some details. +upgrade: + - | + List upgrade notes here, or remove this section. All of the list items in + this section are combined when the release notes are rendered, so the text + needs to be worded so that it does not depend on any information only + available in another section, such as the prelude. This may mean repeating + some details. +deprecations: + - | + List deprecations notes here, or remove this section. All of the list + items in this section are combined when the release notes are rendered, so + the text needs to be worded so that it does not depend on any information + only available in another section, such as the prelude. This may mean + repeating some details. +critical: + - | + Add critical notes here, or remove this section. All of the list items in + this section are combined when the release notes are rendered, so the text + needs to be worded so that it does not depend on any information only + available in another section, such as the prelude. This may mean repeating + some details. +security: + - | + Add security notes here, or remove this section. All of the list items in + this section are combined when the release notes are rendered, so the text + needs to be worded so that it does not depend on any information only + available in another section, such as the prelude. This may mean repeating + some details. +fixes: + - | + Add normal bug fixes here, or remove this section. All of the list items + in this section are combined when the release notes are rendered, so the + text needs to be worded so that it does not depend on any information only + available in another section, such as the prelude. This may mean repeating + some details. +other: + - | + Add other notes here, or remove this section. All of the list items in + this section are combined when the release notes are rendered, so the text + needs to be worded so that it does not depend on any information only + available in another section, such as the prelude. This may mean repeating + some details.