From: aticig Date: Sat, 25 Jun 2022 20:31:19 +0000 (+0300) Subject: Find the existing persistent volume by vim_id keyword X-Git-Tag: release-v12.0-start X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=f709d82704bd30fbf5f35d55d6785fb113e672e5;p=osm%2FRO.git 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 --- 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. + +