New Feature : Addtional changes for VNF access point support 38/738/1
authorPhilip Joseph <philip.joseph@riftio.com>
Thu, 17 Nov 2016 09:26:29 +0000 (14:56 +0530)
committerPhilip Joseph <philip.joseph@riftio.com>
Mon, 28 Nov 2016 19:37:20 +0000 (01:07 +0530)
Signed-off-by: Philip Joseph <philip.joseph@riftio.com>
common/python/rift/mano/config_data/config.py
common/python/rift/mano/config_data/test/test_converter.py
examples/ping_pong_ns/rift/mano/examples/ping_pong_nsd.py
models/plugins/yang/mano-types.yang
models/plugins/yang/vnfd.yang
rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/RiftCM_rpc.py
rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/jujuconf.py
rwlaunchpad/test/mano_ut.py

index 63a2e48..5210904 100644 (file)
@@ -250,7 +250,7 @@ class ConfigPrimitiveConvertor(object):
     def extract_vnfd_config(self, vnfd, format="yaml"):
         config_prim = None
         try:
-            config_prim = vnfd.vnf_configuration.service_primitive
+            config_prim = vnfd.vnf_configuration.config_primitive
         except AttributeError:
             pass
 
@@ -339,7 +339,7 @@ class ConfigPrimitiveConvertor(object):
                 vnfd_init_cfg_prim_msg.append(prim)
 
     def merge_vnfd_config(self, vnfd, input_data):
-        for config_primitive in vnfd.vnf_configuration.service_primitive:
+        for config_primitive in vnfd.vnf_configuration.config_primitive:
             try:
                 cfg = input_data[self.CONFIG_PRIMITIVE][config_primitive.name]
             except KeyError:
index 1bfd7d7..4d29b67 100644 (file)
@@ -222,14 +222,14 @@ def test_vnfd_config_prim(vnfd, convertor):
             ],
         })
 
-    vnf_config.service_primitive.add().from_dict({
+    vnf_config.config_primitive.add().from_dict({
         "name": "PE1",
         "parameter": [
                 {"name": "Foo", "default_value": "Bar"}
         ]
         })
 
-    expected_yaml = """service_primitive:
+    expected_yaml = """config_primitive:
   PE1:
     parameter:
       Foo: Bar
@@ -267,12 +267,12 @@ def test_vnfd_merge(vnfd, convertor):
             "parameter": [{"name": "cidr"}],
         })
 
-    vnf_config.service_primitive.add().from_dict({
+    vnf_config.config_primitive.add().from_dict({
         "name": "PE1",
         "parameter": [{"name": "Foo",}]
         })
 
-    ip_yaml = """service_primitive:
+    ip_yaml = """config_primitive:
   PE1:
     parameter:
       Foo: Bar
@@ -311,7 +311,7 @@ initial_config_primitive:
             ],
         })
 
