コード例 #1
0
ファイル: config.py プロジェクト: gluke77/rally
    def _discover_or_create_image(self):
        glance_wrapper = glance.wrap(self.clients.glance, self)

        if CONF.tempest.img_name_regex:
            LOG.debug("Trying to discover a public image with name matching "
                      "regular expression '%s'. Note that case insensitive "
                      "matching is performed" % CONF.tempest.img_name_regex)
            images = glance_wrapper.list_images(status="active",
                                                visibility="public")
            for img in images:
                if img.name and re.match(CONF.tempest.img_name_regex,
                                         img.name, re.IGNORECASE):
                    LOG.debug(
                        "The following public image discovered: '{0}'. "
                        "Using image '{0}' for the tests".format(img.name))
                    return img

            LOG.debug("There is no public image with name matching "
                      "regular expression '%s'" % CONF.tempest.img_name_regex)

        params = {
            "name": self.generate_random_name(),
            "disk_format": CONF.tempest.img_disk_format,
            "container_format": CONF.tempest.img_container_format,
            "image_location": os.path.join(_create_or_get_data_dir(),
                                           self.image_name),
            "visibility": "public"
        }
        LOG.debug("Creating image '%s'" % params["name"])
        image = glance_wrapper.create_image(**params)
        self._created_images.append(image)

        return image
コード例 #2
0
ファイル: config.py プロジェクト: hkumarmk/rally
    def _discover_or_create_image(self):
        glance_wrap = glance_wrapper.wrap(self.clients.glance, self)

        if CONF.image.name_regex:
            LOG.debug("Trying to discover an image with name matching "
                      "regular expression '%s'. Note that case insensitive "
                      "matching is performed" % CONF.image.name_regex)
            img_list = [img for img in self.clients.glance().images.list()
                        if img.status.lower() == "active" and img.name]
            for img in img_list:
                if re.match(CONF.image.name_regex, img.name, re.IGNORECASE):
                    LOG.debug("The following image discovered: '{0}'. Using "
                              "image '{0}' for the tests".format(img.name))
                    return img

            LOG.debug("There is no image with name matching "
                      "regular expression '%s'" % CONF.image.name_regex)

        params = {
            "name": self.generate_random_name(),
            "disk_format": CONF.image.disk_format,
            "container_format": CONF.image.container_format,
            "image_location": os.path.join(_create_or_get_data_dir(),
                                           self.image_name),
            "is_public": True
        }
        LOG.debug("Creating image '%s'" % params["name"])
        image = glance_wrap.create_image(**params)
        self._created_images.append(image)

        return image
コード例 #3
0
ファイル: images.py プロジェクト: mbliznikova/rally
 def cleanup(self):
     for user, tenant_id in rutils.iterate_per_tenants(
             self.context["users"]):
         clients = osclients.Clients(
             user["credential"],
             api_info=self.context["config"].get("api_versions"))
         glance_wrap = glance_wrapper.wrap(clients.glance, self)
         for image in self.context["tenants"][tenant_id].get("images", []):
             glance_wrap.delete_image(glance_wrap.get_image(image))
コード例 #4
0
ファイル: images.py プロジェクト: stevelle/rally
 def cleanup(self):
     for user, tenant_id in rutils.iterate_per_tenants(
             self.context["users"]):
         clients = osclients.Clients(
             user["credential"],
             api_info=self.context["config"].get("api_versions"))
         glance_wrap = glance_wrapper.wrap(clients.glance, self)
         for image in self.context["tenants"][tenant_id].get("images", []):
             glance_wrap.delete_image(glance_wrap.get_image(image))
コード例 #5
0
ファイル: utils.py プロジェクト: hmdesai89/rally
    def _delete_image(self, image):
        """Deletes given image.

        Returns when the image is actually deleted.

        :param image: Image object
        """
        client = glance_wrapper.wrap(self._clients.glance, self)
        client.delete_image(image)
コード例 #6
0
ファイル: utils.py プロジェクト: gwdg/rally
    def _delete_image(self, image):
        """Deletes given image.

        Returns when the image is actually deleted.

        :param image: Image object
        """
        client = glance_wrapper.wrap(self._clients.glance, self)
        client.delete_image(image)
コード例 #7
0
ファイル: config.py プロジェクト: gluke77/rally
 def _cleanup_images(self):
     glance_wrapper = glance.wrap(self.clients.glance, self)
     for image in self._created_images:
         LOG.debug("Deleting image '%s'" % image.name)
         self.clients.glance().images.delete(image.id)
         task_utils.wait_for_status(
             image, ["deleted", "pending_delete"],
             check_deletion=True,
             update_resource=glance_wrapper.get_image,
             timeout=CONF.benchmark.glance_image_delete_timeout,
             check_interval=CONF.benchmark.
             glance_image_delete_poll_interval)
         self._remove_opt_value_from_config("compute", image.id)
コード例 #8
0
ファイル: config.py プロジェクト: aswadr/rally
 def _cleanup_images(self):
     glance_wrapper = glance.wrap(self.clients.glance, self)
     for image in self._created_images:
         LOG.debug("Deleting image '%s'" % image.name)
         self.clients.glance().images.delete(image.id)
         task_utils.wait_for_status(
             image, ["deleted", "pending_delete"],
             check_deletion=True,
             update_resource=glance_wrapper.get_image,
             timeout=CONF.benchmark.glance_image_delete_timeout,
             check_interval=CONF.benchmark.glance_image_delete_poll_interval
         )
         self._remove_opt_value_from_config("compute", image.id)
コード例 #9
0
ファイル: utils.py プロジェクト: andreykurilin/rally
    def _delete_image(self, image):
        """Deletes given image.

        Returns when the image is actually deleted.

        :param image: Image object
        """
        self.clients("glance").images.delete(image.id)
        wrapper = glance_wrapper.wrap(self._clients.glance, self)
        utils.wait_for_status(
            image, ["deleted", "pending_delete"],
            check_deletion=True,
            update_resource=wrapper.get_image,
            timeout=CONF.openstack.glance_image_delete_timeout,
            check_interval=CONF.openstack.glance_image_delete_poll_interval)
コード例 #10
0
ファイル: utils.py プロジェクト: amit0701/rally
 def cinder_create_image(self, container_format,
                             image_location, disk_format, **create_image_kwargs):
     """Creating an image using glance image create.
     :param container_format: container format of image. Acceptable
                              formats: ami, ari, aki, bare, and ovf
     :param image_location: image file location
     :param disk_format: disk format of image. Acceptable formats:
                         ami, ari, aki, vhd, vmdk, raw, qcow2, vdi, and iso
     :param kwargs: optional parameters to create image
     """ 
     client = glance_wrapper.wrap(self._clients.glance, self)
     return client.create_image(container_format,
                                image_location,
                                disk_format,
                                **create_image_kwargs)         
コード例 #11
0
    def _delete_image(self, image):
        """Deletes given image.

        Returns when the image is actually deleted.

        :param image: Image object
        """
        self.clients("glance").images.delete(image.id)
        wrapper = glance_wrapper.wrap(self._clients.glance, self)
        utils.wait_for_status(
            image, ["deleted", "pending_delete"],
            check_deletion=True,
            update_resource=wrapper.get_image,
            timeout=CONF.openstack.glance_image_delete_timeout,
            check_interval=CONF.openstack.glance_image_delete_poll_interval)
コード例 #12
0
ファイル: utils.py プロジェクト: hmdesai89/rally
    def _create_image(self, container_format, image_location, disk_format,
                      **kwargs):
        """Create a new image.

        :param container_format: container format of image. Acceptable
                                 formats: ami, ari, aki, bare, and ovf
        :param image_location: image file location
        :param disk_format: disk format of image. Acceptable formats:
                            ami, ari, aki, vhd, vmdk, raw, qcow2, vdi, and iso
        :param kwargs: optional parameters to create image

        :returns: image object
        """
        client = glance_wrapper.wrap(self._clients.glance, self)
        return client.create_image(container_format, image_location,
                                   disk_format, **kwargs)
コード例 #13
0
ファイル: images.py プロジェクト: hameedullah/rally
 def cleanup(self):
     for user, tenant_id in rutils.iterate_per_tenants(
             self.context["users"]):
         clients = osclients.Clients(
             user["credential"],
             api_info=self.context["config"].get("api_versions"))
         glance_wrap = glance_wrapper.wrap(clients.glance, self)
         for image in self.context["tenants"][tenant_id].get("images", []):
             clients.glance().images.delete(image)
             utils.wait_for_status(
                 clients.glance().images.get(image), ["deleted"],
                 check_deletion=True,
                 update_resource=glance_wrap.get_image,
                 timeout=CONF.benchmark.glance_image_delete_timeout,
                 check_interval=CONF.benchmark.
                 glance_image_delete_poll_interval)
コード例 #14
0
ファイル: config.py プロジェクト: zioc/rally
    def _discover_image(self):
        LOG.debug("Trying to discover a public image with name matching "
                  "regular expression '%s'. Note that case insensitive "
                  "matching is performed." % CONF.tempest.img_name_regex)
        glance_wrapper = glance.wrap(self.clients.glance, self)
        images = glance_wrapper.list_images(status="active",
                                            visibility="public")
        for image in images:
            if image.name and re.match(CONF.tempest.img_name_regex, image.name,
                                       re.IGNORECASE):
                LOG.debug("The following public "
                          "image discovered: '%s'" % image.name)
                return image

        LOG.debug("There is no public image with name matching "
                  "regular expression '%s'" % CONF.tempest.img_name_regex)
コード例 #15
0
ファイル: config.py プロジェクト: sebrandon1/rally
    def _discover_image(self):
        LOG.debug("Trying to discover a public image with name matching "
                  "regular expression '%s'. Note that case insensitive "
                  "matching is performed." % CONF.tempest.img_name_regex)
        glance_wrapper = glance.wrap(self.clients.glance, self)
        images = glance_wrapper.list_images(status="active",
                                            visibility="public")
        for image in images:
            if image.name and re.match(CONF.tempest.img_name_regex,
                                       image.name, re.IGNORECASE):
                LOG.debug("The following public "
                          "image discovered: '%s'" % image.name)
                return image

        LOG.debug("There is no public image with name matching "
                  "regular expression '%s'" % CONF.tempest.img_name_regex)
コード例 #16
0
ファイル: images.py プロジェクト: NaliniKrishna/Rally
 def cleanup(self):
     for user, tenant_id in rutils.iterate_per_tenants(
             self.context["users"]):
         clients = osclients.Clients(
             user["credential"],
             api_info=self.context["config"].get("api_versions"))
         glance_wrap = glance_wrapper.wrap(clients.glance, self)
         for image in self.context["tenants"][tenant_id].get("images", []):
             clients.glance().images.delete(image)
             utils.wait_for_status(
                 clients.glance().images.get(image),
                 ["deleted", "pending_delete"],
                 check_deletion=True,
                 update_resource=glance_wrap.get_image,
                 timeout=CONF.benchmark.glance_image_delete_timeout,
                 check_interval=CONF.benchmark.
                 glance_image_delete_poll_interval)
コード例 #17
0
ファイル: custom_image.py プロジェクト: alinbalutoiu/rally
    def create_one_image(self, user, **kwargs):
        """Create one image for the user."""

        clients = osclients.Clients(user["credential"])
        admin_clients = osclients.Clients(self.context["admin"]["credential"])

        image_id = types.GlanceImage.transform(
            clients=clients, resource_config=self.config["image"])
        flavor_id = types.Flavor.transform(
            clients=clients, resource_config=self.config["flavor"])

        vm_scenario = vmtasks.BootRuncommandDeleteCustomImage(
            self.context,
            clients=clients)

        glance_wrap = glance_wrapper.wrap(admin_clients.glance, self)

        server, fip = vm_scenario._boot_server_with_fip(
            image=image_id, flavor=flavor_id,
            floating_network=self.config.get("floating_network"),
            userdata=self.config.get("userdata"),
            key_name=user["keypair"]["name"],
            security_groups=[user["secgroup"]["name"]],
            **kwargs)

        try:
            LOG.debug("Installing benchmark on %r %s", server, fip["ip"])
            self.customize_image(server, fip, user)

            LOG.debug("Stopping server %r", server)
            vm_scenario._stop_server(server)

            LOG.debug("Creating snapshot for %r", server)
            custom_image = vm_scenario._create_image(server)
            glance_wrap.set_visibility(custom_image)
        finally:
            vm_scenario._delete_server_with_fip(server, fip)

        if hasattr(custom_image, "to_dict"):
            # NOTE(stpierre): Glance v1 images are objects that can be
            # converted to dicts; Glance v2 images are already
            # dict-like
            custom_image = custom_image.to_dict()

        return custom_image
コード例 #18
0
    def setup(self):
        image_url = self.config["image_url"]
        image_type = self.config["image_type"]
        image_container = self.config["image_container"]
        images_per_tenant = self.config["images_per_tenant"]
        image_name = self.config.get("image_name")

        for user, tenant_id in rutils.iterate_per_tenants(
                self.context["users"]):
            current_images = []
            clients = osclients.Clients(
                user["credential"],
                api_info=self.context["config"].get("api_versions"))
            glance_wrap = glance_wrapper.wrap(clients.glance, self)

            kwargs = self.config.get("image_args", {})
            if self.config.get("min_ram") is not None:
                LOG.warning("The 'min_ram' argument is deprecated; specify "
                            "arbitrary arguments with 'image_args' instead")
                kwargs["min_ram"] = self.config["min_ram"]
            if self.config.get("min_disk") is not None:
                LOG.warning("The 'min_disk' argument is deprecated; specify "
                            "arbitrary arguments with 'image_args' instead")
                kwargs["min_disk"] = self.config["min_disk"]
            if "is_public" in kwargs:
                LOG.warning("The 'is_public' argument is deprecated since "
                            "Rally 0.8.0; specify visibility arguments "
                            "instead")

            for i in range(images_per_tenant):
                if image_name and i > 0:
                    cur_name = image_name + str(i)
                elif image_name:
                    cur_name = image_name
                else:
                    cur_name = self.generate_random_name()

                image = glance_wrap.create_image(image_container,
                                                 image_url,
                                                 image_type,
                                                 name=cur_name,
                                                 **kwargs)
                current_images.append(image.id)

            self.context["tenants"][tenant_id]["images"] = current_images
コード例 #19
0
    def create_one_image(self, user, **kwargs):
        """Create one image for the user."""

        clients = osclients.Clients(user["credential"])
        admin_clients = osclients.Clients(self.context["admin"]["credential"])

        image_id = types.GlanceImage.transform(
            clients=clients, resource_config=self.config["image"])
        flavor_id = types.Flavor.transform(
            clients=clients, resource_config=self.config["flavor"])

        vm_scenario = vmtasks.BootRuncommandDeleteCustomImage(self.context,
                                                              clients=clients)

        glance_wrap = glance_wrapper.wrap(admin_clients.glance, self)

        server, fip = vm_scenario._boot_server_with_fip(
            image=image_id,
            flavor=flavor_id,
            floating_network=self.config.get("floating_network"),
            userdata=self.config.get("userdata"),
            key_name=user["keypair"]["name"],
            security_groups=[user["secgroup"]["name"]],
            **kwargs)

        try:
            LOG.debug("Installing benchmark on %r %s", server, fip["ip"])
            self.customize_image(server, fip, user)

            LOG.debug("Stopping server %r", server)
            vm_scenario._stop_server(server)

            LOG.debug("Creating snapshot for %r", server)
            custom_image = vm_scenario._create_image(server)
            glance_wrap.set_visibility(custom_image)
        finally:
            vm_scenario._delete_server_with_fip(server, fip)

        if hasattr(custom_image, "to_dict"):
            # NOTE(stpierre): Glance v1 images are objects that can be
            # converted to dicts; Glance v2 images are already
            # dict-like
            custom_image = custom_image.to_dict()

        return custom_image
コード例 #20
0
ファイル: utils.py プロジェクト: andreykurilin/rally
    def _create_image(self, container_format, image_location, disk_format,
                      **kwargs):
        """Create a new image.

        :param container_format: container format of image. Acceptable
                                 formats: ami, ari, aki, bare, and ovf
        :param image_location: image file location
        :param disk_format: disk format of image. Acceptable formats:
                            ami, ari, aki, vhd, vmdk, raw, qcow2, vdi, and iso
        :param kwargs: optional parameters to create image

        :returns: image object
        """
        if not kwargs.get("name"):
            kwargs["name"] = self.generate_random_name()
        client = glance_wrapper.wrap(self._clients.glance, self)
        return client.create_image(container_format, image_location,
                                   disk_format, **kwargs)
コード例 #21
0
ファイル: utils.py プロジェクト: hameedullah/rally
    def _delete_image(self, image):
        """Delete the given image.

        Returns when the image is actually deleted.

        :param image: Image object
        """
        self.clients("glance").images.delete(image.id)
        wrapper = glance_wrapper.wrap(self._clients.glance, self)
        check_interval = CONF.benchmark.nova_server_image_delete_poll_interval
        utils.wait_for_status(
            image,
            ready_statuses=["deleted"],
            check_deletion=True,
            update_resource=wrapper.get_image,
            timeout=CONF.benchmark.nova_server_image_delete_timeout,
            check_interval=check_interval
        )
コード例 #22
0
ファイル: utils.py プロジェクト: jethrosun/rally
    def _create_image(self, container_format, image_location, disk_format,
                      **kwargs):
        """Create a new image.

        :param container_format: container format of image. Acceptable
                                 formats: ami, ari, aki, bare, and ovf
        :param image_location: image file location
        :param disk_format: disk format of image. Acceptable formats:
                            ami, ari, aki, vhd, vmdk, raw, qcow2, vdi, and iso
        :param kwargs: optional parameters to create image

        :returns: image object
        """
        LOG.warning("TRACE: _create_image")
        self._init_profiler(self.context)

        if not kwargs.get("name"):
            kwargs["name"] = self.generate_random_name()
        client = glance_wrapper.wrap(self._clients.glance, self)
        return client.create_image(container_format, image_location,
                                   disk_format, **kwargs)
コード例 #23
0
ファイル: utils.py プロジェクト: zhangdelong/rally
    def _upload_volume_to_image(self,
                                volume,
                                force=False,
                                container_format="bare",
                                disk_format="raw"):
        """Upload the given volume to image.

        Returns created image.

        :param volume: volume object
        :param force: flag to indicate whether to snapshot a volume even if
                      it's attached to an instance
        :param container_format: container format of image. Acceptable
                                 formats: ami, ari, aki, bare, and ovf
        :param disk_format: disk format of image. Acceptable formats:
                            ami, ari, aki, vhd, vmdk, raw, qcow2, vdi and iso
        :returns: Returns created image object
        """
        resp, img = volume.upload_to_image(force, self.generate_random_name(),
                                           container_format, disk_format)
        # NOTE (e0ne): upload_to_image changes volume status to uploading so
        # we need to wait until it will be available.
        volume = bench_utils.wait_for(
            volume,
            ready_statuses=["available"],
            update_resource=bench_utils.get_from_manager(),
            timeout=CONF.benchmark.cinder_volume_create_timeout,
            check_interval=CONF.benchmark.cinder_volume_create_poll_interval)
        image_id = img["os-volume_upload_image"]["image_id"]
        image = self.clients("glance").images.get(image_id)
        wrapper = glance_wrapper.wrap(self._clients.glance, self)
        image = bench_utils.wait_for(
            image,
            ready_statuses=["active"],
            update_resource=wrapper.get_image,
            timeout=CONF.benchmark.glance_image_create_timeout,
            check_interval=CONF.benchmark.glance_image_create_poll_interval)

        return image
コード例 #24
0
ファイル: images.py プロジェクト: hameedullah/rally
    def setup(self):
        image_url = self.config["image_url"]
        image_type = self.config["image_type"]
        image_container = self.config["image_container"]
        images_per_tenant = self.config["images_per_tenant"]
        image_name = self.config.get("image_name")

        for user, tenant_id in rutils.iterate_per_tenants(
                self.context["users"]):
            current_images = []
            clients = osclients.Clients(
                user["credential"],
                api_info=self.context["config"].get("api_versions"))
            glance_wrap = glance_wrapper.wrap(clients.glance, self)

            kwargs = self.config.get("image_args", {})
            if self.config.get("min_ram") is not None:
                LOG.warning("The 'min_ram' argument is deprecated; specify "
                            "arbitrary arguments with 'image_args' instead")
                kwargs["min_ram"] = self.config["min_ram"]
            if self.config.get("min_disk") is not None:
                LOG.warning("The 'min_disk' argument is deprecated; specify "
                            "arbitrary arguments with 'image_args' instead")
                kwargs["min_disk"] = self.config["min_disk"]

            for i in range(images_per_tenant):
                if image_name and i > 0:
                    cur_name = image_name + str(i)
                elif image_name:
                    cur_name = image_name
                else:
                    cur_name = self.generate_random_name()

                image = glance_wrap.create_image(
                    image_container, image_url, image_type,
                    name=cur_name, **kwargs)
                current_images.append(image.id)

            self.context["tenants"][tenant_id]["images"] = current_images
