• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.get_from_manager函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: _associate_floating_ip

    def _associate_floating_ip(self, server, address, fixed_address=None,
                               atomic_action=True):
        """Add floating IP to an instance

        :param server: The :class:`Server` to add an IP to.
        :param address: The ip address or FloatingIP to add to the instance
        :param fixed_address: The fixedIP address the FloatingIP is to be
               associated with (optional)
        :param atomic_action: True if this is an atomic action (optional)
        """
        if atomic_action:
            with atomic.ActionTimer(self, "nova.associate_floating_ip"):
                server.add_floating_ip(address, fixed_address=fixed_address)
                utils.wait_for(
                    server,
                    is_ready=self.check_ip_address(address),
                    update_resource=utils.get_from_manager()
                )
        else:
            server.add_floating_ip(address, fixed_address=fixed_address)
            utils.wait_for(
                server,
                is_ready=self.check_ip_address(address),
                update_resource=utils.get_from_manager()
            )
        # Update server data
        server.addresses = server.manager.get(server.id).addresses
开发者ID:aforalee,项目名称:RRally,代码行数:27,代码来源:utils.py


示例2: _scale_stack

    def _scale_stack(self, stack, output_key, delta):
        """Scale a stack up or down.

        Calls the webhook given in the output value identified by
        'output_key', and waits for the stack size to change by
        'delta'.

        :param stack: stack to scale up or down
        :param output_key: The name of the output to get the URL from
        :param delta: The expected change in number of instances in
                      the stack (signed int)
        """
        num_instances = self._count_instances(stack)
        expected_instances = num_instances + delta
        LOG.debug("Scaling stack %s from %s to %s instances with %s" %
                  (stack.id, num_instances, expected_instances, output_key))
        with atomic.ActionTimer(self, "heat.scale_with_%s" % output_key):
            self._stack_webhook(stack, output_key)
            utils.wait_for(
                stack,
                is_ready=lambda s: (
                    self._count_instances(s) == expected_instances),
                update_resource=utils.get_from_manager(
                    ["UPDATE_FAILED"]),
                timeout=CONF.benchmark.heat_stack_scale_timeout,
                check_interval=CONF.benchmark.heat_stack_scale_poll_interval)
开发者ID:rvbaz,项目名称:rally,代码行数:26,代码来源:utils.py


示例3: _update_stack

    def _update_stack(self, stack, template, parameters=None,
                      files=None, environment=None):
        """Update an existing stack

        :param stack: stack that need to be updated
        :param template: Updated template
        :param parameters: template parameters for stack update
        :param files: additional files used in template
        :param environment: stack environment definition

        :returns: object of updated stack
        """

        kw = {
            "stack_name": stack.stack_name,
            "disable_rollback": True,
            "parameters": parameters or {},
            "template": template,
            "files": files or {},
            "environment": environment or {}
        }
        self.clients("heat").stacks.update(stack.id, **kw)

        time.sleep(CONF.benchmark.heat_stack_update_prepoll_delay)
        stack = utils.wait_for(
            stack,
            ready_statuses=["UPDATE_COMPLETE"],
            update_resource=utils.get_from_manager(["UPDATE_FAILED"]),
            timeout=CONF.benchmark.heat_stack_update_timeout,
            check_interval=CONF.benchmark.heat_stack_update_poll_interval)
        return stack
开发者ID:rvbaz,项目名称:rally,代码行数:31,代码来源:utils.py


示例4: _create_bay

    def _create_bay(self, baymodel, node_count, **kwargs):
        """Create a bay

        :param baymodel: baymodel for the bay
        :param node_count: the bay node count
        :param kwargs: optional additional arguments for bay creation
        :returns: magnum bay
        """

        name = self.generate_random_name()
        bay = self.clients("magnum").bays.create(
            name=name, baymodel_id=baymodel,
            node_count=node_count, **kwargs)

        common_utils.interruptable_sleep(
            CONF.benchmark.magnum_bay_create_prepoll_delay)
        bay = utils.wait_for_status(
            bay,
            ready_statuses=["CREATE_COMPLETE"],
            update_resource=utils.get_from_manager(),
            timeout=CONF.benchmark.magnum_bay_create_timeout,
            check_interval=CONF.benchmark.magnum_bay_create_poll_interval,
            id_attr="uuid"
        )
        return bay
开发者ID:obutenko,项目名称:rally,代码行数:25,代码来源:utils.py


