From: Luis Vega Date: Wed, 26 Jul 2023 20:49:12 +0000 (+0000) Subject: Fix Bug 2272 - NS instantiation fails in VIMs with microversion with a KeyError ... X-Git-Tag: release-v15.0-start~17 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=d6577d82c444bd5faf349aa17129d8cf62dc09ec;p=osm%2FRO.git Fix Bug 2272 - NS instantiation fails in VIMs with microversion with a KeyError 'original_name'. Change-Id: I4a1c002c28ac349b2e531965755f305ebc9050e5 Signed-off-by: Luis Vega --- diff --git a/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py b/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py index f225be45..9d474371 100644 --- a/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py +++ b/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py @@ -645,9 +645,10 @@ class vimconnector(vimconn.VimConnector): # TODO parse input and translate to VIM format (openmano_schemas.new_vminstance_response_schema) server_dict = server.to_dict() try: - server_dict["flavor"]["id"] = self.nova.flavors.find( - name=server_dict["flavor"]["original_name"] - ).id + if server_dict["flavor"].get("original_name"): + server_dict["flavor"]["id"] = self.nova.flavors.find( + name=server_dict["flavor"]["original_name"] + ).id except nClient.exceptions.NotFound as e: self.logger.warning(str(e.message)) return server_dict @@ -3942,9 +3943,10 @@ class vimconnector(vimconn.VimConnector): all_servers = self.nova.servers.list(detailed=True) try: for server in all_servers: - server.flavor["id"] = self.nova.flavors.find( - name=server.flavor["original_name"] - ).id + if server.flavor.get("original_name"): + server.flavor["id"] = self.nova.flavors.find( + name=server.flavor["original_name"] + ).id except nClient.exceptions.NotFound as e: self.logger.warning(str(e.message)) all_ports = self.neutron.list_ports() diff --git a/releasenotes/notes/Fix-Bug-2272-6cf785b85d32c651.yaml b/releasenotes/notes/Fix-Bug-2272-6cf785b85d32c651.yaml new file mode 100644 index 00000000..38270b35 --- /dev/null +++ b/releasenotes/notes/Fix-Bug-2272-6cf785b85d32c651.yaml @@ -0,0 +1,22 @@ +####################################################################################### +# 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. +####################################################################################### +--- +fixes: + - | + Fix Bug 2272 - NS instantiation fails in VIMs with microversion with a KeyError 'original_name'. + With this fix, now Key `original_name` is only used when working with the newer version of the + nova API. \ No newline at end of file