Exemplo n.º 1
0
    def transform(cls, clients, resource_config):
        """Transform the resource config to EC2 id.

        If OpenStack resource id is given, this function gets resource name
        from the id and then gets EC2 resource id from the name.

        :param clients: openstack admin client handles
        :param resource_config: scenario config with `id`, `name` or `regex`

        :returns: EC2 id matching resource
        """
        if "name" not in resource_config and "regex" not in resource_config:
            # NOTE(wtakase): gets resource name from OpenStack id
            glanceclient = clients.glance()
            resource_name = types._name_from_id(
                resource_config=resource_config,
                resources=list(glanceclient.images.list()),
                typename="image")
            resource_config["name"] = resource_name

        # NOTE(wtakase): gets EC2 resource id from name or regex
        ec2client = clients.ec2()
        resource_ec2_id = types._id_from_name(resource_config=resource_config,
                                              resources=list(
                                                  ec2client.get_all_images()),
                                              typename="ec2_image")
        return resource_ec2_id
Exemplo n.º 2
0
    def transform(cls, clients, resource_config):
        """Transform the resource config to EC2 id.

        If OpenStack resource id is given, this function gets resource name
        from the id and then gets EC2 resource id from the name.

        :param clients: openstack admin client handles
        :param resource_config: scenario config with `id`, `name` or `regex`

        :returns: EC2 id matching resource
        """
        if "name" not in resource_config and "regex" not in resource_config:
            # NOTE(wtakase): gets resource name from OpenStack id
            glanceclient = clients.glance()
            resource_name = types._name_from_id(
                resource_config=resource_config,
                resources=list(glanceclient.images.list()),
                typename="image")
            resource_config["name"] = resource_name

        # NOTE(wtakase): gets EC2 resource id from name or regex
        ec2client = clients.ec2()
        resource_ec2_id = types._id_from_name(
            resource_config=resource_config,
            resources=list(ec2client.get_all_images()),
            typename="ec2_image")
        return resource_ec2_id
Exemplo n.º 3
0
 def pre_process(self, resource_spec, config):
     resource_id = resource_spec.get("id")
     if not resource_id:
         cinder = block.BlockStorage(self._clients)
         resource_id = types._id_from_name(resource_config=resource_spec,
                                           resources=cinder.list_types(),
                                           typename="volume_type")
     return resource_id
Exemplo n.º 4
0
 def pre_process(self, resource_spec, config):
     resource_id = resource_spec.get("id")
     if not resource_id:
         novaclient = self._clients.nova()
         resource_id = types._id_from_name(
             resource_config=resource_spec,
             resources=novaclient.flavors.list(),
             typename="flavor")
     return resource_id
Exemplo n.º 5
0
 def pre_process(self, resource_spec, config):
     resource_id = resource_spec.get("id")
     if not resource_id:
         novaclient = self._clients.nova()
         resource_id = types._id_from_name(
             resource_config=resource_spec,
             resources=novaclient.flavors.list(),
             typename="flavor")
     return resource_id
Exemplo n.º 6
0
 def pre_process(self, resource_spec, config):
     resource_id = resource_spec.get("id")
     if not resource_id:
         cinder = block.BlockStorage(self._clients)
         resource_id = types._id_from_name(
             resource_config=resource_spec,
             resources=cinder.list_types(),
             typename="volume_type")
     return resource_id
Exemplo n.º 7
0
 def pre_process(self, resource_spec, config):
     resource_id = resource_spec.get("id")
     if not resource_id:
         watcherclient = self._clients.watcher()
         resource_id = types._id_from_name(
             resource_config=resource_spec,
             resources=[watcherclient.goal.get(resource_spec.get("name"))],
             typename="goal",
             id_attr="uuid")
     return resource_id
Exemplo n.º 8
0
 def pre_process(self, resource_spec, config):
     resource_id = resource_spec.get("id")
     if not resource_id:
         watcherclient = self._clients.watcher()
         resource_id = types._id_from_name(
             resource_config=resource_spec,
             resources=[watcherclient.goal.get(resource_spec.get("name"))],
             typename="goal",
             id_attr="uuid")
     return resource_id
Exemplo n.º 9
0
    def pre_process(self, resource_spec, config):
        resource_id = resource_spec.get("id")
        list_kwargs = resource_spec.get("list_kwargs", {})

        if not resource_id:
            cache_id = hash(frozenset(list_kwargs.items()))
            if cache_id not in self._cache:
                glance = image.Image(self._clients)
                self._cache[cache_id] = glance.list_images(**list_kwargs)
            images = self._cache[cache_id]
            resource_id = types._id_from_name(resource_config=resource_spec,
                                              resources=images,
                                              typename="image")
        return resource_id
