Merge "[RIFT 16414, 16415, 16416] Unittest fixes to conform to the new package struct...
authorvelandy <rajesh.velandy@riftio.com>
Thu, 11 May 2017 18:35:55 +0000 (20:35 +0200)
committerGerrit Code Review <root@osm.etsi.org>
Thu, 11 May 2017 18:35:55 +0000 (20:35 +0200)
models/openmano/python/rift/openmano/rift2openmano.py
models/plugins/yang/nsd.yang
models/plugins/yang/nsr.yang
models/plugins/yang/vnfd.yang
rwlaunchpad/plugins/rwlaunchpadtasklet/rift/package/package.py
rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/openmano_nsm.py

index 276573c..b1d1c8b 100755 (executable)
@@ -488,6 +488,8 @@ def rift2openmano_vnfd(rift_vnfd, rift_nsd):
             raise ValueError("VDU Virtual Interface type {} not supported".format(rift_type))
 
     # Add all external connections
+    cp_to_port_security_map = {}
+
     for cp in rift_vnfd.cps:
         # Find the VDU and and external interface for this connection point
         vdu, ext_if = find_vdu_and_ext_if_by_cp_ref(cp.name)
@@ -499,6 +501,8 @@ def rift2openmano_vnfd(rift_vnfd, rift_nsd):
             "description": "%s iface on VDU %s" % (ext_if.name, vdu.name),
             }
 
+        if cp.has_field('port_security_enabled'):
+            cp_to_port_security_map[cp.name] = cp.port_security_enabled
         vnf["external-connections"].append(connection)
 
     # Add all internal networks
@@ -677,6 +681,9 @@ def rift2openmano_vnfd(rift_vnfd, rift_nsd):
                         if bps/x[1] >= 1:
                             intf["bandwidth"] = "{} {}bps".format(math.ceil(bps/x[1]), x[0])
 
+        for bridge_iface in vnfc["bridge-ifaces"]:
+            if bridge_iface['name'] in cp_to_port_security_map:
+                bridge_iface['port-security'] = cp_to_port_security_map[bridge_iface['name']]
         # Sort bridge-ifaces-list TODO sort others
         newlist = sorted(vnfc["bridge-ifaces"], key=lambda k: k['name'])
         vnfc["bridge-ifaces"] = newlist
index 7818391..7adc2f2 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * 
+ *
  *   Copyright 2016 RIFT.IO Inc
  *
  *   Licensed under the Apache License, Version 2.0 (the "License");
@@ -279,7 +279,7 @@ module nsd
       uses manotypes:provider-network;
 
       leaf mgmt-network {
-         description "Flag indicating whether this network is a VIM management network"; 
+         description "Flag indicating whether this network is a VIM management network";
          type boolean;
          default false;
       }
@@ -299,10 +299,11 @@ module nsd
         case vim-network-profile {
           leaf ip-profile-ref {
             description "Named reference to IP-profile object";
-            type string;
-          } 
+            type leafref {
+              path "../../ip-profiles/name";
+            }
+          }
         }
-
       }
     }
 
@@ -316,7 +317,7 @@ module nsd
       leaf member-vnf-index {
         description
           "Identifier/index for the VNFD. This separate id
-           is required so that multiple VNFs can be part of 
+           is required so that multiple VNFs can be part of
            single NS";
         type uint64;
       }