コード例 #25
0
ファイル: utils.py プロジェクト: andreykurilin/rally
    def _upload_volume_to_image(self, volume, force=False,
                                container_format="bare", disk_format="raw"):
        """Upload the given volume to image.

        Returns created image.

        :param volume: volume object
        :param force: flag to indicate whether to snapshot a volume even if
                      it's attached to an instance
        :param container_format: container format of image. Acceptable
                                 formats: ami, ari, aki, bare, and ovf
        :param disk_format: disk format of image. Acceptable formats:
                            ami, ari, aki, vhd, vmdk, raw, qcow2, vdi and iso
        :returns: Returns created image object
        """
        resp, img = volume.upload_to_image(force, self.generate_random_name(),
                                           container_format, disk_format)
        # NOTE (e0ne): upload_to_image changes volume status to uploading so
        # we need to wait until it will be available.
        volume = bench_utils.wait_for_status(
            volume,
            ready_statuses=["available"],
            update_resource=bench_utils.get_from_manager(),
            timeout=CONF.openstack.cinder_volume_create_timeout,
            check_interval=CONF.openstack.cinder_volume_create_poll_interval
        )
        image_id = img["os-volume_upload_image"]["image_id"]
        image = self.clients("glance").images.get(image_id)
        wrapper = glance_wrapper.wrap(self._clients.glance, self)
        image = bench_utils.wait_for_status(
            image,
            ready_statuses=["active"],
            update_resource=wrapper.get_image,
            timeout=CONF.openstack.glance_image_create_timeout,
            check_interval=CONF.openstack.glance_image_create_poll_interval
        )

        return image
コード例 #26
0
ファイル: config.py プロジェクト: sebrandon1/rally
    def _discover_or_create_image(self):
        if CONF.tempest.img_name_regex:
            image = self._discover_image()
            if image:
                LOG.debug("Using image '%s' (ID = %s) "
                          "for the tests" % (image.name, image.id))
                return image

        params = {
            "name": self.generate_random_name(),
            "disk_format": CONF.tempest.img_disk_format,
            "container_format": CONF.tempest.img_container_format,
            "image_location": os.path.join(self.data_dir, self.image_name),
            "visibility": "public"
        }
        LOG.debug("Creating image '%s'" % params["name"])
        glance_wrapper = glance.wrap(self.clients.glance, self)
        image = glance_wrapper.create_image(**params)
        LOG.debug("Image '%s' (ID = %s) has been "
                  "successfully created!" % (image.name, image.id))
        self._created_images.append(image)

        return image
コード例 #27
0
ファイル: config.py プロジェクト: zioc/rally
    def _discover_or_create_image(self):
        if CONF.tempest.img_name_regex:
            image = self._discover_image()
            if image:
                LOG.debug("Using image '%s' (ID = %s) "
                          "for the tests" % (image.name, image.id))
                return image

        params = {
            "name": self.generate_random_name(),
            "disk_format": CONF.tempest.img_disk_format,
            "container_format": CONF.tempest.img_container_format,
            "image_location": os.path.join(self.data_dir, self.image_name),
            "visibility": "public"
        }
        LOG.debug("Creating image '%s'" % params["name"])
        glance_wrapper = glance.wrap(self.clients.glance, self)
        image = glance_wrapper.create_image(**params)
        LOG.debug("Image '%s' (ID = %s) has been "
                  "successfully created!" % (image.name, image.id))
        self._created_images.append(image)

        return image
