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')
)
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)
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
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):