From 343c520e28e61f5bfa18506e3818c1d3af7f57af Mon Sep 17 00:00:00 2001 From: aticig Date: Sat, 25 Jun 2022 23:31:19 +0300 Subject: [PATCH] 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. Change-Id: I7847cfc30a26bfa5f860eae2aefdbc4c44050234 Signed-off-by: aticig --- .../osm_rovim_openstack/vimconn_openstack.py | 24 ++++++++++++------- ...ent_disk_with_vim_id-b4dc1bb0d62e0abc.yaml | 24 +++++++++++++++++++ 2 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 releasenotes/notes/Find_persistent_disk_with_vim_id-b4dc1bb0d62e0abc.yaml diff --git a/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py b/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py index d9edb323..eda56990 100644 --- a/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py +++ b/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py @@ -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 index 00000000..e32e7ca6 --- /dev/null +++ b/releasenotes/notes/Find_persistent_disk_with_vim_id-b4dc1bb0d62e0abc.yaml @@ -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. + + -- 2.17.1