当前位置: 首页>>代码示例>>Python>>正文


Python glance.wrap函数代码示例

本文整理汇总了Python中rally.plugins.openstack.wrappers.glance.wrap函数的典型用法代码示例。如果您正苦于以下问题:Python wrap函数的具体用法?Python wrap怎么用?Python wrap使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wrap函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _discover_or_create_image

    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
开发者ID:hkumarmk,项目名称:rally,代码行数:31,代码来源:config.py

示例2: _discover_or_create_image

    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
开发者ID:gluke77,项目名称:rally,代码行数:33,代码来源:config.py

示例3: cleanup

 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))
开发者ID:mbliznikova,项目名称:rally,代码行数:9,代码来源:images.py

示例4: _delete_image

    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)
开发者ID:gwdg,项目名称:rally,代码行数:9,代码来源:utils.py

示例5: _cleanup_images

 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)
开发者ID:gluke77,项目名称:rally,代码行数:13,代码来源:config.py

示例6: cinder_create_image

 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)         
开发者ID:amit0701,项目名称:rally,代码行数:15,代码来源:utils.py

示例7: _delete_image

    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)
开发者ID:andreykurilin,项目名称:rally,代码行数:15,代码来源:utils.py

示例8: _discover_image

    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)
开发者ID:sebrandon1,项目名称:rally,代码行数:16,代码来源:config.py

示例9: cleanup

 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)
开发者ID:hameedullah,项目名称:rally,代码行数:16,代码来源:images.py

示例10: create_one_image

    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
开发者ID:alinbalutoiu,项目名称:rally,代码行数:45,代码来源:custom_image.py

示例11: _create_image

    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)
开发者ID:andreykurilin,项目名称:rally,代码行数:18,代码来源:utils.py

示例12: _delete_image

    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
        )
开发者ID:hameedullah,项目名称:rally,代码行数:18,代码来源:utils.py

示例13: setup

    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
开发者ID:hameedullah,项目名称:rally,代码行数:39,代码来源:images.py

示例14: _upload_volume_to_image

    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
开发者ID:andreykurilin,项目名称:rally,代码行数:38,代码来源:utils.py

示例15: _discover_or_create_image

    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
开发者ID:sebrandon1,项目名称:rally,代码行数:23,代码来源:config.py


注:本文中的rally.plugins.openstack.wrappers.glance.wrap函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。