本文整理汇总了Python中sahara.utils.openstack.base.execute_with_retries函数的典型用法代码示例。如果您正苦于以下问题:Python execute_with_retries函数的具体用法?Python execute_with_retries怎么用?Python execute_with_retries使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了execute_with_retries函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: instantiate
def instantiate(self, update_existing, disable_rollback=True):
main_tmpl = self._get_main_template()
heat = h.client()
kwargs = {
'stack_name': self.cluster.stack_name,
'timeout_mins': 180,
'disable_rollback': disable_rollback,
'parameters': {},
'template': main_tmpl,
'files': self.files}
if CONF.heat_stack_tags:
kwargs['tags'] = ",".join(CONF.heat_stack_tags)
if not update_existing:
LOG.debug("Creating Heat stack with args: {args}"
.format(args=kwargs))
b.execute_with_retries(heat.stacks.create, **kwargs)
else:
stack = h.get_stack(self.cluster.stack_name)
self.last_updated_time = stack.updated_time
LOG.debug("Updating Heat stack {stack} with args: "
"{args}".format(stack=stack, args=kwargs))
b.execute_with_retries(stack.update, **kwargs)
self.heat_stack = h.get_stack(self.cluster.stack_name)
示例2: _get_neutron_limits
def _get_neutron_limits():
limits = {}
neutron = neutron_client.client()
tenant_id = context.ctx().tenant_id
total_lim = b.execute_with_retries(neutron.show_quota, tenant_id)['quota']
# tmckay-fp here we would just get the limits all the time
usage_fip = b.execute_with_retries(
neutron.list_floatingips, tenant_id=tenant_id)['floatingips']
limits['floatingips'] = _sub_limit(total_lim['floatingip'],
len(usage_fip))
usage_sg = b.execute_with_retries(
neutron.list_security_groups, tenant_id=tenant_id).get(
'security_groups', [])
limits['security_groups'] = _sub_limit(total_lim['security_group'],
len(usage_sg))
usage_sg_rules = b.execute_with_retries(
neutron.list_security_group_rules, tenant_id=tenant_id).get(
'security_group_rules', [])
limits['security_group_rules'] = _sub_limit(
total_lim['security_group_rule'], len(usage_sg_rules))
usage_ports = b.execute_with_retries(
neutron.list_ports, tenant_id=tenant_id)['ports']
limits['ports'] = _sub_limit(total_lim['port'], len(usage_ports))
return limits
示例3: init_instances_ips
def init_instances_ips(instance):
"""Extracts internal and management ips.
As internal ip will be used the first ip from the nova networks CIDRs.
If use_floating_ip flag is set than management ip will be the first
non-internal ip.
"""
server = nova.get_instance_info(instance)
management_ip = None
internal_ip = None
for network_label, addresses in six.iteritems(server.addresses):
for address in addresses:
if address['OS-EXT-IPS:type'] == 'fixed':
internal_ip = internal_ip or address['addr']
else:
management_ip = management_ip or address['addr']
cluster = instance.cluster
if (not CONF.use_floating_ips or
(cluster.has_proxy_gateway() and
not instance.node_group.is_proxy_gateway)):
management_ip = internal_ip
# NOTE(aignatov): Once bug #1262529 is fixed this 'if' block should be
# reviewed and reformatted again, probably removed completely.
if CONF.use_neutron and not (management_ip and internal_ip):
LOG.debug("Instance doesn't yet contain Floating IP or Internal IP. "
"Floating IP={mgmt_ip}, Internal IP={internal_ip}. "
"Trying to get via Neutron.".format(
mgmt_ip=management_ip, internal_ip=internal_ip))
neutron_client = neutron.client()
ports = b.execute_with_retries(
neutron_client.list_ports, device_id=server.id)["ports"]
if ports:
target_port_id = ports[0]['id']
fl_ips = b.execute_with_retries(
neutron_client.list_floatingips,
port_id=target_port_id)['floatingips']
if fl_ips:
fl_ip = fl_ips[0]
if not internal_ip:
internal_ip = fl_ip['fixed_ip_address']
LOG.debug('Found fixed IP {internal_ip}'
.format(internal_ip=internal_ip))
# Zeroing management_ip if Sahara in private network
if not CONF.use_floating_ips:
management_ip = internal_ip
elif not management_ip:
management_ip = fl_ip['floating_ip_address']
LOG.debug('Found floating IP {mgmt_ip}'
.format(mgmt_ip=management_ip))
conductor.instance_update(context.ctx(), instance,
{"management_ip": management_ip,
"internal_ip": internal_ip})
return internal_ip and management_ip
示例4: proxy_user_delete
def proxy_user_delete(username=None, user_id=None):
'''Delete the user from the proxy domain.
:param username: The name of the user to delete.
:param user_id: The id of the user to delete, if provided this overrides
the username.
:raises NotFoundException: If there is an error locating the user in the
proxy domain.
'''
admin = k.client_for_admin()
if not user_id:
domain = domain_for_proxy()
user_list = b.execute_with_retries(
admin.users.list, domain=domain.id, name=username)
if len(user_list) == 0:
raise ex.NotFoundException(
value=username,
message_template=_('Failed to find user %s'))
if len(user_list) > 1:
raise ex.NotFoundException(
value=username,
message_template=_('Unexpected results found when searching '
'for user %s'))
user_id = user_list[0].id
b.execute_with_retries(admin.users.delete, user_id)
LOG.debug('Deleted proxy user id {user_id}'.format(user_id=user_id))
示例5: get_image
def get_image(**kwargs):
if len(kwargs) == 1 and 'id' in kwargs:
return b.execute_with_retries(
sahara_images.image_manager().get, kwargs['id'])
else:
return b.execute_with_retries(
sahara_images.image_manager().find, **kwargs)
示例6: _get_neutron_limits
def _get_neutron_limits():
limits = {}
if not CONF.use_neutron:
return limits
neutron = neutron_client.client()
tenant_id = context.ctx().tenant_id
total_lim = b.execute_with_retries(neutron.show_quota, tenant_id)['quota']
if CONF.use_floating_ips:
usage_fip = b.execute_with_retries(
neutron.list_floatingips, tenant_id=tenant_id)['floatingips']
limits['floatingips'] = _sub_limit(total_lim['floatingip'],
len(usage_fip))
usage_sg = b.execute_with_retries(
neutron.list_security_groups, tenant_id=tenant_id).get(
'security_groups', [])
limits['security_groups'] = _sub_limit(total_lim['security_group'],
len(usage_sg))
usage_sg_rules = b.execute_with_retries(
neutron.list_security_group_rules, tenant_id=tenant_id).get(
'security_group_rules', [])
limits['security_group_rules'] = _sub_limit(
total_lim['security_group_rule'], len(usage_sg_rules))
usage_ports = b.execute_with_retries(
neutron.list_ports, tenant_id=tenant_id)['ports']
limits['ports'] = _sub_limit(total_lim['port'], len(usage_ports))
return limits
示例7: _delete_volume
def _delete_volume(volume_id):
LOG.debug("Deleting volume {volume}".format(volume=volume_id))
volume = cinder.get_volume(volume_id)
try:
b.execute_with_retries(volume.delete)
except Exception:
LOG.error("Can't delete volume {volume}".format(volume=volume.id))
示例8: wait_stack_completion
def wait_stack_completion(stack, is_update=False, last_updated_time=None):
base.execute_with_retries(stack.get)
while not _verify_completion(stack, is_update, last_updated_time):
context.sleep(1)
base.execute_with_retries(stack.get)
if stack.status != 'COMPLETE':
raise ex.HeatStackException(stack.stack_status_reason)
示例9: _delete_aa_server_group
def _delete_aa_server_group(self, cluster):
if cluster.anti_affinity:
server_group_name = g.generate_aa_group_name(cluster.name)
client = nova.client().server_groups
server_groups = b.execute_with_retries(client.findall,
name=server_group_name)
if len(server_groups) == 1:
b.execute_with_retries(client.delete, server_groups[0].id)
示例10: wait_stack_completion
def wait_stack_completion(stack):
# NOTE: expected empty status because status of stack
# maybe is not set in heat database
while stack.status in ['IN_PROGRESS', '']:
context.sleep(1)
base.execute_with_retries(stack.get)
if stack.status != 'COMPLETE':
raise ex.HeatStackException(stack.stack_status)
示例11: get_private_network_cidrs
def get_private_network_cidrs(cluster):
neutron_client = client()
private_net = base.execute_with_retries(neutron_client.show_network, cluster.neutron_management_network)
cidrs = []
for subnet_id in private_net["network"]["subnets"]:
subnet = base.execute_with_retries(neutron_client.show_subnet, subnet_id)
cidrs.append(subnet["subnet"]["cidr"])
return cidrs
示例12: _detach_volume
def _detach_volume(instance, volume_id):
volume = cinder.get_volume(volume_id)
try:
LOG.debug("Detaching volume {id} from instance".format(id=volume_id))
b.execute_with_retries(nova.client().volumes.delete_server_volume, instance.instance_id, volume_id)
except Exception:
LOG.error(_LE("Can't detach volume {id}").format(id=volume.id))
detach_timeout = CONF.timeouts.detach_volume_timeout
LOG.debug("Waiting {timeout} seconds to detach {id} volume".format(timeout=detach_timeout, id=volume_id))
_await_detach(volume_id)
示例13: proxy_domain_users_list
def proxy_domain_users_list():
'''Return a list of all users in the proxy domain.'''
admin = k.client_for_admin()
domain = domain_for_proxy()
if domain:
return b.execute_with_retries(admin.users.list, domain=domain.id)
return []
示例14: proxy_user_create
def proxy_user_create(username):
'''Create a new user in the proxy domain
Creates the username specified with a random password.
:param username: The name of the new user.
:returns: The password created for the user.
'''
admin = k.client_for_admin()
domain = domain_for_proxy()
password = six.text_type(uuid.uuid4())
b.execute_with_retries(
admin.users.create, name=username, password=password, domain=domain.id)
LOG.debug('Created proxy user {username}'.format(username=username))
return password
示例15: delete_stack
def delete_stack(cluster):
stack_name = cluster.stack_name
base.execute_with_retries(client().stacks.delete, stack_name)
stack = get_stack(stack_name, raise_on_missing=False)
while stack is not None:
# Valid states: IN_PROGRESS, empty and COMPLETE
if stack.status in ['IN_PROGRESS', '', 'COMPLETE']:
context.sleep(5)
else:
raise ex.HeatStackException(
message=_(
"Cannot delete heat stack {name}, reason: "
"stack status: {status}, status reason: {reason}").format(
name=stack_name, status=stack.status,
reason=stack.stack_status_reason))
stack = get_stack(stack_name, raise_on_missing=False)