Merge "Adding retry ability to neutronclient calls"
This commit is contained in:
commit
2e2692f1e2
@ -63,10 +63,12 @@ def init_instances_ips(instance):
|
||||
"Trying to get via Neutron.".format(
|
||||
mgmt_ip=management_ip, internal_ip=internal_ip))
|
||||
neutron_client = neutron.client()
|
||||
ports = neutron_client.list_ports(device_id=server.id)["ports"]
|
||||
ports = b.execute_with_retries(
|
||||
neutron_client.list_ports, device_id=server.id)["ports"]
|
||||
if ports:
|
||||
target_port_id = ports[0]['id']
|
||||
fl_ips = neutron_client.list_floatingips(
|
||||
fl_ips = b.execute_with_retries(
|
||||
neutron_client.list_floatingips,
|
||||
port_id=target_port_id)['floatingips']
|
||||
if fl_ips:
|
||||
fl_ip = fl_ips[0]
|
||||
|
@ -162,25 +162,28 @@ def _get_neutron_limits():
|
||||
return limits
|
||||
neutron = neutron_client.client()
|
||||
tenant_id = context.ctx().tenant_id
|
||||
total_lim = neutron.show_quota(tenant_id)['quota']
|
||||
total_lim = b.execute_with_retries(neutron.show_quota, tenant_id)['quota']
|
||||
|
||||
if CONF.use_floating_ips:
|
||||
usage_fip = neutron.list_floatingips(
|
||||
tenant_id=tenant_id)['floatingips']
|
||||
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 = neutron.list_security_groups(
|
||||
tenant_id=tenant_id).get('security_groups', [])
|
||||
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 = neutron.list_security_group_rules(
|
||||
tenant_id=tenant_id).get('security_group_rules', [])
|
||||
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 = neutron.list_ports(tenant_id=tenant_id)['ports']
|
||||
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
|
||||
|
@ -79,7 +79,8 @@ class NeutronClient(object):
|
||||
routers = self.neutron.list_routers()['routers']
|
||||
for router in routers:
|
||||
device_id = router['id']
|
||||
ports = self.neutron.list_ports(device_id=device_id)['ports']
|
||||
ports = base.execute_with_retries(
|
||||
self.neutron.list_ports, device_id=device_id)['ports']
|
||||
port = next((port for port in ports
|
||||
if port['network_id'] == self.network), None)
|
||||
if port:
|
||||
@ -96,12 +97,13 @@ class NeutronClient(object):
|
||||
|
||||
def get_private_network_cidrs(cluster):
|
||||
neutron_client = client()
|
||||
private_net = neutron_client.show_network(
|
||||
cluster.neutron_management_network)
|
||||
private_net = base.execute_with_retries(neutron_client.show_network,
|
||||
cluster.neutron_management_network)
|
||||
|
||||
cidrs = []
|
||||
for subnet_id in private_net['network']['subnets']:
|
||||
subnet = neutron_client.show_subnet(subnet_id)
|
||||
subnet = base.execute_with_retries(
|
||||
neutron_client.show_subnet, subnet_id)
|
||||
cidrs.append(subnet['subnet']['cidr'])
|
||||
|
||||
return cidrs
|
||||
|
Loading…
Reference in New Issue
Block a user