From 772fa4a3fa6fda1a9b81bc23aabe68bc9c7298e0 Mon Sep 17 00:00:00 2001 From: aticig Date: Thu, 12 May 2022 21:35:47 +0300 Subject: [PATCH] Fix Bug 1911 Root disk cannot be a Persistent Volume By this fix, VNFs could have persistent root disk if the disk type is defined as persistent-storage. Besides, the problem of creating unnecessary empty persistent volume is solved. Change-Id: Ibb48fab8084962a0983c2a5260ae97b53eee8f4d Signed-off-by: aticig --- NG-RO/osm_ng_ro/ns.py | 60 +++++++++++++++---- .../osm_rovim_openstack/vimconn_openstack.py | 6 +- devops-stages/stage-test.sh | 1 + .../notes/fix_bug_1911-e84f3fe699d114cf.yaml | 22 +++++++ 4 files changed, 75 insertions(+), 14 deletions(-) create mode 100644 releasenotes/notes/fix_bug_1911-e84f3fe699d114cf.yaml diff --git a/NG-RO/osm_ng_ro/ns.py b/NG-RO/osm_ng_ro/ns.py index d09f5791..18503531 100644 --- a/NG-RO/osm_ng_ro/ns.py +++ b/NG-RO/osm_ng_ro/ns.py @@ -693,7 +693,9 @@ class Ns(object): return extra_dict - def _process_affinity_group_params(target_affinity_group, vim_info, target_record_id): + def _process_affinity_group_params( + target_affinity_group, vim_info, target_record_id + ): extra_dict = {} affinity_group_data = { @@ -919,26 +921,55 @@ class Ns(object): if ssh_keys: cloud_config["key-pairs"] = ssh_keys - disk_list = None + persistent_root_disk = {} + disk_list = [] + vnfd_id = vnfr["vnfd-id"] + vnfd = self.db.get_one("vnfds", {"_id": vnfd_id}) + for vdu in vnfd.get("vdu", ()): + if vdu["name"] == target_vdu["vdu-name"]: + for vsd in vnfd.get("virtual-storage-desc", ()): + if ( + vsd.get("id") + == vdu.get("virtual-storage-desc", [[]])[0] + ): + root_disk = vsd + if root_disk.get( + "type-of-storage" + ) == "persistent-storage:persistent-storage" and root_disk.get( + "size-of-storage" + ): + persistent_root_disk[vsd["id"]] = { + "image_id": vdu.get("sw-image-desc"), + "size": root_disk["size-of-storage"], + } + disk_list.append(persistent_root_disk[vsd["id"]]) + if target_vdu.get("virtual-storages"): - disk_list = [ - {"size": disk["size-of-storage"]} - for disk in target_vdu["virtual-storages"] - if disk.get("type-of-storage") - == "persistent-storage:persistent-storage" - ] + for disk in target_vdu["virtual-storages"]: + if ( + disk.get("type-of-storage") + == "persistent-storage:persistent-storage" + and disk["id"] not in persistent_root_disk.keys() + ): + disk_list.append({"size": disk["size-of-storage"]}) affinity_group_list = [] if target_vdu.get("affinity-or-anti-affinity-group-id"): affinity_group = {} - for affinity_group_id in target_vdu["affinity-or-anti-affinity-group-id"]: + for affinity_group_id in target_vdu[ + "affinity-or-anti-affinity-group-id" + ]: affinity_group_text = ( - ns_preffix + ":affinity-or-anti-affinity-group." + affinity_group_id + ns_preffix + + ":affinity-or-anti-affinity-group." + + affinity_group_id ) extra_dict["depends_on"].append(affinity_group_text) - affinity_group["affinity_group_id"] = "TASK-" + affinity_group_text + affinity_group["affinity_group_id"] = ( + "TASK-" + affinity_group_text + ) affinity_group_list.append(affinity_group) extra_dict["params"] = { @@ -1195,8 +1226,11 @@ class Ns(object): step = "process NS Affinity Groups" _process_items( target_list=indata.get("affinity-or-anti-affinity-group") or [], - existing_list=db_nsr.get("affinity-or-anti-affinity-group") or [], - db_record="nsrs:{}:affinity-or-anti-affinity-group".format(nsr_id), + existing_list=db_nsr.get("affinity-or-anti-affinity-group") + or [], + db_record="nsrs:{}:affinity-or-anti-affinity-group".format( + nsr_id + ), db_update=db_nsr_update, db_path="affinity-or-anti-affinity-group", item="affinity-or-anti-affinity-group", diff --git a/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py b/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py index a15a53cf..92e1f56a 100644 --- a/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py +++ b/RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py @@ -1867,6 +1867,7 @@ class vimconnector(vimconn.VimConnector): # Create additional volumes in case these are present in disk_list base_disk_index = ord("b") + boot_volume_id = None if disk_list: block_device_mapping = {} for disk in disk_list: @@ -1876,11 +1877,13 @@ class vimconnector(vimconn.VimConnector): ] else: if "image_id" in disk: + base_disk_index = ord("a") volume = self.cinder.volumes.create( size=disk["size"], name=name + "_vd" + chr(base_disk_index), imageRef=disk["image_id"], ) + boot_volume_id = volume.id else: volume = self.cinder.volumes.create( size=disk["size"], @@ -1912,7 +1915,8 @@ class vimconnector(vimconn.VimConnector): "Timeout creating volumes for instance " + name, http_code=vimconn.HTTP_Request_Timeout, ) - + if boot_volume_id: + self.cinder.volumes.set_bootable(boot_volume_id, True) # get availability Zone vm_av_zone = self._get_vm_availability_zone( availability_zone_index, availability_zone_list diff --git a/devops-stages/stage-test.sh b/devops-stages/stage-test.sh index 9d761076..240ff987 100755 --- a/devops-stages/stage-test.sh +++ b/devops-stages/stage-test.sh @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +set -e echo "Launching tox" tox --parallel=auto diff --git a/releasenotes/notes/fix_bug_1911-e84f3fe699d114cf.yaml b/releasenotes/notes/fix_bug_1911-e84f3fe699d114cf.yaml new file mode 100644 index 00000000..fdcbf34d --- /dev/null +++ b/releasenotes/notes/fix_bug_1911-e84f3fe699d114cf.yaml @@ -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: + - | + This fixes the bug 1911 Root disk cannot be a Persistent Volume. VNFs could have + persistent root disk if the disk type is defined as persistent-storage. Besides, + the problem of creating one more persistent volume is solved. \ No newline at end of file -- 2.25.1