示例5: _migrate

    def _migrate(self, server, skip_host_check=False):
        """Run migration of the given server.

        :param server: Server object
        :param skip_host_check: Specifies whether to verify the targeted host
                                availability
        """
        server_admin = self.admin_clients("nova").servers.get(server.id)
        host_pre_migrate = getattr(server_admin, "OS-EXT-SRV-ATTR:host")
        server_admin.migrate()
        utils.wait_for(
            server,
            ready_statuses=["VERIFY_RESIZE"],
            update_resource=utils.get_from_manager(),
            timeout=CONF.benchmark.nova_server_migrate_timeout,
            check_interval=(
                CONF.benchmark.nova_server_migrate_poll_interval)
        )
        if not skip_host_check:
            server_admin = self.admin_clients("nova").servers.get(server.id)
            host_after_migrate = getattr(server_admin, "OS-EXT-SRV-ATTR:host")
            if host_pre_migrate == host_after_migrate:
                raise exceptions.MigrateException(
                    "Migration complete but instance did not change host: %s" %
                    host_pre_migrate)
开发者ID:asimonet,项目名称:rally,代码行数:25,代码来源:utils.py


示例6: _create_node

    def _create_node(self, driver, properties, **kwargs):
        """Create node immediately.

        :param driver: The name of the driver used to manage this Node.
        :param properties: Key/value pair describing the physical
            characteristics of the node.
        :param kwargs: optional parameters to create image
        :returns: node object
        """
        kwargs["name"] = self.generate_random_name()
        node = self.admin_clients("ironic").node.create(driver=driver,
                                                        properties=properties,
                                                        **kwargs)

        self.sleep_between(CONF.openstack.ironic_node_create_poll_interval)
        node = utils.wait_for_status(
            node,
            ready_statuses=["AVAILABLE"],
            update_resource=utils.get_from_manager(),
            timeout=CONF.openstack.ironic_node_create_timeout,
            check_interval=CONF.openstack.ironic_node_poll_interval,
            id_attr="uuid", status_attr="provision_state"
        )

        return node
开发者ID:andreykurilin,项目名称:rally,代码行数:25,代码来源:utils.py


示例7: test_get_from_manager_in_deleted_state

 def test_get_from_manager_in_deleted_state(self):
     get_from_manager = utils.get_from_manager()
     manager = fakes.FakeManager()
     resource = fakes.FakeResource(manager=manager, status="DELETED")
     manager._cache(resource)
     self.assertRaises(exceptions.GetResourceNotFound,
                       get_from_manager, resource)
开发者ID:alinbalutoiu,项目名称:rally,代码行数:7,代码来源:test_utils.py


示例8: _create_share

    def _create_share(self, share_proto, size=1, **kwargs):
        """Create a share.

        :param share_proto: share protocol for new share,
            available values are NFS, CIFS, GlusterFS and HDFS.
        :param size: size of a share in GB
        :param snapshot_id: ID of the snapshot
        :param name: name of new share
        :param description: description of a share
        :param metadata: optional metadata to set on share creation
        :param share_network: either instance of ShareNetwork or str with ID
        :param share_type: either instance of ShareType or str with ID
        :param is_public: defines whether to set share as public or not.
        :returns: instance of :class:`Share`
        """
        if not kwargs.get("name"):
            kwargs["name"] = self._generate_random_name()

        share = self.clients("manila").shares.create(
            share_proto, size, **kwargs)
        time.sleep(CONF.benchmark.manila_share_create_prepoll_delay)
        share = utils.wait_for(
            share,
            is_ready=utils.resource_is("available"),
            update_resource=utils.get_from_manager(),
            timeout=CONF.benchmark.manila_share_create_timeout,
            check_interval=CONF.benchmark.manila_share_create_poll_interval,
        )
        return share
开发者ID:sckevmit,项目名称:rally,代码行数:29,代码来源:utils.py


示例9: _create_cluster

    def _create_cluster(self, cluster_template, node_count, **kwargs):
        """Create a cluster

        :param cluster_template: cluster_template for the cluster
        :param node_count: the cluster node count
        :param kwargs: optional additional arguments for cluster creation
        :returns: magnum cluster
        """

        name = self.generate_random_name()
        cluster = self.clients("magnum").clusters.create(
            name=name, cluster_template_id=cluster_template,
            node_count=node_count, **kwargs)

        common_utils.interruptable_sleep(
            CONF.openstack.magnum_cluster_create_prepoll_delay)
        cluster = utils.wait_for_status(
            cluster,
            ready_statuses=["CREATE_COMPLETE"],
            update_resource=utils.get_from_manager(),
            timeout=CONF.openstack.magnum_cluster_create_timeout,
            check_interval=CONF.openstack.magnum_cluster_create_poll_interval,
            id_attr="uuid"
        )
        return cluster
