Bug 323 : Config agent account not deleted properly
[osm/SO.git] / rwcm / plugins / rwconman / rift / tasklets / rwconmantasklet / rwconman_conagent.py
index 543e51b..b1e1667 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):
@@ -188,7 +192,7 @@ class RiftCMConfigAgent(object):
     def _on_config_agent_delete(self, config_agent):
         self._log.debug("Got nsm plugin config agent delete, account: %s, type: %s",
                 config_agent.name, config_agent.account_type)
-        cap_name = config_agent.account_type
+        cap_name = config_agent.name
         if cap_name in self._plugin_instances:
             self._log.debug("Config agent nsm plugin exists, deleting it.")
             del self._plugin_instances[cap_name]