def test_get_class(self):
        test = utils.get_class(
            "tukey_middleware.auth.keystone_proxy.KeystoneProxy")
        auth = test.handle_parameters({
                    "memcache_client":  {
                        "class": "tukey_middleware.tests.services.mc_mock.ClientPreload",
                        "params": [["localhost:11211"], 1]
                    },
                    "eucarc_path":  "tukey_middleware/tests/data/%s"
                })
        inst = auth("test_cloud", "test_token")

        test2 = utils.get_class("tukey_middleware.cloud_driver.euca.EucaDriver")
        test2(inst)
Exemple #2
0
    def test_get_class(self):
        test = utils.get_class(
            "tukey_middleware.auth.keystone_proxy.KeystoneProxy")
        auth = test.handle_parameters({
            "memcache_client": {
                "class":
                "tukey_middleware.tests.services.mc_mock.ClientPreload",
                "params": [["localhost:11211"], 1]
            },
            "eucarc_path":
            "tukey_middleware/tests/data/%s"
        })
        inst = auth("test_cloud", "test_token")

        test2 = utils.get_class(
            "tukey_middleware.cloud_driver.euca.EucaDriver")
        test2(inst)
    def handle_parameters(params):

        try:
            ec2path = params["eucarc_path"]
        except KeyError:
            ec2path = None

        mc_class = utils.get_class(params["memcache_client"]["class"])
        mc_params = params["memcache_client"]["params"]
        mc = mc_class(mc_params[0], mc_params[1])

        logger = utils.get_logger()
        logger.debug(mc)
        logger.debug("doing lambda now ")

        return lambda cloud, token: KeystoneProxy(
            cloud, token, mc, eucarc_path=ec2path)
Exemple #4
0
    def _initialize_cloud(self, cloud, name, auth_token):
        ''' Cloud entering is a dictionary and returned is the initialized
        cloud driver '''

        if "auth_driver" in cloud:
            auth_path = cloud["auth_driver"]
        else:
            auth_path = self.DEFAULT_AUTH

        self.logger.debug("getting auth class from %s", auth_path)

        if "auth_driver_parameters" in cloud:
            params = cloud["auth_driver_parameters"]
        else:
            params = self.DEFAULT_AUTH_PARAMS

        if auth_path is not None:
            auth_class = utils.get_class(auth_path).handle_parameters(params)
            auth_instance = auth_class(name, auth_token)
        else:
            auth_instance = None

        if "driver" in cloud:
            driver_path = cloud["driver"]
        elif "access" in cloud:
            has_volume = False
            has_object = False

            for service in cloud["access"]["serviceCatalog"]:
                if service["type"] == "volume":
                    has_volume = True
                if service["type"] == "object-store":
                    has_object = True

            if has_object and has_volume:
                #TODO: replace with volume + object class
                driver_path = ("tukey_middleware.cloud_driver"
                    ".openstack_volumes.OpenStackVolumeDriver")

            elif has_object:
                #TODO: replace with object class
                driver_path = ("tukey_middleware.cloud_driver"
                    ".openstack.OpenStackDriver")

            elif has_volume:
                driver_path = ("tukey_middleware.cloud_driver"
                    ".openstack_volumes.OpenStackVolumeDriver")

            else:
                driver_path = ("tukey_middleware.cloud_driver"
                    ".openstack.OpenStackDriver")
        else:
            driver_path = ("tukey_middleware.cloud_driver"
                ".osdc_euca.OsdcEucaDriver")

        self.logger.debug("getting cloud driver class from %s",
                driver_path)

        driver_class = utils.get_class(driver_path)
        if driver_class == ("tukey_middleware.cloud_driver.openstack."
                "OpenStackDriver"):
            driver_instance = driver_class(auth_instance,
                    client_format=self.client_format)
        else:
            driver_instance = driver_class(auth_instance)


        self.logger.debug("cloud: %s auth SUCCESS %s", cloud,
                auth_token)

        #TODO: for faster selection of ec2/eucalyptus cloud have a special id
        # that we can look at to instantly dismiss or accept requests
        #driver_instance.cloud_id = cloud["id"]

        driver_instance.cloud = cloud.get("cloud", name)
        driver_instance.cloud_id = name

        return driver_instance