开发者ID:jacobwagner,项目名称:rally,代码行数:25,代码来源:utils.py


示例10: _create_volume

    def _create_volume(self, size, **kwargs):
        """Create one volume.

        Returns when the volume is actually created and is in the "Available"
        state.

        :param size: int be size of volume in GB, or
                     dictionary, must contain two values:
                         min - minimum size volumes will be created as;
                         max - maximum size volumes will be created as.
        :param kwargs: Other optional parameters to initialize the volume
        :returns: Created volume object
        """
        kwargs["display_name"] = kwargs.get("display_name",
                                            self._generate_random_name())

        if isinstance(size, dict):
            size = random.randint(size["min"], size["max"])

        volume = self.clients("cinder").volumes.create(size, **kwargs)
        # NOTE(msdubov): It is reasonable to wait 5 secs before starting to
        #                check whether the volume is ready => less API calls.
        time.sleep(CONF.benchmark.cinder_volume_create_prepoll_delay)
        volume = bench_utils.wait_for(
            volume,
            is_ready=bench_utils.resource_is("available"),
            update_resource=bench_utils.get_from_manager(),
            timeout=CONF.benchmark.cinder_volume_create_timeout,
            check_interval=CONF.benchmark.cinder_volume_create_poll_interval
        )
        return volume
开发者ID:fdumpling,项目名称:rally,代码行数:31,代码来源:utils.py


示例11: _live_migrate

    def _live_migrate(self, server, target_host, block_migration=False,
                      disk_over_commit=False, skip_host_check=False):
        """Run live migration of the given server.

        :param server: Server object
        :param target_host: Specifies the target compute node to migrate
        :param block_migration: Specifies the migration type
        :param disk_over_commit: Specifies whether to overcommit migrated
                                 instance or not
        :param skip_host_check: Specifies whether to verify the targeted host
                                availability
        """
        server_admin = self.admin_clients("nova").servers.get(server.id)
        host_pre_migrate = getattr(server_admin, "OS-EXT-SRV-ATTR:host")
        server_admin.live_migrate(target_host,
                                  block_migration=block_migration,
                                  disk_over_commit=disk_over_commit)
        utils.wait_for(
            server,
            ready_statuses=["ACTIVE"],
            update_resource=utils.get_from_manager(),
            timeout=CONF.benchmark.nova_server_live_migrate_timeout,
            check_interval=(
                CONF.benchmark.nova_server_live_migrate_poll_interval)
        )
        server_admin = self.admin_clients("nova").servers.get(server.id)
        if (host_pre_migrate == getattr(server_admin, "OS-EXT-SRV-ATTR:host")
                and not skip_host_check):
            raise exceptions.LiveMigrateException(
                "Migration complete but instance did not change host: %s" %
                host_pre_migrate)
开发者ID:asimonet,项目名称:rally,代码行数:31,代码来源:utils.py


示例12: _create_snapshot

    def _create_snapshot(self, volume_id, force=False, **kwargs):
        """Create one snapshot.

        Returns when the snapshot is actually created and is in the "Available"
        state.

        :param volume_id: volume uuid for creating snapshot
        :param force: flag to indicate whether to snapshot a volume even if
                      it's attached to an instance
        :param kwargs: Other optional parameters to initialize the volume
        :returns: Created snapshot object
        """
        kwargs["display_name"] = kwargs.get("display_name",
                                            self._generate_random_name())
        kwargs["force"] = force
        snapshot = self.clients("cinder").volume_snapshots.create(volume_id,
                                                                  **kwargs)
        time.sleep(CONF.benchmark.cinder_volume_create_prepoll_delay)
        snapshot = bench_utils.wait_for(
            snapshot,
            is_ready=bench_utils.resource_is("available"),
            update_resource=bench_utils.get_from_manager(),
            timeout=CONF.benchmark.cinder_volume_create_timeout,
            check_interval=CONF.benchmark.cinder_volume_create_poll_interval
        )
        return snapshot
开发者ID:fdumpling,项目名称:rally,代码行数:26,代码来源:utils.py


示例13: _create_volume

    def _create_volume(self, size, **kwargs):
        """Create one volume.

        Returns when the volume is actually created and is in the "Available"
        state.

        :param size: int be size of volume in GB, or
                     dictionary, must contain two values:
                         min - minimum size volumes will be created as;
                         max - maximum size volumes will be created as.
        :param kwargs: Other optional parameters to initialize the volume
        :returns: Created volume object
        """
        if isinstance(size, dict):
            size = random.randint(size["min"], size["max"])

        client = cinder_wrapper.wrap(self._clients.cinder, self)
        volume = client.create_volume(size, **kwargs)

        # NOTE(msdubov): It is reasonable to wait 5 secs before starting to
        #                check whether the volume is ready => less API calls.
        self.sleep_between(CONF.openstack.cinder_volume_create_prepoll_delay)

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


