Find the existing persistent volume by vim_id keyword 70/12270/2 release-v12.0-start
authoraticig <gulsum.atici@canonical.com>
Sat, 25 Jun 2022 20:31:19 +0000 (23:31 +0300)
committeraticig <gulsum.atici@canonical.com>
Sat, 25 Jun 2022 20:39:29 +0000 (23:39 +0300)
It's possible to find an existing disk id searching with vim_id or
vim_volume_id depend on situation. vim_id is added in the search key list.

Change-Id: I7847cfc30a26bfa5f860eae2aefdbc4c44050234
Signed-off-by: aticig <gulsum.atici@canonical.com>
RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py
releasenotes/notes/Find_persistent_disk_with_vim_id-b4dc1bb0d62e0abc.yaml [new file with mode: 0644]

index d9edb32..eda5699 100644 (file)
@@ -1901,14 +1901,18 @@ class vimconnector(vimconn.VimConnector):
                         # persistent root volume
                         base_disk_index = ord("a")
                         image_id = ""
+                        # use existing persistent root volume
                         if disk.get("vim_volume_id"):
-
-                            # use existing persistent root volume
                             block_device_mapping["vd" + chr(base_disk_index)] = disk[
                                 "vim_volume_id"
                             ]
                             existing_vim_volumes.append({"id": disk["vim_volume_id"]})
-
+                        # use existing persistent root volume
+                        elif disk.get("vim_id"):
+                            block_device_mapping["vd" + chr(base_disk_index)] = disk[
+                                "vim_id"
+                            ]
+                            existing_vim_volumes.append({"id": disk["vim_id"]})
                         else:
                             # create persistent root volume
                             volume = self.cinder.volumes.create(
@@ -1925,16 +1929,18 @@ class vimconnector(vimconn.VimConnector):
                             ] = volume.id
                     else:
                         # non-root persistent volume
-                        if disk.get("vim_volume_id"):
-
+                        key_id = (
+                            "vim_volume_id"
+                            if "vim_volume_id" in disk.keys()
+                            else "vim_id"
+                        )
+                        if disk.get(key_id):
                             # use existing persistent volume
                             block_device_mapping["vd" + chr(base_disk_index)] = disk[
-                                "vim_volume_id"
+                                key_id
                             ]
-                            existing_vim_volumes.append({"id": disk["vim_volume_id"]})
-
+                            existing_vim_volumes.append({"id": disk[key_id]})
                         else:
-
                             # create persistent volume
                             volume = self.cinder.volumes.create(
                                 size=disk["size"],
diff --git a/releasenotes/notes/Find_persistent_disk_with_vim_id-b4dc1bb0d62e0abc.yaml b/releasenotes/notes/Find_persistent_disk_with_vim_id-b4dc1bb0d62e0abc.yaml
new file mode 100644 (file)
index 0000000..e32e7ca
--- /dev/null
@@ -0,0 +1,24 @@
+#######################################################################################
+# 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:
+  - |
+    Find the existing persistent volume by vim_id keyword. It's possible to find an
+    existing disk id searching with vim_id or vim_volume_id depend on situation.
+    vim_id is added in the search key list. 
+    
+