Fix Bug 2270: Feature (Start, Stop, Rebuild) The update type shows as completed befor... 91/13991/3
authorRahul Kumar <rahul.k4@tataelxsi.co.in>
Wed, 8 Nov 2023 06:48:12 +0000 (06:48 +0000)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Tue, 11 Jun 2024 14:01:01 +0000 (16:01 +0200)
Change-Id: I5e88c3cabfadffe7faed2996f31d45ab6cb9f617
Signed-off-by: Rahul Kumar <rahul.k4@tataelxsi.co.in>
RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py
releasenotes/notes/bug_fix_2270_Feature_Start_Stop_Rebuild_The_update_type_shows_completed_before_VM_status_changed-9a996997b3d2a571.yaml [new file with mode: 0644]

index 54d0e88..221fc24 100644 (file)
@@ -3376,6 +3376,12 @@ class vimconnector(vimconn.VimConnector):
         if "start" in action_dict:
             if action_dict["start"] == "rebuild":
                 server.rebuild()
+                vm_state = self.__wait_for_vm(vm_id, "ACTIVE")
+                if not vm_state:
+                    raise nvExceptions.BadRequest(
+                        409,
+                        message="Cannot 'REBUILD' vm_state is in ERROR",
+                    )
             else:
                 if server.status == "PAUSED":
                     server.unpause()
@@ -3383,6 +3389,12 @@ class vimconnector(vimconn.VimConnector):
                     server.resume()
                 elif server.status == "SHUTOFF":
                     server.start()
+                    vm_state = self.__wait_for_vm(vm_id, "ACTIVE")
+                    if not vm_state:
+                        raise nvExceptions.BadRequest(
+                            409,
+                            message="Cannot 'START' vm_state is in ERROR",
+                        )
                 else:
                     self.logger.debug(
                         "ERROR : Instance is not in SHUTOFF/PAUSE/SUSPEND state"
@@ -3399,6 +3411,12 @@ class vimconnector(vimconn.VimConnector):
             self.logger.debug("server status %s", server.status)
             if server.status == "ACTIVE":
                 server.stop()
+                vm_state = self.__wait_for_vm(vm_id, "SHUTOFF")
+                if not vm_state:
+                    raise nvExceptions.BadRequest(
+                        409,
+                        message="Cannot 'STOP' vm_state is in ERROR",
+                    )
             else:
                 self.logger.debug("ERROR: VM is not in Active state")
                 raise vimconn.VimConnException(
diff --git a/releasenotes/notes/bug_fix_2270_Feature_Start_Stop_Rebuild_The_update_type_shows_completed_before_VM_status_changed-9a996997b3d2a571.yaml b/releasenotes/notes/bug_fix_2270_Feature_Start_Stop_Rebuild_The_update_type_shows_completed_before_VM_status_changed-9a996997b3d2a571.yaml
new file mode 100644 (file)
index 0000000..629fdc0
--- /dev/null
@@ -0,0 +1,21 @@
+#######################################################################################
+# 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:
+  - |
+    Bug Fix 2270 Feature (Start, Stop, Rebuild) The update type shows as completed
+    before VM status is changed in OpenStack of that VM