Beispiel #1
0
    def _get_core(self):

        try:
            core_name = self.CFG.provisioner['core']
        except KeyError:
            return ProvisionerCore

        core = get_class(core_name)
        return core
Beispiel #2
0
    def load(self, classname):
        """Return instance of specified decision engine"""
        log.debug("Loading Decision Engine '%s'" % classname)
        kls = get_class(classname)
        if not kls:
            raise Exception("Cannot find decision engine implementation: '%s'" % classname)
        # Could use zope.interface in the future and check implementedBy here,
        # but it is not actually that helpful.

        engine = kls()
        log.info("Loaded Decision Engine '%s'" % str(engine))
        return engine
Beispiel #3
0
    def load(self, classname):
        """Return instance of specified decision engine"""
        log.debug("attempting to load Decision Engine '%s'" % classname)
        kls = get_class(classname)
        if not kls:
            raise Exception(
                "Cannot find decision engine implementation: '%s'" % classname)
        # Could use zope.interface in the future and check implementedBy here,
        # but it is not actually that helpful.

        engine = kls()
        log.info("Loaded Decision Engine: %s" % str(engine))
        return engine
Beispiel #4
0
    def _validate_engine_config(self, config):
        engine_class = DEFAULT_ENGINE_CLASS
        if EPUM_CONF_GENERAL in config:
            general_config = config[EPUM_CONF_GENERAL]
            if EPUM_CONF_ENGINE_CLASS in general_config:
                engine_class = general_config[EPUM_CONF_ENGINE_CLASS]

        log.debug("attempting to load Decision Engine '%s'" % engine_class)
        kls = get_class(engine_class)
        if not kls:
            raise Exception("Cannot find decision engine implementation: '%s'" % engine_class)

        if hasattr(kls, 'validate_config') and callable(getattr(kls, 'validate_config')):
            kls.validate_config(config.get(EPUM_CONF_ENGINE, {}))
Beispiel #5
0
def get_site_drivers(site_config):
    """Loads a dict of IaaS drivers from a config block
    """
    if site_config is None or not isinstance(site_config, dict):
        raise ValueError("expecting dict of IaaS driver configs")
    drivers = {}
    for site, spec in site_config.iteritems():
        try:
            cls_name = spec["driver_class"]
            cls_kwargs = spec["driver_kwargs"]
            log.debug("Loading IaaS driver %s", cls_name)
            cls = get_class(cls_name)
            driver = cls(**cls_kwargs)
            drivers[site] = driver
        except KeyError,e:
            raise KeyError("IaaS site description '%s' missing key '%s'" % (site, str(e)))
Beispiel #6
0
def get_site_drivers(site_config):
    """Loads a dict of IaaS drivers from a config block
    """
    if site_config is None or not isinstance(site_config, dict):
        raise ValueError("expecting dict of IaaS driver configs")
    drivers = {}
    for site, spec in site_config.iteritems():
        try:
            cls_name = spec["driver_class"]
            cls_kwargs = spec["driver_kwargs"]
            log.debug("Loading IaaS driver %s", cls_name)
            cls = get_class(cls_name)
            driver = cls(**cls_kwargs)
            drivers[site] = driver
        except KeyError, e:
            raise KeyError("IaaS site description '%s' missing key '%s'" %
                           (site, str(e)))
Beispiel #7
0
    def _get_engine_doc(self, config):
        engine_class = DEFAULT_ENGINE_CLASS
        if EPUM_CONF_GENERAL in config:
            general_config = config[EPUM_CONF_GENERAL]
            if EPUM_CONF_ENGINE_CLASS in general_config:
                engine_class = general_config[EPUM_CONF_ENGINE_CLASS]

        log.debug("attempting to load Decision Engine '%s'" % engine_class)
        kls = get_class(engine_class)
        if not kls:
            raise Exception("Cannot find decision engine implementation: '%s'" % engine_class)

        if hasattr(kls, 'get_config_doc') and callable(getattr(kls, 'get_config_doc')):
            doc = kls.get_config_doc()
        else:
            doc = kls.__doc__

        return doc
Beispiel #8
0
                cls_name = "libcloud.compute.drivers.ec2.EucNodeDriver"
                path = site_description.get("path")
                if path is not None:
                    cls_kwargs["path"] = path
        elif cloud_type == "fake":
            cls_name = "epu.provisioner.test.util.FakeNodeDriver"
        elif cloud_type == "mock-ec2":
            cls_name = "epu.mocklibcloud.MockEC2NodeDriver"
            try:
                cls_kwargs["sqlite_db"] = site_description["sqlite_db"]
            except KeyError, e:
                raise KeyError("IaaS site description '%s' missing key '%s'" % (site_description, str(e)))


        try:
            key = credentials_description["access_key"]
            secret = credentials_description["secret_key"]
        except KeyError, e:
            raise KeyError("IaaS credentials description '%s' missing key '%s'" % (site_description, str(e)))

        cls_kwargs["key"] = key
        cls_kwargs["secret"] = secret

        cls = get_class(cls_name)
        self.driver = partial(cls, **cls_kwargs)()
        try:
            self.driver.connection.timeout = timeout
        except AttributeError:
            # Some mock drivers won't have this attribute
            pass