Add VCA details to input file for NS initial-config-primitive 63/1163/1
authorPhilip Joseph <philip.joseph@riftio.com>
Tue, 24 Jan 2017 12:55:51 +0000 (12:55 +0000)
committerPhilip Joseph <philip.joseph@riftio.com>
Thu, 23 Feb 2017 13:43:34 +0000 (19:13 +0530)
Signed-off-by: Philip Joseph <philip.joseph@riftio.com>
rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/riftcm_config_plugin.py
rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/rwconman_conagent.py
rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/rwconman_config.py

index e289cf4..593cdfe 100644 (file)
@@ -237,6 +237,11 @@ class RiftCMConfigPluginBase(object):
     def vnfr(self, vnfr_id):
         raise NotImplementedError
 
+    @abc.abstractmethod
+    def get_Service_name(self):
+        """ Get the service name specific to the plugin """
+        pass
+
     @abc.abstractmethod
     @asyncio.coroutine
     def apply_config(self, agent_nsr, agent_vnfr, config, rpc_ip):
index 7fa5042..6847e24 100644 (file)
@@ -141,19 +141,23 @@ class RiftCMConfigAgent(object):
                        .format(vnfr.name, method, rc))
         return rc
 
-    def is_vnfr_config_agent_managed(self, vnfr):
-        if (not vnfr.has_field('netconf') and
-            not vnfr.has_field('juju') and
-            not vnfr.has_field('script')):
-            return False
+    def get_vnfr_config_agent(self, vnfr):
+        if (not vnfr.has_field('netconf') and
+            not vnfr.has_field('juju') and
+            not vnfr.has_field('script')):
+            return False
 
         for agent in self._plugin_instances.values():
             try:
                 if agent.is_vnfr_managed(vnfr.id):
-                    return True
+                    return agent
             except Exception as e:
                 self._log.debug("Check if VNFR {} is config agent managed: {}".
                                 format(vnfr.name, e))
+
+    def is_vnfr_config_agent_managed(self, vnfr):
+        if self.get_vnfr_config_agent(vnfr):
+            return True
         return False
 
     def _on_config_agent(self, config_agent):
index 1960bde..237b8c4 100644 (file)
@@ -1026,10 +1026,6 @@ class ConfigManagerConfig(object):
             if vnfr_name:
                 inp['vnfr_name'] = vnfr_name
 
-            # TODO (pjoseph): Add config agents, we need to identify which all
-            # config agents are required from this NS and provide only those
-            inp['config-agent'] = {}
-
             # Add parameters for initial config
             inp['parameter'] = {}
             for parameter in parameters:
@@ -1044,6 +1040,20 @@ class ConfigManagerConfig(object):
                                        format(nsr_obj.nsr_name, parameter, e))
 
 
+            # Add config agents specific to each VNFR
+            inp['config-agent'] = {}
+            for vnfr in nsr_obj.agent_nsr.vnfrs:
+                # Get the config agent for the VNFR
+                # If vnfr name is specified, add only CA specific to that
+                if (vnfr_name is None) or \
+                   (vnfr_name == vnfr.name):
+                    agent = self._config_agent_mgr.get_vnfr_config_agent(vnfr.vnfr_msg)
+                    if agent:
+                        if agent.agent_type != riftcm_config_plugin.DEFAULT_CAP_TYPE:
+                            inp['config-agent'][vnfr.member_vnf_index] = agent.agent_data
+                            inp['config-agent'][vnfr.member_vnf_index] \
+                                ['service-name'] = agent.get_service_name(vnfr.id)
+
             # Add vnfrs specific data
             inp['vnfr'] = {}
             for vnfr in nsr_obj.vnfrs:
@@ -1078,6 +1088,7 @@ class ConfigManagerConfig(object):
 
                 inp['vnfr'][vnfr['member_vnf_index_ref']] = v
 
+
             self._log.debug("Input data for {}: {}".
                             format((vnfr_name if vnfr_name else nsr_obj.nsr_name),
                                    inp))