本文整理汇总了Python中rally.task.utils.get_from_manager函数的典型用法代码示例。如果您正苦于以下问题:Python get_from_manager函数的具体用法?Python get_from_manager怎么用?Python get_from_manager使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_from_manager函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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)
示例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
示例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
示例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)
示例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
示例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)
示例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
示例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
示例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
示例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)
示例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
示例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
示例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
示例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