Fix bug 1803 - adding ephemeral disks 89/11389/1
authorsousaedu <eduardo.sousa@canonical.com>
Mon, 22 Nov 2021 14:02:17 +0000 (14:02 +0000)
committersousaedu <eduardo.sousa@canonical.com>
Mon, 22 Nov 2021 19:25:58 +0000 (19:25 +0000)
Change-Id: Ie29e598271b1aa5ab78d65826f513c31d0b580be
Signed-off-by: sousaedu <eduardo.sousa@canonical.com>
NG-RO/osm_ng_ro/ns.py
RO-VIM-openstack/osm_rovim_openstack/vimconn_openstack.py
releasenotes/notes/fix_bug_1803-3b91c88af8fc6ba8.yaml [new file with mode: 0644]

index ee0463a..d42433b 100644 (file)
@@ -539,6 +539,8 @@ class Ns(object):
 
                     return quota
 
+                nonlocal indata
+
                 flavor_data = {
                     "disk": int(target_flavor["storage-gb"]),
                     "ram": int(target_flavor["memory-mb"]),
@@ -547,6 +549,21 @@ class Ns(object):
                 numa = {}
                 extended = {}
 
+                target_vdur = None
+                for vnf in indata.get("vnf", []):
+                    for vdur in vnf.get("vdur", []):
+                        if vdur.get("ns-flavor-id") == target_flavor["id"]:
+                            target_vdur = vdur
+
+                for storage in target_vdur.get("virtual-storages", []):
+                    if (
+                        storage.get("type-of-storage")
+                        == "etsi-nfv-descriptors:ephemeral-storage"
+                    ):
+                        flavor_data["ephemeral"] = int(
+                            storage.get("size-of-storage", 0)
+                        )
+
                 if target_flavor.get("guest-epa"):
                     extended = {}
                     epa_vcpu_set = False
index d3837ab..297e14b 100644 (file)
@@ -1177,6 +1177,7 @@ class vimconnector(vimconn.VimConnector):
                 flavor_dict["ram"],
                 flavor_dict["vcpus"],
                 flavor_dict["disk"],
+                flavor_dict.get("ephemeral", 0),
             )
             # numa=None
             extended = flavor_dict.get("extended", {})
@@ -1196,7 +1197,12 @@ class vimconnector(vimconn.VimConnector):
                     continue
                     # TODO
 
-                flavor_data = (flavor.ram, flavor.vcpus, flavor.disk)
+                flavor_data = (
+                    flavor.ram,
+                    flavor.vcpus,
+                    flavor.disk,
+                    flavor.ephemeral,
+                )
                 if flavor_data == flavor_target:
                     return flavor.id
                 elif (
@@ -1346,10 +1352,11 @@ class vimconnector(vimconn.VimConnector):
 
                     # create flavor
                     new_flavor = self.nova.flavors.create(
-                        name,
-                        ram,
-                        vcpus,
-                        flavor_data.get("disk", 0),
+                        name=name,
+                        ram=ram,
+                        vcpus=vcpus,
+                        disk=flavor_data.get("disk", 0),
+                        ephemeral=flavor_data.get("ephemeral", 0),
                         is_public=flavor_data.get("is_public", True),
                     )
                     # add metadata
diff --git a/releasenotes/notes/fix_bug_1803-3b91c88af8fc6ba8.yaml b/releasenotes/notes/fix_bug_1803-3b91c88af8fc6ba8.yaml
new file mode 100644 (file)
index 0000000..e895252
--- /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:
+  - |
+    Fixing bug 1803 - this fix allows for the creation of ephemeral
+    disks.