Fix Bug 2272 - NS instantiation fails in VIMs with microversion with a KeyError ... 50/13750/2
authorLuis Vega <lvega@whitestack.com>
Wed, 26 Jul 2023 20:49:12 +0000 (20:49 +0000)
committerLuis Vega <lvega@whitestack.com>
Wed, 26 Jul 2023 20:52:44 +0000 (20:52 +0000)
Change-Id: I4a1c002c28ac349b2e531965755f305ebc9050e5
Signed-off-by: Luis Vega <lvega@whitestack.com>
RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py
releasenotes/notes/Fix-Bug-2272-6cf785b85d32c651.yaml [new file with mode: 0644]

index f225be4..9d47437 100644 (file)
@@ -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 (file)
index 0000000..38270b3
--- /dev/null
@@ -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