示例14: _create_snapshot

    def _create_snapshot(self, volume_id, force=False, **kwargs):
        """Create one snapshot.

        Returns when the snapshot is actually created and is in the "Available"
        state.

        :param volume_id: volume uuid for creating snapshot
        :param force: flag to indicate whether to snapshot a volume even if
                      it's attached to an instance
        :param kwargs: Other optional parameters to initialize the volume
        :returns: Created snapshot object
        """
        kwargs["force"] = force

        client = cinder_wrapper.wrap(self._clients.cinder, self)
        snapshot = client.create_snapshot(volume_id, **kwargs)

        self.sleep_between(CONF.openstack.cinder_volume_create_prepoll_delay)
        snapshot = bench_utils.wait_for_status(
            snapshot,
            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
        )
        return snapshot
开发者ID:andreykurilin,项目名称:rally,代码行数:26,代码来源:utils.py


示例15: create_image

    def create_image(self, container_format, image_location,
                     disk_format, **kwargs):
        kw = {
            "container_format": container_format,
            "disk_format": disk_format,
        }
        kw.update(kwargs)
        if "name" not in kw:
            kw["name"] = self.owner.generate_random_name()
        image_location = os.path.expanduser(image_location)

        try:
            if os.path.isfile(image_location):
                kw["data"] = open(image_location)
            else:
                kw["copy_from"] = image_location

            image = self.client.images.create(**kw)

            time.sleep(CONF.benchmark.glance_image_create_prepoll_delay)

            image = utils.wait_for_status(
                image, ["active"],
                update_resource=utils.get_from_manager(),
                timeout=CONF.benchmark.glance_image_create_timeout,
                check_interval=CONF.benchmark.
                glance_image_create_poll_interval)
        finally:
            if "data" in kw:
                kw["data"].close()

        return image
开发者ID:mbliznikova,项目名称:rally,代码行数:32,代码来源:glance.py


示例16: test_get_from_manager_in_error_state

 def test_get_from_manager_in_error_state(self):
     get_from_manager = utils.get_from_manager()
     manager = fakes.FakeManager()
     resource = fakes.FakeResource(manager=manager, status="ERROR")
     manager._cache(resource)
     self.assertRaises(exceptions.GetResourceFailure,
                       get_from_manager, resource)
开发者ID:alinbalutoiu,项目名称:rally,代码行数:7,代码来源:test_utils.py


示例17: delete_image

 def delete_image(self, image):
     image.delete()
     utils.wait_for_status(
         image, ["deleted"],
         check_deletion=True,
         update_resource=utils.get_from_manager(),
         timeout=CONF.benchmark.glance_image_delete_timeout,
         check_interval=CONF.benchmark.glance_image_delete_poll_interval)
开发者ID:mbliznikova,项目名称:rally,代码行数:8,代码来源:glance.py


示例18: _resize

 def _resize(self, server, flavor):
     server.resize(flavor)
     utils.wait_for(
         server,
         ready_statuses=["VERIFY_RESIZE"],
         update_resource=utils.get_from_manager(),
         timeout=CONF.benchmark.nova_server_resize_timeout,
         check_interval=CONF.benchmark.nova_server_resize_poll_interval
     )
开发者ID:asimonet,项目名称:rally,代码行数:9,代码来源:utils.py


示例19: _wait

 def _wait(self, ready_statuses, failure_statuses):
     self.stack = utils.wait_for_status(
         self.stack,
         check_interval=10,
         timeout=1200,
         ready_statuses=ready_statuses,
         failure_statuses=failure_statuses,
         update_resource=utils.get_from_manager(),
     )
开发者ID:amit0701,项目名称:rally,代码行数:9,代码来源:main.py


示例20: _wait

 def _wait(self, ready_statuses, failure_statuses):
     self.stack = utils.wait_for_status(
         self.stack,
         check_interval=CONF.openstack.heat_stack_create_poll_interval,
         timeout=CONF.openstack.heat_stack_create_timeout,
         ready_statuses=ready_statuses,
         failure_statuses=failure_statuses,
         update_resource=utils.get_from_manager(),
     )
开发者ID:jacobwagner,项目名称:rally,代码行数:9,代码来源:main.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.resource_is函数代码示例发布时间:2022-05-26
下一篇:
Python runner._run_scenario_once函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap