summaryrefslogtreecommitdiffstats
path: root/vstf/vstf/agent/env/vswitch_plugins/manager.py
diff options
context:
space:
mode:
Diffstat (limited to 'vstf/vstf/agent/env/vswitch_plugins/manager.py')
-rwxr-xr-xvstf/vstf/agent/env/vswitch_plugins/manager.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/vstf/vstf/agent/env/vswitch_plugins/manager.py b/vstf/vstf/agent/env/vswitch_plugins/manager.py
new file mode 100755
index 00000000..00115dfd
--- /dev/null
+++ b/vstf/vstf/agent/env/vswitch_plugins/manager.py
@@ -0,0 +1,31 @@
+"""
+Created on 2015-9-15
+
+@author: y00228926
+"""
+import stevedore
+
+
+class VswitchPluginManager(object):
+ def __init__(self):
+ self.plugin = None
+ self.mgr = stevedore.extension.ExtensionManager(namespace="vswitch.plugins", invoke_on_load=True)
+
+ def clean(self):
+ if self.plugin:
+ self.plugin.clean()
+ self.plugin = None
+ for plugin in self.mgr.names():
+ self.mgr[plugin].obj.clean()
+ return True
+
+ def get_vs_plugin(self, plugin):
+ if plugin in self.mgr.names():
+ ext = self.mgr[plugin]
+ self.plugin = ext.obj
+ return self.plugin
+ else:
+ raise Exception("unsupported vswitch plugin: %s" % plugin)
+
+ def get_supported_plugins(self):
+ return self.mgr.names()