-    vnf_config.service_primitive.add().from_dict({
+    vnf_config.config_primitive.add().from_dict({
         "name": "PE1",
         "parameter": [
                 {"name": "Foo", "default_value": "Bar"}
index d84a912..5c02cbb 100755 (executable)
@@ -125,9 +125,218 @@ class VirtualNetworkFunction(ManoDescriptor):
     def add_placement_group(self, group):
         self._placement_groups.append(group)
 
+    def add_vnf_access_point(self, mano_ut=False):
+        vnfd = self.descriptor.vnfd[0]
+        vnfap = vnfd.vnfap
+        cap = vnfap.create_capability()
+        cap.from_dict({
+            "name": "mgmt_ip",
+            "description": "Management address",
+            "attribute": "../../../../mgmt-interface, ip-address",
+        })
+        vnfap.capability.append(cap)
+        cap = vnfap.create_capability()
+        cap.from_dict({
+            "name": "mgmt_port",
+            "description": "Management port",
+            "xpath": "../../../../mgmt-interface/port",
+        })
+        vnfap.capability.append(cap)
+        cap = vnfap.create_capability()
+        cap.from_dict({
+            "name": "username",
+            "description": "Management username",
+            "value": "admin"
+        })
+        vnfap.capability.append(cap)
+        cap = vnfap.create_capability()
+        cap.from_dict({
+            "name": "password",
+            "description": "Management password",
+            "value": "admin"
+        })
+        vnfap.capability.append(cap)
+
+        # Check if pong
+        if 'pong_' in self.name:
+            cap = vnfap.create_capability()
+            cap.from_dict({
+                "name": "service_ip",
+                "description": "IP on which Pong service is listening",
+                "attribute": "../../../../connection-point[name='pong_vnfd/cp0'], ip-address"
+            })
+            vnfap.capability.append(cap)
+            cap = vnfap.create_capability()
+            cap.from_dict({
+                "name": "service_port",
+                "description": "Port on which server listens for incoming data packets",
+                "value": "5555"
+            })
+            vnfap.capability.append(cap)
+
+        else:
+            cap = vnfap.create_capability()
+            cap.from_dict({
+                "name": "rate",
+                "description": "Rate of packet generation",
+                "value": "5"
+            })
+            vnfap.capability.append(cap)
+
+            dep = vnfap.create_dependency()
+            dep.from_dict({
+                "name": "service_ip",
+                "description": "IP on which Pong service is listening",
+                "mandatory": "true",
+            })
+            dep.config_primitive_name_ref.append('config')
+            vnfap.dependency.append(dep)
+            dep = vnfap.create_dependency()
+            dep.from_dict({
+                "name": "service_port",
+                "description": "Port on which Pong service is listening",
+                "mandatory": False,
+            })
+            dep.config_primitive_name_ref.append('config')
+            vnfap.dependency.append(dep)
+
+    def add_ping_config(self, mano_ut=False, use_ns_init_conf=False):
+        vnfd = self.descriptor.vnfd[0]
+        # Add vnf configuration
+        vnf_config = vnfd.vnf_configuration
+
+        vnf_config.config_attributes.config_delay = 60
+
+        # Add config primitive
+        vnf_config.create_config_primitive()
+        prim = VnfdYang.ConfigPrimitive.from_dict({
+            "name": "config",
+            "parameter": [
+                {"name": "mgmt_ip", "data_type": "STRING"},
+                {"name": "mgmt_port", "data_type": "INTEGER"},
+                {"name": "username", "data_type": "STRING"},
+                {"name": "password", "data_type": "STRING"},
+                {"name": "service_ip", "data_type": "STRING"},
+                {"name": "service_port", "data_type": "INTEGER",
+                 "default_value": "5555"},
+            ],
+            "user_defined_script": "ping-setup.py",
+        })
+        vnf_config.config_primitive.append(prim)
+
+        prim = VnfdYang.ConfigPrimitive.from_dict({
+            "name": "set-rate",
+            "parameter": [
+                {"name": "mgmt_ip", "data_type": "STRING"},
+                {"name": "mgmt_port", "data_type": "INTEGER"},
+                {"name": "username", "data_type": "STRING"},
+                {"name": "password", "data_type": "STRING"},
+                {"name": "rate", "data_type": "INTEGER",
+                 "default_value": "5"},
+            ],
+            "user_defined_script": "ping-set-rate.py",
+        })
+        vnf_config.config_primitive.append(prim)
+
+        prim = VnfdYang.ConfigPrimitive.from_dict({
+            "name": "start-stop",
+            "parameter": [
+                {"name": "mgmt_ip", "data_type": "STRING"},
+                {"name": "mgmt_port", "data_type": "INTEGER"},
+                {"name": "username", "data_type": "STRING"},
+                {"name": "password", "data_type": "STRING"},
+                {"name": "start", "data_type": "BOOLEAN",
+                 "default_value": "true"}
+            ],
+            "user_defined_script": "ping-start-stop.py",
+        })
+        vnf_config.config_primitive.append(prim)
+
+        # Add initial config primitive
+        vnf_config.create_initial_config_primitive()
+        init_config = VnfdYang.InitialConfigPrimitive.from_dict(
+            {
+                "seq": 1,
+                "config_primitive_ref": "config",
+            }
+        )
+        vnf_config.initial_config_primitive.append(init_config)
+
+        init_config = VnfdYang.InitialConfigPrimitive.from_dict(
+            {
+                "seq": 2,
+                "config_primitive_ref": "set-rate",
+            },
+        )
+        vnf_config.initial_config_primitive.append(init_config)
+
+        if use_ns_init_conf is False:
+            init_config = VnfdYang.InitialConfigPrimitive.from_dict(
+                {
+                    "seq": 3,
+                    "config_primitive_ref": "start-stop",
+                },
+            )
+            vnf_config.initial_config_primitive.append(init_config)
+
+    def add_pong_config(self, mano_ut=False, use_ns_init_conf=False):
+        vnfd = self.descriptor.vnfd[0]
+        # Add vnf configuration
+        vnf_config = vnfd.vnf_configuration
+
+        # Add config primitive
+        vnf_config.create_config_primitive()
+        prim = VnfdYang.ConfigPrimitive.from_dict({
+            "name": "config",
+            "parameter": [
+                {"name": "mgmt_ip", "data_type": "STRING"},
+                {"name": "mgmt_port", "data_type": "INTEGER"},
+                {"name": "username", "data_type": "STRING"},
+                {"name": "password", "data_type": "STRING"},
+                {"name": "service_ip", "data_type": "STRING"},
+                {"name": "service_port", "data_type": "INTEGER"},
+            ],
+            "user_defined_script": "ping-setup.py",
+        })
+        vnf_config.config_primitive.append(prim)
+
+        prim = VnfdYang.ConfigPrimitive.from_dict({
+            "name": "start-stop",
+            "parameter": [
+                {"name": "mgmt_ip", "data_type": "STRING"},
+                {"name": "mgmt_port", "data_type": "INTEGER"},
+                {"name": "username", "data_type": "STRING"},
+                {"name": "password", "data_type": "STRING"},
+                {"name": "start", "data_type": "BOOLEAN",
+                 "default_value": "true"}
+            ],
+            "user_defined_script": "ping-start-stop.py",
+        })
+        vnf_config.config_primitive.append(prim)
+
+        # Add initial config primitive
+        vnf_config.create_initial_config_primitive()
+        init_config = VnfdYang.InitialConfigPrimitive.from_dict(
+            {
+                "seq": 1,
+                "config_primitive_ref": "config",
+            }
+        )
+        vnf_config.initial_config_primitive.append(init_config)
+
+        if use_ns_init_conf is False:
+            init_config = VnfdYang.InitialConfigPrimitive.from_dict(
+                {
+                    "seq": 2,
+                    "config_primitive_ref": "start-stop",
+                },
+            )
+            vnf_config.initial_config_primitive.append(init_config)
+
     def compose(self, image_name, cloud_init="", cloud_init_file="", endpoint=None, mon_params=[],
                 mon_port=8888, mgmt_port=8888, num_vlr_count=1, num_ivlr_count=1,
-                num_vms=1, image_md5sum=None, mano_ut=False):
+                num_vms=1, image_md5sum=None, mano_ut=False, use_ns_init_conf=False,
+                use_vca_conf=False):
         self.descriptor = RwVnfdYang.YangData_Vnfd_VnfdCatalog()
         self.id = str(uuid.uuid1())
         vnfd = self.descriptor.vnfd.add()
@@ -202,6 +411,13 @@ class VirtualNetworkFunction(ManoDescriptor):
                 if aws:
                     vdu.cloud_init += "  - [ systemctl, restart, --no-block, elastic-network-interfaces.service ]\n"
 
+            # Add VNF access point
+            self.add_vnf_access_point(mano_ut=mano_ut)
+            if 'pong_' in self.name:
+                self.add_pong_config(mano_ut=mano_ut, use_ns_init_conf=use_ns_init_conf)
+            else:
+                self.add_ping_config(mano_ut=mano_ut, use_ns_init_conf=use_ns_init_conf)
+
             # sepcify the guest EPA
             if use_epa:
                 vdu.guest_epa.trusted_execution = False
@@ -260,7 +476,7 @@ class VirtualNetworkFunction(ManoDescriptor):
                     internal_cp.name = cp_name + "/icp{}".format(i)
                     internal_cp.id = cp_name + "/icp{}".format(i)
                     internal_cp.type_yang = 'VPORT'
-                    ivld_cp = internal_vlds[i].internal_connection_point_ref.add()
+                    ivld_cp = internal_vlds[i].internal_connection_point.add()
                     ivld_cp.id_ref = internal_cp.id
 
                     internal_interface = vdu.internal_interface.add()
@@ -499,8 +715,8 @@ exit 0
             # Config parameters can be taken from config.yaml and
             # actions from actions.yaml in the charm
             # Config to set the home domain
-            vnf_config.create_service_primitive()
-            config = VnfdYang.ServicePrimitive.from_dict({
+            vnf_config.create_config_primitive()
+            config = VnfdYang.ConfigPrimitive.from_dict({
                 "name": "config",
                 "parameter": [
                     {"name": "home_domain", "data_type": "STRING"},
@@ -509,9 +725,9 @@ exit 0
                     {"name": "password", "data_type": "STRING"},
                 ]
             })
-            vnf_config.service_primitive.append(config)
+            vnf_config.config_primitive.append(config)
 
-            config = VnfdYang.ServicePrimitive.from_dict({
+            config = VnfdYang.ConfigPrimitive.from_dict({
                 "name": "create-update-user",
                 # "user-defined-script":"/tmp/test.py",
                 "parameter": [
@@ -519,15 +735,15 @@ exit 0
                     {"name": "password", "data_type": "STRING", "mandatory": True},
                 ]
             })
-            vnf_config.service_primitive.append(config)
+            vnf_config.config_primitive.append(config)
 
-            config = VnfdYang.ServicePrimitive.from_dict({
+            config = VnfdYang.ConfigPrimitive.from_dict({
                 "name": "delete-user",
                 "parameter": [
                     {"name": "number", "data_type": "STRING", "mandatory": True},
                 ]
             })
-            vnf_config.service_primitive.append(config)
+            vnf_config.config_primitive.append(config)
 
     def default_config(self, const_vnfd, vnfd, mano_ut, use_ns_init_conf):
         vnf_config = vnfd.vnfd.vnf_configuration
@@ -615,7 +831,9 @@ exit 0
 
 
 
-    def compose(self, vnfd_list, cpgroup_list, mano_ut, use_ns_init_conf=True):
+    def compose(self, vnfd_list, cpgroup_list, mano_ut,
+                use_ns_init_conf=True,
+                use_vca_conf=False):
 
         if mano_ut:
             # Disable NS initial config primitive
@@ -678,8 +896,9 @@ exit 0
                     constituent_vnfd.start_by_default = False
 
                 constituent_vnfd.vnfd_id_ref = vnfd.descriptor.vnfd[0].id
-                self.default_config(constituent_vnfd, vnfd, mano_ut,
-                                    use_ns_init_conf,)
+                if use_vca_conf is False:
+                    self.default_config(constituent_vnfd, vnfd, mano_ut,
+                                        use_ns_init_conf)
                 member_vnf_index += 1
 
         # Enable config primitives if either mano_ut or
@@ -892,6 +1111,7 @@ def generate_ping_pong_descriptors(fmt="json",
                                    ex_pong_userdata=None,
                                    use_placement_group=True,
                                    use_ns_init_conf=True,
+                                   use_vca_conf=True,
                                    ):
     # List of connection point groups
     # Each connection point group refers to a virtual link
@@ -936,6 +1156,8 @@ def generate_ping_pong_descriptors(fmt="json",
             num_vms=num_vnf_vms,
             image_md5sum=ping_md5sum,
             mano_ut=mano_ut,
+            use_ns_init_conf=use_ns_init_conf,
+            use_vca_conf=use_vca_conf,
             )
 
     pong = VirtualNetworkFunction("pong_vnfd%s" % (suffix))
@@ -976,6 +1198,8 @@ def generate_ping_pong_descriptors(fmt="json",
             num_vms=num_vnf_vms,
             image_md5sum=pong_md5sum,
             mano_ut=mano_ut,
+            use_ns_init_conf=use_ns_init_conf,
+            use_vca_conf=use_vca_conf,
             )
 
     # Initialize the member VNF index
@@ -1041,7 +1265,9 @@ def generate_ping_pong_descriptors(fmt="json",
     nsd_catalog.compose(vnfd_list,
                         cpgroup_list,
                         mano_ut,
-                        use_ns_init_conf=use_ns_init_conf,)
+                        use_ns_init_conf=use_ns_init_conf,
+                        use_vca_conf=use_vca_conf,
+    )
 
     if write_to_file:
         ping.write_to_file(out_dir, ping_fmt if ping_fmt is not None else fmt)
index 91e981e..da5d1cd 100644 (file)
@@ -279,6 +279,13 @@ module mano-types
           key "name";
           uses primitive-parameter;
         }
+
+        leaf user-defined-script {
+          description
+            "A user defined script. If user defined script is defined,
+             the script will be executed using bash";
+          type string;
+        }
       }
 
       list initial-config-primitive {
@@ -304,7 +311,7 @@ module mano-types
           }
 
           case primitive-ref {
-            leaf config-primtive-ref {
+            leaf config-primitive-ref {
               description
                 "Reference to a config primitive name.
                  NOTE: The config primitive referred should have
index 5fd811e..20072d6 100644 (file)
@@ -117,10 +117,11 @@ module vnfd
 
   grouping vnf-access-point {
     container vnfap {
+      rwpb:msg-new VnfAp;
       description
         "List of VNF access points, i.e., the capabilites
          and dependencies.";
-      list capbility {
+      list capability {
         description "The list of capabilites of this VNF";
         key "name";
 
index 5f33024..a215f67 100644 (file)
@@ -105,7 +105,7 @@ class RiftCMRPCHandler(object):
         if vnf:
             self._log.debug("nsr/vnf {}/{}, vnf_configuration: %s",
                             vnf.vnf_configuration)
-            for primitive in vnf.vnf_configuration.service_primitive:
+            for primitive in vnf.vnf_configuration.config_primitive:
                 if primitive.name == primitive_name:
                     return primitive
 
index dce31c3..e951754 100644 (file)
@@ -316,7 +316,7 @@ class JujuConfigPlugin(riftcm_config_plugin.RiftCMConfigPluginBase):
             service = vnfr['vnf_juju_name']
             vnf_config = vnfr['config']
             self._log.debug("VNF config %s", vnf_config)
-            configs = vnf_config.service_primitive
+            configs = vnf_config.config_primitive
             for config in configs:
                 if config.name == primitive.name:
                     self._log.debug("jujuCA: Found the config primitive %s",
index 69a0d40..a4ef59d 100755 (executable)
@@ -642,7 +642,7 @@ class PingPongDescriptorPublisher(object):
                         internal_vlr_count=num_internal_vlrs,
                         num_vnf_vms=2,
                         mano_ut=True,
-                        use_scale_group=True,
+                        use_scale_group=False,
                         use_mon_params=False,
                         )