21
Quantum's Manager class is responsible for parsing a config file
22
and instantiating the correct plugin that concretely implement
23
quantum_plugin_base class
21
Quantum's Manager class is responsible for parsing a config file and
22
instantiating the correct plugin that concretely implement quantum_plugin_base
25
24
The caller should make sure that QuantumManager is a singleton.
28
28
gettext.install('quantum', unicode=1)
30
32
from common import utils
31
33
from quantum_plugin_base import QuantumPluginBase
33
CONFIG_FILE = "quantum/plugins.ini"
35
CONFIG_FILE = "plugins.ini"
38
def find_config(basepath):
39
for root, dirs, files in os.walk(basepath):
40
if CONFIG_FILE in files:
41
return os.path.join(root, CONFIG_FILE)
36
45
class QuantumManager(object):
38
def __init__(self, config=CONFIG_FILE):
39
self.configuration_file = CONFIG_FILE
40
plugin_location = utils.getPluginFromConfig(CONFIG_FILE)
41
print "PLUGIN LOCATION:%s" % plugin_location
47
def __init__(self, config=None):
49
self.configuration_file = find_config(
50
os.path.abspath(os.path.dirname(__file__)))
52
self.configuration_file = config
53
plugin_location = utils.getPluginFromConfig(self.configuration_file)
42
54
plugin_klass = utils.import_class(plugin_location)
43
55
if not issubclass(plugin_klass, QuantumPluginBase):
44
56
raise Exception("Configured Quantum plug-in " \
51
63
def get_manager(self):
55
# TODO(somik): rmove the main class
56
# Added for temporary testing purposes
58
manager = QuantumManager()
59
myManager = manager.get_manager()
60
myManager.get_all_networks("tesst")
63
# Standard boilerplate to call the main() function.
64
if __name__ == '__main__':