New feature: Support for ping pong charm 70/1170/1
authorPhilip Joseph <philip.joseph@riftio.com>
Thu, 5 Jan 2017 08:10:20 +0000 (08:10 +0000)
committerPhilip Joseph <philip.joseph@riftio.com>
Thu, 23 Feb 2017 14:19:32 +0000 (19:49 +0530)
Signed-off-by: Philip Joseph <philip.joseph@riftio.com>
examples/ping_pong_ns/rift/mano/examples/ping_pong_nsd.py
models/plugins/yang/vnfd.yang
rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/rwconman_config.py

index ca4bb67..cce685c 100755 (executable)
@@ -834,14 +834,14 @@ class VirtualNetworkFunction(ManoDescriptor):
                     member_vdu.member_vdu_ref = vdu.id
 
 
-    def write_to_file(self, outdir, output_format, use_vca_conf=False):
+    def write_to_file(self, outdir, output_format):
         dirpath = "%s/%s" % (outdir, self.name)
         if not os.path.exists(dirpath):
             os.makedirs(dirpath)
         super(VirtualNetworkFunction, self).write_to_file(['vnfd', 'rw-vnfd'],
                                                           dirpath,
                                                           output_format)
-        self.add_scripts(outdir, use_vca_conf=use_vca_conf)
+        self.add_scripts(outdir)
 
     def add_cloud_init(self, outdir):
         script_dir = os.path.join(outdir, self.name, 'cloud_init')
@@ -1700,10 +1700,8 @@ def generate_ping_pong_descriptors(fmt="json",
     )
 
     if write_to_file:
-        ping.write_to_file(out_dir, ping_fmt if ping_fmt is not None else fmt,
-                           use_vca_conf=use_vca_conf)
-        pong.write_to_file(out_dir, pong_fmt if ping_fmt is not None else fmt,
-                           use_vca_conf=use_vca_conf)
+        ping.write_to_file(out_dir, ping_fmt if ping_fmt is not None else fmt)
+        pong.write_to_file(out_dir, pong_fmt if ping_fmt is not None else fmt)
         nsd_catalog.write_config(out_dir, vnfd_list)
         nsd_catalog.write_to_file(out_dir, ping_fmt if nsd_fmt is not None else fmt)
 
index fb1bd03..e218a92 100644 (file)
@@ -342,6 +342,13 @@ module vnfd
           type inet:port-number;
         }
 
+        leaf ssh-key {
+          description
+            "Whether SSH keys need to be generated and passed
+             to the RO and VCA during instantiation.";
+          type boolean;
+        }
+
         container dashboard-params {
           description "Parameters for the VNF dashboard";
 
index 7fbe123..3fa827e 100644 (file)
@@ -1084,6 +1084,7 @@ class ConfigManagerConfig(object):
                         if k in vdu:
                             d[k] = vdu[k]
                     vdu_data.append(d)
+
                 v['vdur'].append(vdu_data)
 
                 inp['vnfr'][vnfr['member_vnf_index_ref']] = v
@@ -1202,27 +1203,33 @@ class ConfigManagerConfig(object):
 
                     inp_file = get_input_file(parameters)
 
-        vnfd = vnfr.vnfd
-        vnf_cfg = vnfd.vnf_configuration
-
-        for conf in vnf_cfg.initial_config_primitive:
-                self._log.debug("VNFR {} initial config: {}".
-                                format(vnfr_name, conf))
-
-                if not conf.user_defined_script:
-                    self._log.debug("VNFR {} did not fine user defined script: {}".
-                                    format(vnfr_name, conf))
-                    continue
-
-                script = self.get_script_file(conf.user_defined_script,
-                                              vnfd.name,
-                                              vnfd.id,
-                                              'vnfd')
+                    script = get_script_file(conf['user_defined_script'],
+                                             nsd.name,
+                                             nsd.id)
+
+                    cmd = "{0} {1}".format(script, inp_file)
+                    self._log.debug("Running the CMD: {}".format(cmd))
+
+                    process = yield from asyncio. \
+                              create_subprocess_shell(
+                                  cmd, loop=self._loop,
+                                  stdout=asyncio.subprocess.PIPE,
+                                  stderr=asyncio.subprocess.PIPE)
+                    yield from process.wait()
+                    if process.returncode:
+                        script_out, script_err = yield from process.communicate()
+                        msg = "NSR {} initial config using {} failed with {}". \
+                              format(nsr_name, script, process.returncode)
+                        self._log.error(msg)
+                        self._log.error("Script {} stderr: {}".
+                                        format(script, script_err))
+                        raise InitialConfigError(msg)
+                    else:
+                        os.remove(inp_file)
 
-                yield from self.process_initial_config(nsr_obj,
-                                                       conf.as_dict(),
-                                                       script,
-                                                       vnfr_name=vnfr_name)
+            except KeyError as e:
+                self._log.debug("Did not find initial config: {}".
+                                format(e))
 
 
 class ConfigManagerNSR(object):