Exemplo n.º 1
0
    def __init__(self, libvirt_uri=None, objstore_loc=None):

        self.objstore = ObjectStore(objstore_loc)
        self.conn = LibvirtConnection(libvirt_uri)
        kargs = {'objstore': self.objstore, 'conn': self.conn}

        if self.conn.isQemuURI():
            for pool_name, pool_arg in DEFAULT_POOLS.iteritems():
                self._default_pool_check(pool_name, pool_arg)

        this = os.path.basename(__file__)
        this_mod = os.path.splitext(this)[0]

        models = []
        for mod_name in listPathModules(os.path.dirname(__file__)):
            if mod_name.startswith("_") or mod_name == this_mod:
                continue

            module = import_module('model.' + mod_name)
            members = inspect.getmembers(module, inspect.isclass)
            for cls_name, instance in members:
                if inspect.getmodule(instance) == module:
                    if cls_name.endswith('Model'):
                        models.append(instance(**kargs))

        return super(Model, self).__init__(models)
Exemplo n.º 2
0
    def __init__(self, libvirt_uri='qemu:///system', objstore_loc=None):
        self.objstore = ObjectStore(objstore_loc)
        self.conn = LibvirtConnection(libvirt_uri)
        kargs = {'objstore': self.objstore, 'conn': self.conn}

        if 'qemu:///' in libvirt_uri:
            self._default_pool_check()
            self._default_network_check()

        this = os.path.basename(__file__)
        this_mod = os.path.splitext(this)[0]

        models = []
        for mod_name in listPathModules(os.path.dirname(__file__)):
            if mod_name.startswith("_") or mod_name == this_mod:
                continue

            module = import_module('model.' + mod_name)
            members = inspect.getmembers(module, inspect.isclass)
            for cls_name, instance in members:
                if inspect.getmodule(instance) == module:
                    if cls_name.endswith('Model'):
                        models.append(instance(**kargs))

        return super(Model, self).__init__(models)
Exemplo n.º 3
0
    def __init__(self, libvirt_uri="qemu:///system", objstore_loc=None):
        self.objstore = ObjectStore(objstore_loc)
        self.conn = LibvirtConnection(libvirt_uri)
        kargs = {"objstore": self.objstore, "conn": self.conn}

        if "qemu:///" in libvirt_uri:
            for pool_name, pool_arg in DEFAULT_POOLS.iteritems():
                self._default_pool_check(pool_name, pool_arg)

        this = os.path.basename(__file__)
        this_mod = os.path.splitext(this)[0]

        models = []
        for mod_name in listPathModules(os.path.dirname(__file__)):
            if mod_name.startswith("_") or mod_name == this_mod:
                continue

            module = import_module("model." + mod_name)
            members = inspect.getmembers(module, inspect.isclass)
            for cls_name, instance in members:
                if inspect.getmodule(instance) == module:
                    if cls_name.endswith("Model"):
                        models.append(instance(**kargs))

        return super(Model, self).__init__(models)
Exemplo n.º 4
0
def load_url_sub_node(path, package_name, expect_attr="_url_sub_node_name"):
    sub_nodes = {}
    for mod_name in listPathModules(path):
        if mod_name.startswith("_"):
            continue

        module = import_module(package_name + '.' + mod_name)

        for node in [getattr(module, x) for x in dir(module)]:
            if not hasattr(node, expect_attr):
                continue
            name = getattr(node, expect_attr)["name"]
            sub_nodes.update({name: node})

    return sub_nodes
Exemplo n.º 5
0
def load_url_sub_node(path, package_name, expect_attr="_url_sub_node_name"):
    sub_nodes = {}
    for mod_name in listPathModules(path):
        if mod_name.startswith("_"):
            continue

        module = import_module(package_name + '.' + mod_name)

        for node in [getattr(module, x) for x in dir(module)]:
            if not hasattr(node, expect_attr):
                continue
            name = getattr(node, expect_attr)["name"]
            sub_nodes.update({name: node})

    return sub_nodes