From: Chamarty Date: Thu, 27 Apr 2017 19:36:16 +0000 (-0400) Subject: Deprecate old config-manager model attributes X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;ds=sidebyside;h=65c780c68fed897c97967a9158b702b42fc62698;hp=-c;p=osm%2FSO.git Deprecate old config-manager model attributes Change-Id: Ided08fb06ea5dadccc4dff14c3ea07689ab5136b Signed-off-by: Chamarty --- 65c780c68fed897c97967a9158b702b42fc62698 diff --git a/examples/ping_pong_ns/rift/mano/examples/ping_pong_nsd.py b/examples/ping_pong_ns/rift/mano/examples/ping_pong_nsd.py index e0a68489..0941129c 100755 --- a/examples/ping_pong_ns/rift/mano/examples/ping_pong_nsd.py +++ b/examples/ping_pong_ns/rift/mano/examples/ping_pong_nsd.py @@ -306,14 +306,9 @@ class VirtualNetworkFunction(ManoDescriptor): vnfd = self.descriptor.vnfd[0] # Add vnf configuration vnf_config = vnfd.vnf_configuration - - # vnf_config.config_attributes.config_delay = 10 - - # Select "script" configuration - vnf_config.script.script_type = 'bash' + vnf_config.script.script_type = 'python' # Add initial config primitive - vnf_config.create_initial_config_primitive() init_config = VnfdYang.InitialConfigPrimitive.from_dict( { "seq": 1, @@ -327,12 +322,9 @@ class VirtualNetworkFunction(ManoDescriptor): vnfd = self.descriptor.vnfd[0] # Add vnf configuration vnf_config = vnfd.vnf_configuration - - # Select "script" configuration - vnf_config.script.script_type = 'bash' + vnf_config.script.script_type = 'python' # Add initial config primitive - vnf_config.create_initial_config_primitive() init_config = VnfdYang.InitialConfigPrimitive.from_dict( { "seq": 1, @@ -420,15 +412,24 @@ class NetworkService(ManoDescriptor): self.vnfd_config = {} self._placement_groups = [] - def default_config(self, vnfd): + def default_config(self, constituent_vnfd, vnfd, mano_ut, use_ns_init_conf, use_vnf_init_conf): vnf_config = vnfd.vnfd.vnf_configuration vnf_config.config_attributes.config_priority = 0 vnf_config.config_attributes.config_delay = 0 - # Select "script" configuration - vnf_config.script.script_type = 'bash' - vnf_config.config_template = "#!/bin/bash" + if vnfd.name == 'pong_vnfd' or vnfd.name == 'pong_vnfd_with_epa' or vnfd.name == 'pong_vnfd_aws': + vnf_config.config_attributes.config_priority = 1 + # First priority config delay will delay the entire NS config delay + if mano_ut is False: + vnf_config.config_attributes.config_delay = 60 + else: + # This is PONG and inside mano_ut + # This is test only + vnf_config.config_attributes.config_delay = 10 + + if vnfd.name == 'ping_vnfd' or vnfd.name == 'ping_vnfd_with_epa' or vnfd.name == 'ping_vnfd_aws': + vnf_config.config_attributes.config_priority = 2 def ns_config(self, nsd, vnfd_list, mano_ut): @@ -558,7 +559,8 @@ class NetworkService(ManoDescriptor): constituent_vnfd.start_by_default = False constituent_vnfd.vnfd_id_ref = vnfd.descriptor.vnfd[0].id - self.default_config(vnfd) + self.default_config(constituent_vnfd, vnfd, mano_ut, + - use_ns_init_conf, use_vnf_init_conf) member_vnf_index += 1 # Enable config primitives if either mano_ut or diff --git a/models/plugins/yang/mano-types.yang b/models/plugins/yang/mano-types.yang index 4ec602cb..c6b40034 100644 --- a/models/plugins/yang/mano-types.yang +++ b/models/plugins/yang/mano-types.yang @@ -212,61 +212,18 @@ module mano-types choice config-method { description "Defines the configuration method for the VNF."; - case netconf { - description - "Use NETCONF for configuring the VNF."; - container netconf { - leaf target { - description - "Netconf configuration target"; - type enumeration { - enum running; - enum candidate; - } - } - - leaf protocol { - description - "Protocol to use for NETCONF, such as ssh"; - type enumeration { - enum None; - enum ssh; - } - } - - leaf port { - description - "Port for the NETCONF server."; - type inet:port-number; - } - } - } - - case rest { - description - "Use REST for configuring the VNF."; - container rest { - leaf port { - description - "Port for the REST server."; - type inet:port-number; - } - } - } - case script { description "Use custom script for configuring the VNF. - This script is executed in the context of + This script is executed in the context of Orchestrator (The same system and environment as the Launchpad)."; container script { leaf script-type { description - "Script type - currently supported : bash, expect"; + "Script type - currently supported : python"; type enumeration { - enum bash; - enum expect; + enum python; } } } @@ -284,27 +241,6 @@ module mano-types } } - container config-access { - leaf mgmt-ip-address { - description - "IP address to be used to configure this VNF, - optional if it is possible to resolve dynamically."; - type inet:ip-address; - } - - leaf username { - description - "User name for configuration."; - type string; - } - - leaf password { - description - "Password for configuration access authentication."; - type string; - } - } - container config-attributes { description "Miscellaneous input parameters to be considered @@ -353,12 +289,6 @@ module mano-types key "seq"; uses initial-config; } - - leaf config-template { - description - "Configuration template for each VNF"; - type string; - } } } // END - grouping vnf-configuration diff --git a/rwcm/plugins/rwconman/CMakeLists.txt b/rwcm/plugins/rwconman/CMakeLists.txt index adeb27c0..9a699146 100644 --- a/rwcm/plugins/rwconman/CMakeLists.txt +++ b/rwcm/plugins/rwconman/CMakeLists.txt @@ -20,18 +20,6 @@ include(rift_plugin) set(TASKLET_NAME rwconmantasklet) -set(CONMAN_INSTALL "etc/conman") - -## -# Install translation script in demos -## -install( - FILES - rift/tasklets/${TASKLET_NAME}/xlate_cfg.py - rift/tasklets/${TASKLET_NAME}/xlate_tags.yml - DESTINATION ${CONMAN_INSTALL} - COMPONENT ${PKG_LONG_NAME}) - ## # This function creates an install target for the plugin artifacts diff --git a/rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/rwconman_config.py b/rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/rwconman_config.py index 9e8b944e..3be80692 100644 --- a/rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/rwconman_config.py +++ b/rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/rwconman_config.py @@ -299,27 +299,21 @@ class ConfigManagerConfig(object): def process_nsd_vnf_configuration(self, nsr_obj, vnfr): def get_config_method(vnf_config): - cfg_types = ['netconf', 'juju', 'script'] + cfg_types = ['juju', 'script'] for method in cfg_types: if method in vnf_config: return method return None - def get_cfg_file_extension(method, configuration_options): + def get_cfg_file_extension(method): ext_dict = { - "netconf" : "xml", - "script" : { - "bash" : "sh", - "expect" : "exp", - }, - "juju" : "yml" + "juju" : "yml", + "script" : "py" } - if method == "netconf": + if method == "juju": return ext_dict[method] elif method == "script": - return ext_dict[method][configuration_options['script_type']] - elif method == "juju": return ext_dict[method] else: return "cfg" @@ -408,12 +402,6 @@ class ConfigManagerConfig(object): configuration_options[cfg_opt] = vnf_config[method][cfg_opt] vnf_cfg[cfg_opt] = configuration_options[cfg_opt] - cfg_opt_list = ['mgmt_ip_address', 'username', 'password'] - for cfg_opt in cfg_opt_list: - if cfg_opt in vnf_config['config_access']: - configuration_options[cfg_opt] = vnf_config['config_access'][cfg_opt] - vnf_cfg[cfg_opt] = configuration_options[cfg_opt] - # Add to the cp_dict vnf_cp_dict = nsr_obj._cp_dict[vnfr['member_vnf_index_ref']] vnf_cp_dict['rw_mgmt_ip'] = vnf_cfg['mgmt_ip_address'] @@ -422,22 +410,9 @@ class ConfigManagerConfig(object): # TBD - see if we can neatly include the config in "config_attributes" file, no need though - #config_priority['config_template'] = vnf_config['config_template'] # Create config file vnf_cfg['juju_script'] = os.path.join(self._parent.cfg_dir, 'juju_if.py') - - if 'config_template' in vnf_config: - vnf_cfg['cfg_template'] = '{}_{}_template.cfg'.format(nsr_obj.cfg_path_prefix, config_priority['configuration_type']) - vnf_cfg['cfg_file'] = '{}.{}'.format(nsr_obj.cfg_path_prefix, get_cfg_file_extension(method, configuration_options)) - vnf_cfg['xlate_script'] = os.path.join(self._parent.cfg_dir, 'xlate_cfg.py') - try: - # Now write this template into file - with open(vnf_cfg['cfg_template'], "w") as cf: - cf.write(vnf_config['config_template']) - except Exception as e: - self._log.error("Processing NSD, failed to generate configuration template : %s (Error : %s)", - vnf_config['config_template'], str(e)) - raise + vnf_cfg['cfg_file'] = '{}.{}'.format(nsr_obj.cfg_path_prefix, get_cfg_file_extension(method)) self._log.debug("VNF endpoint so far: %s", vnf_cfg) @@ -470,10 +445,6 @@ class ConfigManagerConfig(object): nsr_dict = self._nsr_dict self._log.info("Configure NSR, id = %s", id) - #####################TBD########################### - # yield from self._config_agent_mgr.invoke_config_agent_plugins('notify_create_nsr', self.id, self._nsd) - # yield from self._config_agent_mgr.invoke_config_agent_plugins('notify_nsr_active', self.id, self._vnfrs) - try: if id not in nsr_dict: nsr_obj = ConfigManagerNSR(self._log, self._loop, self, id) @@ -517,9 +488,6 @@ class ConfigManagerConfig(object): self._log.info("Checking NS config directory: %s", nsr_dir) if not os.path.isdir(nsr_dir): os.makedirs(nsr_dir) - # self._log.critical("NS %s is not to be configured by Service Orchestrator!", nsr_obj.nsr_name) - # yield from nsr_obj.update_ns_cm_state(conmanY.RecordState.READY_NO_CFG) - # return nsr_obj.set_config_dir(self) @@ -539,12 +507,6 @@ class ConfigManagerConfig(object): nsr_obj.agent_nsr, agent_vnfr) - #####################TBD########################### - # self._log.debug("VNF active. Apply initial config for vnfr {}".format(vnfr.name)) - # yield from self._config_agent_mgr.invoke_config_agent_plugins('apply_initial_config', - # vnfr.id, vnfr) - # yield from self._config_agent_mgr.invoke_config_agent_plugins('notify_terminate_vnf', self.id, vnfr) - except Exception as e: self._log.error("Failed processing NSR (%s) as (%s)", nsr_obj.nsr_name, str(e)) self._log.exception(e) @@ -558,13 +520,6 @@ class ConfigManagerConfig(object): except Exception as e: self._log.error("NS:(%s) failed to write config attributes file as (%s)", nsr_obj.nsr_name, str(e)) - try: - # Generate nsr_xlate_dict.yaml (For debug reference) - with open(nsr_obj.xlate_dict_file, "w") as yf: - yf.write(yaml.dump(nsr_obj._cp_dict, default_flow_style=False)) - except Exception as e: - self._log.error("NS:(%s) failed to write nsr xlate tags file as (%s)", nsr_obj.nsr_name, str(e)) - self._log.debug("Starting to configure each VNF") # Check if this NS has input parametrs @@ -576,19 +531,11 @@ class ConfigManagerConfig(object): # Go in loop to configure by specified order self._log.info("Using Dynamic configuration input parametrs for NS: %s", nsr_obj.nsr_name) - # cfg_delay = nsr_obj.nsr_cfg_config_attributes_dict['configuration_delay'] - # if cfg_delay: - # self._log.info("Applying configuration delay for NS (%s) ; %d seconds", - # nsr_obj.nsr_name, cfg_delay) - # yield from asyncio.sleep(cfg_delay, loop=self._loop) - for config_attributes_dict in nsr_obj.nsr_cfg_config_attributes_dict.values(): # Iterate through each priority level for vnf_config_attributes_dict in config_attributes_dict: # Iterate through each vnfr at this priority level - # Make up vnf_unique_name with vnfd name and member index - #vnfr_name = "{}.{}".format(nsr_obj.nsr_name, vnf_config_attributes_dict['name']) vnf_unique_name = get_vnf_unique_name( nsr_obj.nsr_name, vnf_config_attributes_dict['name'], @@ -662,9 +609,6 @@ class ConfigManagerConfig(object): # publish delete cm-state (cm-nsr) yield from nsr_obj.delete_cm_nsr() - #####################TBD########################### - # yield from self._config_agent_mgr.invoke_config_agent_plugins('notify_terminate_ns', self.id) - self._log.info("NSR(%s/%s) is deleted", nsr_obj.nsr_name, id) @asyncio.coroutine @@ -958,46 +902,7 @@ class ConfigManagerNSR(object): self._log.debug("NSR:(%s), Created configuration directory(%s)", caller._nsr['name_ref'], self.this_nsr_dir) self.config_attributes_file = os.path.join(self.this_nsr_dir, "configuration_config_attributes.yml") - self.xlate_dict_file = os.path.join(self.this_nsr_dir, "nsr_xlate_dict.yml") - def xlate_conf(self, vnfr, vnf_cfg): - - # If configuration type is not already set, try to read from attributes - if vnf_cfg['interface_type'] is None: - # Prepare unique name for this VNF - vnf_unique_name = get_vnf_unique_name( - vnf_cfg['nsr_name'], - vnfr['short_name'], - vnfr['member_vnf_index_ref'], - ) - - # Find this particular (unique) VNF's config attributes - if (vnf_unique_name in self.vnf_config_attributes_dict): - vnf_cfg_config_attributes_dict = self.vnf_config_attributes_dict[vnf_unique_name] - vnf_cfg['interface_type'] = vnf_cfg_config_attributes_dict['configuration_type'] - if 'configuration_options' in vnf_cfg_config_attributes_dict: - cfg_opts = vnf_cfg_config_attributes_dict['configuration_options'] - for key, value in cfg_opts.items(): - vnf_cfg[key] = value - - cfg_path_prefix = '{}/{}/{}_{}'.format( - self._parent._parent.cfg_dir, - vnf_cfg['nsr_name'], - vnfr['short_name'], - vnfr['member_vnf_index_ref'], - ) - - vnf_cfg['cfg_template'] = '{}_{}_template.cfg'.format(cfg_path_prefix, vnf_cfg['interface_type']) - vnf_cfg['cfg_file'] = '{}.cfg'.format(cfg_path_prefix) - vnf_cfg['xlate_script'] = self._parent._parent.cfg_dir + '/xlate_cfg.py' - - self._log.debug("VNF endpoint so far: %s", vnf_cfg) - - self._log.info("Checking cfg_template %s", vnf_cfg['cfg_template']) - if os.path.exists(vnf_cfg['cfg_template']): - return True - return False - def ConfigVNF(self, vnfr): vnf_cfg = vnfr['vnf_cfg'] @@ -1018,30 +923,9 @@ class ConfigManagerNSR(object): self._cp_dict['rw_mgmt_ip'] = vnf_cfg['mgmt_ip_address'] self._cp_dict['rw_username'] = vnf_cfg['username'] self._cp_dict['rw_password'] = vnf_cfg['password'] - ############################################################ - # TBD - Need to lookup above 3 for a given VNF, not global # - # Once we do that no need to dump below file again before # - # each VNF configuration translation. # - # This will require all existing config templates to be # - # changed for above three tags to include member index # - ############################################################ - try: - nsr_obj = vnf_cfg['nsr_obj'] - # Generate config_config_attributes.yaml (For debug reference) - with open(nsr_obj.xlate_dict_file, "w") as yf: - yf.write(yaml.dump(nsr_obj._cp_dict, default_flow_style=False)) - except Exception as e: - self._log.error("NS:(%s) failed to write nsr xlate tags file as (%s)", nsr_obj.nsr_name, str(e)) - - if 'cfg_template' in vnf_cfg: - script_cmd = 'python3 {} -i {} -o {} -x "{}"'.format(vnf_cfg['xlate_script'], vnf_cfg['cfg_template'], vnf_cfg['cfg_file'], self.xlate_dict_file) - self._log.debug("xlate script command (%s)", script_cmd) - #xlate_msg = subprocess.check_output(script_cmd).decode('utf-8') - xlate_msg = subprocess.check_output(script_cmd, shell=True).decode('utf-8') - self._log.info("xlate script output (%s)", xlate_msg) except Exception as e: vnf_cm_state['state'] = self.state_to_string(conmanY.RecordState.CFG_PROCESS_FAILED) - self._log.error("Failed to execute translation script for VNF: %s with (%s)", log_this_vnf(vnf_cfg), str(e)) + self._log.error("Failed to set tags for VNF: %s with (%s)", log_this_vnf(vnf_cfg), str(e)) return self._log.info("Applying config to VNF: %s = %s!", log_this_vnf(vnf_cfg), vnf_cfg) diff --git a/rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/rwconman_events.py b/rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/rwconman_events.py index f292a689..e576aac8 100644 --- a/rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/rwconman_events.py +++ b/rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/rwconman_events.py @@ -97,23 +97,8 @@ class ConfigManagerEvents(object): yield from self.update_vnf_state(vnf_cfg, conmanY.RecordState.CFG_SEND) try: - if vnf_cfg['config_method'] == 'netconf': - self._log.info("Creating ncc handle for VNF cfg = %s!", vnf_cfg) - self.ncc = ConfigManagerVNFnetconf(self._log, self._loop, self, vnf_cfg) - if vnf_cfg['protocol'] == 'ssh': - yield from self.ncc.connect_ssh() - else: - yield from self.ncc.connect() - yield from self.ncc.apply_edit_cfg() - elif vnf_cfg['config_method'] == 'rest': - if self.rcc is None: - self._log.info("Creating rcc handle for VNF cfg = %s!", vnf_cfg) - self.rcc = ConfigManagerVNFrestconf(self._log, self._loop, self, vnf_cfg) - self.ncc.apply_edit_cfg() - elif vnf_cfg['config_method'] == 'script': - self._log.info("Executing script for VNF cfg = %s!", vnf_cfg) - scriptc = ConfigManagerVNFscriptconf(self._log, self._loop, self, vnf_cfg) - yield from scriptc.apply_edit_cfg() + if vnf_cfg['config_method'] == 'script': + self._log.info("Executing script for VNF cfg = %s, No action needed!", vnf_cfg) elif vnf_cfg['config_method'] == 'juju': self._log.info("Executing juju config for VNF cfg = %s!", vnf_cfg) jujuc = ConfigManagerVNFjujuconf(self._log, self._loop, self._parent, vnf_cfg) @@ -139,194 +124,6 @@ class ConfigManagerEvents(object): return True -class ConfigManagerVNFscriptconf(object): - - def __init__(self, log, loop, parent, vnf_cfg): - self._log = log - self._loop = loop - self._parent = parent - self._manager = None - self._vnf_cfg = vnf_cfg - - #@asyncio.coroutine - def apply_edit_cfg(self): - vnf_cfg = self._vnf_cfg - self._log.debug("Attempting to apply scriptconf to VNF: %s", log_this_vnf(vnf_cfg)) - try: - st = os.stat(vnf_cfg['cfg_file']) - os.chmod(vnf_cfg['cfg_file'], st.st_mode | stat.S_IEXEC) - #script_msg = subprocess.check_output(vnf_cfg['cfg_file'], shell=True).decode('utf-8') - - proc = yield from asyncio.create_subprocess_exec( - vnf_cfg['script_type'], vnf_cfg['cfg_file'], - stdout=asyncio.subprocess.PIPE) - script_msg = yield from proc.stdout.read() - rc = yield from proc.wait() - - if rc != 0: - raise ScriptError( - "script config returned error code : %s" % rc - ) - - self._log.debug("config script output (%s)", script_msg) - except Exception as e: - self._log.error("Error (%s) while executing script config for VNF: %s", - str(e), log_this_vnf(vnf_cfg)) - raise - -class ConfigManagerVNFrestconf(object): - - def __init__(self, log, loop, parent, vnf_cfg): - self._log = log - self._loop = loop - self._parent = parent - self._manager = None - self._vnf_cfg = vnf_cfg - - def fetch_handle(self, response): - if response.error: - self._log.error("Failed to send HTTP config request - %s", response.error) - else: - self._log.debug("Sent HTTP config request - %s", response.body) - - @asyncio.coroutine - def apply_edit_cfg(self): - vnf_cfg = self._vnf_cfg - self._log.debug("Attempting to apply restconf to VNF: %s", log_this_vnf(vnf_cfg)) - try: - http_c = tornadoh.AsyncHTTPClient() - # TBD - # Read the config entity from file? - # Convert connectoin-point? - http_c.fetch("http://", self.fetch_handle) - except Exception as e: - self._log.error("Error (%s) while applying HTTP config", str(e)) - -class ConfigManagerVNFnetconf(object): - - def __init__(self, log, loop, parent, vnf_cfg): - self._log = log - self._loop = loop - self._parent = parent - self._manager = None - self._vnf_cfg = vnf_cfg - - self._model = RwYang.Model.create_libncx() - self._model.load_schema_ypbc(conmanY.get_schema()) - - @asyncio.coroutine - def connect(self, timeout_secs=120): - vnf_cfg = self._vnf_cfg - start_time = time.time() - self._log.debug("connecting netconf .... %s", vnf_cfg) - while (time.time() - start_time) < timeout_secs: - - try: - self._log.info("Attemping netconf connection to VNF: %s", log_this_vnf(vnf_cfg)) - - self._manager = yield from ncclient.asyncio_manager.asyncio_connect( - loop=self._loop, - host=vnf_cfg['mgmt_ip_address'], - port=vnf_cfg['port'], - username=vnf_cfg['username'], - password=vnf_cfg['password'], - allow_agent=False, - look_for_keys=False, - hostkey_verify=False, - ) - - self._log.info("Netconf connected to VNF: %s", log_this_vnf(vnf_cfg)) - return - - except ncclient.transport.errors.SSHError as e: - yield from self._parent.update_vnf_state(vnf_cfg, conmanY.RecordState.FAILED_CONNECTION) - self._log.error("Netconf connection to VNF: %s, failed: %s", - log_this_vnf(vnf_cfg), str(e)) - - yield from asyncio.sleep(2, loop=self._loop) - - raise ConfigManagerROifConnectionError( - "Failed to connect to VNF: %s within %s seconds" % - (log_this_vnf(vnf_cfg), timeout_secs) - ) - - @asyncio.coroutine - def connect_ssh(self, timeout_secs=120): - vnf_cfg = self._vnf_cfg - start_time = time.time() - - if (self._manager != None and self._manager.connected == True): - self._log.debug("Disconnecting previous session") - self._manager.close_session - - self._log.debug("connecting netconf via SSH .... %s", vnf_cfg) - while (time.time() - start_time) < timeout_secs: - - try: - yield from self._parent.update_vnf_state(vnf_cfg, conmanY.RecordState.CONNECTING) - self._log.debug("Attemping netconf connection to VNF: %s", log_this_vnf(vnf_cfg)) - - self._manager = ncclient.asyncio_manager.manager.connect_ssh( - host=vnf_cfg['mgmt_ip_address'], - port=vnf_cfg['port'], - username=vnf_cfg['username'], - password=vnf_cfg['password'], - allow_agent=False, - look_for_keys=False, - hostkey_verify=False, - ) - - yield from self._parent.update_vnf_state(vnf_cfg, conmanY.RecordState.NETCONF_SSH_CONNECTED) - self._log.debug("netconf over SSH connected to VNF: %s", log_this_vnf(vnf_cfg)) - return - - except ncclient.transport.errors.SSHError as e: - yield from self._parent.update_vnf_state(vnf_cfg, conmanY.RecordState.FAILED_CONNECTION) - self._log.error("Netconf connection to VNF: %s, failed: %s", - log_this_vnf(vnf_cfg), str(e)) - - yield from asyncio.sleep(2, loop=self._loop) - - raise ConfigManagerROifConnectionError( - "Failed to connect to VNF: %s within %s seconds" % - (log_this_vnf(vnf_cfg), timeout_secs) - ) - - @asyncio.coroutine - def apply_edit_cfg(self): - vnf_cfg = self._vnf_cfg - self._log.debug("Attempting to apply netconf to VNF: %s", log_this_vnf(vnf_cfg)) - - if self._manager is None: - self._log.error("Netconf is not connected to VNF: %s, aborting!", log_this_vnf(vnf_cfg)) - return - - # Get config file contents - try: - with open(vnf_cfg['cfg_file']) as f: - configuration = f.read() - except Exception as e: - self._log.error("Reading contents of the configuration file(%s) failed: %s", vnf_cfg['cfg_file'], str(e)) - return - - try: - self._log.debug("apply_edit_cfg to VNF: %s", log_this_vnf(vnf_cfg)) - xml = '{}'.format(configuration) - response = yield from self._manager.edit_config(xml, target='running') - if hasattr(response, 'xml'): - response_xml = response.xml - else: - response_xml = response.data_xml.decode() - - self._log.debug("apply_edit_cfg response: %s", response_xml) - if '' in response_xml: - raise ConfigManagerROifConnectionError("apply_edit_cfg response has rpc-error : %s", - response_xml) - - self._log.debug("apply_edit_cfg Successfully applied configuration {%s}", xml) - except: - raise - class ConfigManagerVNFjujuconf(object): def __init__(self, log, loop, parent, vnf_cfg): diff --git a/rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/rwconman_test_config_template.cfg b/rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/rwconman_test_config_template.cfg deleted file mode 100644 index d5342c23..00000000 --- a/rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/rwconman_test_config_template.cfg +++ /dev/null @@ -1,32 +0,0 @@ -# This template has all supported TAGs. -# This template can be used as input to the xlate_cfg.py script as follows: - -# python3 ./xlate_cfg.py -i ./rwconman_test_config_template.cfg -o ./rwconman_test_config.cfg -x ./rwconman_test_xlate_dict.yml - - -# This is error -#0. - -# Following are simple TAGs -1. This is Management IP: -2. This is Username: -3. This is Password: -4. This is globally unique connection point: - -# Following are colon separated complex TAGs -5. This is connection point for a given VNF with unique member index: -6. This is converting connection point IP address into network address: -7. This is converting connection point IP address into boadcast address: - -# Following generated tuple with original connectino point name (Global only) -8. This is not used anywhere: - -# Following are multi-colon separated complex TAGs -9. This is converting connection point IP address into network address VNF with unique member index: -10. This is converting connection point IP address into network address VNF with unique member index: - -# Following test all of the above in single line -11. All at once: START| rw_mgmt_ip: | rw_username: | rw_password: | global CP: | 1 CP: | network: | broadcast: | tuple: | 2 network: | 2 broadcast: |END - -# Need to work on the solution for multiple pattern of same type in single line. - diff --git a/rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/rwconman_test_xlate_dict.yml b/rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/rwconman_test_xlate_dict.yml deleted file mode 100644 index becbff14..00000000 --- a/rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/rwconman_test_xlate_dict.yml +++ /dev/null @@ -1,8 +0,0 @@ -1: - test/cp1: 11.0.0.1 -2: - test/cp1: 11.0.0.2 -test/cp1: 11.0.0.3 -rw_mgmt_ip: 1.1.1.1 -rw_username: admin -rw_password: admin diff --git a/rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/xlate_cfg.py b/rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/xlate_cfg.py deleted file mode 100644 index add8a9a4..00000000 --- a/rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/xlate_cfg.py +++ /dev/null @@ -1,245 +0,0 @@ -#!/usr/bin/env python3 - -# -# Copyright 2016 RIFT.IO Inc -# -# 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. -# - - -''' -This script will go through the input conffiguration template and convert all the matching "regular expression" and "strings" -specified in xlate_cp_list & xlate_str_list with matching IP addresses passed in as dictionary to this script. - --i Configuration template --o Output final configuration complete with IP addresses --x Xlate(Translate dictionary in string format --t TAGS to be translated - -''' - -import sys -import getopt -import ast -import re -import yaml -import netaddr - -from inspect import getsourcefile -import os.path - -xlate_dict = None - -def xlate_cp_list(line, cp_list): - for cp_string in cp_list: - match = re.search(cp_string, line) - if match is not None: - # resolve IP address using Connection Point dictionary - resolved_ip = xlate_dict[match.group(1)] - if resolved_ip is None: - print("No matching CP found: ", match.group(1)) - exit(2) - else: - line = line[:match.start()] + resolved_ip + line[match.end():] - return line - -def xlate_multi_colon_list(line, multi_colon_list): - for ucp_string in multi_colon_list: - #print("Searching :", ucp_string) - match = re.search(ucp_string, line) - if match is not None: - #print("match :", match.group()) - # resolve IP address using Connection Point dictionary for specified member (unique) index - ucp_str_list = match.group(1).split(':') - print("matched = {}, split list = {}".format(match.group(1), ucp_str_list)) - if len(ucp_str_list) != 3: - print("Invalid TAG in the configuration: ", match.group(1)) - exit(2) - - # Traslate given CP address & mask into netaddr - if ucp_string.startswith(' - -# Literal string translations -xlate_str_list : - - - - - - - -# This list contains 2 tags separated by colon (:) -xlate_colon_list : - # Fetch CP from the member_index dictionary (I.e. CP of a particular VNF) - - - # Generate network address from CP address and mask (mask is expected to be a hard coded number in config) - - - # Generate broadcast address from CP address and mask (mask is expected to be a hard coded number in config) - - - -# This list contains 3 tags separated by colon (:) -xlate_multi_colon_list : - # Generate network address from CP of a particular VNF (mask is expected to be a hard coded number in config)) - - - # Generate broadcast address from CP of a particular VNF (mask is expected to be a hard coded number in config)) - - - -# This translates connection point name and generates tuple with name:resolved IP -xlate_cp_to_tuple_list : - - - diff --git a/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py b/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py index 2cbe2404..9a7e77a1 100755 --- a/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py +++ b/rwlaunchpad/plugins/rwvnfm/rift/tasklets/rwvnfmtasklet/rwvnfmtasklet.py @@ -1417,9 +1417,6 @@ class VirtualNetworkFunctionRecord(object): if self._vnfr.vnf_configuration is not None: vnfr_msg.vnf_configuration.from_dict(self._vnfr.vnf_configuration.as_dict()) - if (ip_address is not None and - vnfr_msg.vnf_configuration.config_access.mgmt_ip_address is None): - vnfr_msg.vnf_configuration.config_access.mgmt_ip_address = ip_address for group in self._vnfr_msg.placement_groups_info: group_info = VnfrYang.YangData_Vnfr_VnfrCatalog_Vnfr_PlacementGroupsInfo()