コード例 #28
0
ファイル: config.py プロジェクト: aswadr/rally
    def _discover_or_create_image(self):
        glance_wrapper = glance.wrap(self.clients.glance, self)

        if CONF.tempest.img_name_regex:
            LOG.debug("Trying to discover a public image with name matching "
                      "regular expression '%s'. Note that case insensitive "
                      "matching is performed" % CONF.tempest.img_name_regex)
            images = glance_wrapper.list_images(status="active",
                                                visibility="public")
            for img in images:
                if img.name and re.match(CONF.tempest.img_name_regex, img.name,
                                         re.IGNORECASE):
                    LOG.debug("The following public image discovered: '{0}'. "
                              "Using image '{0}' for the tests".format(
                                  img.name))
                    return img

            LOG.debug("There is no public image with name matching "
                      "regular expression '%s'" % CONF.tempest.img_name_regex)

        params = {
            "name":
            self.generate_random_name(),
            "disk_format":
            CONF.tempest.img_disk_format,
            "container_format":
            CONF.tempest.img_container_format,
            "image_location":
            os.path.join(_create_or_get_data_dir(), self.image_name),
            "visibility":
            "public"
        }
        LOG.debug("Creating image '%s'" % params["name"])
        image = glance_wrapper.create_image(**params)
        self._created_images.append(image)

        return image
コード例 #29
0
    def _discover_or_create_image(self):
        glance_wrap = glance_wrapper.wrap(self.clients.glance, self)

        if CONF.image.name_regex:
            LOG.debug("Trying to discover an image with name matching "
                      "regular expression '%s'. Note that case insensitive "
                      "matching is performed" % CONF.image.name_regex)
            img_list = [
                img for img in self.clients.glance().images.list()
                if img.status.lower() == "active" and img.name
            ]
            for img in img_list:
                if re.match(CONF.image.name_regex, img.name, re.IGNORECASE):
                    LOG.debug("The following image discovered: '{0}'. Using "
                              "image '{0}' for the tests".format(img.name))
                    return img

            LOG.debug("There is no image with name matching "
                      "regular expression '%s'" % CONF.image.name_regex)

        params = {
            "name":
            self.generate_random_name(),
            "disk_format":
            CONF.image.disk_format,
            "container_format":
            CONF.image.container_format,
            "image_location":
            os.path.join(_create_or_get_data_dir(), self.image_name),
            "is_public":
            True
        }
        LOG.debug("Creating image '%s'" % params["name"])
        image = glance_wrap.create_image(**params)
        self._created_images.append(image)

        return image
コード例 #30
0
ファイル: utils.py プロジェクト: asimonet/rally
    def _create_images(self, container_format, image_location, disk_format,
                      n=1, **kwargs):
        """Create new images

        :param container_format: container format of image. Acceptable
                                 formats: ami, ari, aki, bare, and ovf
        :param image_location: image file location
        :param disk_format: disk format of image. Acceptable formats:
                            ami, ari, aki, vhd, vmdk, raw, qcow2, vdi, and iso
        :param n: number of images to create
        :param kwargs: optional parameters to create image

        :returns: image object
        """
        
        images = []
        for _ in xrange(n):
            kwargs["name"] = self.generate_random_name()
            client = glance_wrapper.wrap(self._clients.glance, self)
            images.append(client.create_image(container_format,
                                    image_location,
                                    disk_format, **kwargs))
        
        return images
コード例 #31
0
 def setUp(self):
     super(GlanceV1WrapperTestCase, self).setUp()
     self.client = mock.MagicMock()
     self.client.choose_version.return_value = "1"
     self.owner = mock.Mock()
     self.wrapped_client = glance_wrapper.wrap(self.client, self.owner)
コード例 #32
0
 def test_wrap(self, version, expected_class):
     client = mock.MagicMock()
     client.choose_version.return_value = version
     self.assertIsInstance(glance_wrapper.wrap(client, mock.Mock()),
                           expected_class)
コード例 #33
0
 def _wrapper(self):
     return glance_wrapper.wrap(self._client(), self)
コード例 #34
0
ファイル: resources.py プロジェクト: alinbalutoiu/rally
 def _wrapper(self):
     return glance_wrapper.wrap(self._client(), self)
コード例 #35
0
ファイル: resources.py プロジェクト: stevelle/rally
 def _manager(self):
     return glance_wrapper.wrap(
         getattr(self.admin or self.user, self._service), self)