Exemplo n.º 10
0
    def pre_process(self, resource_spec, config):
        resource_id = resource_spec.get("id")
        list_kwargs = resource_spec.get("list_kwargs", {})

        if not resource_id:
            cache_id = hash(frozenset(list_kwargs.items()))
            if cache_id not in self._cache:
                glance = image.Image(self._clients)
                self._cache[cache_id] = glance.list_images(**list_kwargs)
            images = self._cache[cache_id]
            resource_id = types._id_from_name(
                resource_config=resource_spec,
                resources=images,
                typename="image")
        return resource_id
Exemplo n.º 11
0
    def transform(cls, clients, resource_config):
        """Transform the resource config to id.

        :param clients: openstack admin client handles
        :param resource_config: scenario config with `id`, `name` or `regex`

        :returns: id matching resource
        """
        resource_id = resource_config.get("id")
        if not resource_id:
            glanceclient = clients.glance()
            resource_id = types._id_from_name(resource_config=resource_config,
                                              resources=list(
                                                  glanceclient.images.list()),
                                              typename="image")
        return resource_id
Exemplo n.º 12
0
    def transform(cls, clients, resource_config):
        """Transform the resource config to id.

        :param clients: openstack admin client handles
        :param resource_config: scenario config with `id`, `name` or `regex`

        :returns: id matching resource
        """
        resource_id = resource_config.get("id")
        if not resource_id:
            glanceclient = clients.glance()
            resource_id = types._id_from_name(
                resource_config=resource_config,
                resources=list(glanceclient.images.list()),
                typename="image")
        return resource_id
Exemplo n.º 13
0
    def transform(cls, clients, resource_config):
        """Transform the resource config to id.

        :param clients: openstack admin client handles
        :param resource_config: scenario config with `id`, `name` or `regex`

        :returns: id matching resource
        """
        resource_id = resource_config.get("id")
        list_kwargs = resource_config.get("list_kwargs", {})
        if not resource_id:
            images = list(image.Image(clients).list_images(**list_kwargs))
            resource_id = types._id_from_name(resource_config=resource_config,
                                              resources=images,
                                              typename="image")
        return resource_id
Exemplo n.º 14
0
    def pre_process(self, resource_spec, config):
        if "name" not in resource_spec and "regex" not in resource_spec:
            # NOTE(wtakase): gets resource name from OpenStack id
            glanceclient = self._clients.glance()
            resource_name = types._name_from_id(
                resource_config=resource_spec,
                resources=list(glanceclient.images.list()),
                typename="image")
            resource_spec["name"] = resource_name

        # NOTE(wtakase): gets EC2 resource id from name or regex
        ec2client = self._clients.ec2()
        resource_ec2_id = types._id_from_name(resource_config=resource_spec,
                                              resources=list(
                                                  ec2client.get_all_images()),
                                              typename="ec2_image")
        return resource_ec2_id
Exemplo n.º 15
0
    def pre_process(self, resource_spec, config):
        if "name" not in resource_spec and "regex" not in resource_spec:
            # NOTE(wtakase): gets resource name from OpenStack id
            glanceclient = self._clients.glance()
            resource_name = types._name_from_id(
                resource_config=resource_spec,
                resources=list(glanceclient.images.list()),
                typename="image")
            resource_spec["name"] = resource_name

        # NOTE(wtakase): gets EC2 resource id from name or regex
        ec2client = self._clients.ec2()
        resource_ec2_id = types._id_from_name(
            resource_config=resource_spec,
            resources=list(ec2client.get_all_images()),
            typename="ec2_image")
        return resource_ec2_id
Exemplo n.º 16
0
Arquivo: types.py Projeto: zioc/rally
    def transform(cls, clients, resource_config):
        """Transform the resource config to id.

        :param clients: openstack admin client handles
        :param resource_config: scenario config with `id`, `name` or `regex`

        :returns: id matching resource
        """
        resource_id = resource_config.get("id")
        if not resource_id:
            watcherclient = clients.watcher()
            resource_id = types._id_from_name(
                resource_config=resource_config,
                resources=[watcherclient.goal.get(
                    resource_config.get("name"))],
                typename="goal",
                id_attr="uuid")
        return resource_id