@@ -376,7 +377,7 @@ module nsd
 
         leaf scale-in-operation-type {
           description
-              "Operation to be applied to check between scaling criterias to 
+              "Operation to be applied to check between scaling criterias to
                check if the scale in threshold condition has been met.
                Defaults to AND";
           type scaling-criteria-operation;
@@ -385,7 +386,7 @@ module nsd
 
         leaf scale-out-operation-type {
           description
-              "Operation to be applied to check between scaling criterias to 
+              "Operation to be applied to check between scaling criterias to
                check if the scale out threshold condition has been met.
                Defaults to OR";
           type scaling-criteria-operation;
@@ -433,7 +434,7 @@ module nsd
           }
 
           leaf ns-monitoring-param-ref {
-            description 
+            description
                "Reference to the NS level monitoring parameter
                 that is aggregated";
             type leafref {
@@ -468,7 +469,7 @@ module nsd
         description
           "Minimum number of instances of the scaling group that
           are allowed in a single network service. These instances
-          are created by default when the network service is 
+          are created by default when the network service is
           instantiated.";
         type uint32;
         default 0;
@@ -477,7 +478,7 @@ module nsd
       leaf max-instance-count {
         description
           "Maximum number of instances of this scaling group that
-          are allowed in a single network service. The network 
+          are allowed in a single network service. The network
           service scaling fails when the number of service group
           instances exceeds the max-instance-count specified.";
         type uint32;
@@ -525,7 +526,7 @@ module nsd
           description
               "Identifier for the VNFD.";
           type leafref {
-            path "../../../constituent-vnfd" + 
+            path "../../../constituent-vnfd" +
                  "[member-vnf-index = current()/../member-vnf-index-ref]" +
                  "/vnfd-id-ref";
           }
@@ -806,8 +807,8 @@ module nsd
 
     list parameter-pool {
       description
-         "Pool of parameter values from which to choose during 
-         configuration.";  
+         "Pool of parameter values from which to choose during
+         configuration.";
       key "name";
 
       leaf name {
@@ -912,7 +913,7 @@ module nsd
         type string;
       }
     }
+
     list initial-config-primitive {
       rwpb:msg-new NsdInitialConfigPrimitive;
       description
index 3fdd642..a3f9f57 100644 (file)
@@ -855,7 +855,7 @@ module nsr
             leaf member-vnf-index-ref {
               description
                  "Reference to member-vnf within constituent-vnfds";
-              type string;
+              type uint64;
             }
 
             leaf vnfd-id-ref {
index 1dfb459..51bb9f7 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * 
+ *
  *   Copyright 2016 RIFT.IO Inc
  *
  *   Licensed under the Apache License, Version 2.0 (the "License");
@@ -292,10 +292,11 @@ module vnfd
           case vim-network-profile {
             leaf ip-profile-ref {
               description "Named reference to IP-profile object";
-              type string;
+              type leafref {
+                path "../../ip-profiles/name";
+              }
             }
           }
-
         }
       }
 
@@ -453,7 +454,7 @@ module vnfd
           }
 
           uses manotypes:volume-info;
-        } 
+        }
       }
 
       list vdu-dependency {
index 2859b1b..6f77985 100644 (file)
@@ -431,10 +431,21 @@ class DescriptorPackage(object):
         Raises:
             NotADirectoryError - dest_root_dir is not a directory
         """
+        def find_prefix():
+            """ Find comon prefix of all files in package. This prefix will be 
+            used to collapse directory structure during extraction to eliminate 
+            empty nested folders.
+            """
+            common_dir = set() 
+            for f in self.files: 
+                common_dir.add(os.path.dirname(f))
+            prefix = os.path.commonprefix(list(common_dir))
+            return prefix if prefix else None
+
         if not os.path.isdir(dest_root_dir):
             raise NotADirectoryError(dest_root_dir)
 
-        self.extract_dir(None, dest_root_dir, extract_images)
+        self.extract_dir(find_prefix(), dest_root_dir, extract_images)
 
     def open(self, rel_path):
         """ Open a file contained in the package in read-only, binary mode.
index db08e8e..f8ce1aa 100644 (file)
@@ -528,7 +528,6 @@ class OpenmanoNsr(object):
     def add_nsr(self, nsr, vnfr):
         self._nsrs[vnfr.id] = nsr
 
-    @asyncio.coroutine
     def delete(self):
         if not self._created:
             self._log.debug("NSD wasn't created.  Skipping delete.")