Ejemplo n.º 1
0
def _get_tenant_network_usages(request, usages, disabled_quotas, tenant_id):
    enabled_quotas = ((NOVA_NETWORK_QUOTA_FIELDS | NEUTRON_QUOTA_FIELDS) -
                      disabled_quotas)
    if not enabled_quotas:
        return

    # NOTE(amotoki): floatingip is Neutron quota and floating_ips is
    # Nova quota. We need to check both.
    if {'floatingip', 'floating_ips'} & enabled_quotas:
        floating_ips = []
        try:
            if neutron.floating_ip_supported(request):
                floating_ips = neutron.tenant_floating_ip_list(request)
        except Exception:
            pass
        usages.tally('floating_ips', len(floating_ips))

    if 'security_group' not in disabled_quotas:
        security_groups = []
        security_groups = neutron.security_group_list(request)
        usages.tally('security_groups', len(security_groups))

    if 'network' not in disabled_quotas:
        networks = neutron.network_list(request, tenant_id=tenant_id)
        usages.tally('networks', len(networks))

    if 'subnet' not in disabled_quotas:
        subnets = neutron.subnet_list(request, tenant_id=tenant_id)
        usages.tally('subnets', len(subnets))

    if 'router' not in disabled_quotas:
        routers = neutron.router_list(request, tenant_id=tenant_id)
        usages.tally('routers', len(routers))
Ejemplo n.º 2
0
def _get_tenant_network_usages(request, usages, disabled_quotas, tenant_id):
    enabled_quotas = ((NOVA_NETWORK_QUOTA_FIELDS | NEUTRON_QUOTA_FIELDS)
                      - disabled_quotas)
    if not enabled_quotas:
        return

    # NOTE(amotoki): floatingip is Neutron quota and floating_ips is
    # Nova quota. We need to check both.
    if {'floatingip', 'floating_ips'} & enabled_quotas:
        floating_ips = []
        try:
            if neutron.floating_ip_supported(request):
                floating_ips = neutron.tenant_floating_ip_list(request)
        except Exception:
            pass
        usages.tally('floating_ips', len(floating_ips))

    if 'security_group' not in disabled_quotas:
        security_groups = []
        security_groups = neutron.security_group_list(request)
        usages.tally('security_groups', len(security_groups))

    if 'network' not in disabled_quotas:
        networks = neutron.network_list(request, tenant_id=tenant_id)
        usages.tally('networks', len(networks))

    if 'subnet' not in disabled_quotas:
        subnets = neutron.subnet_list(request, tenant_id=tenant_id)
        usages.tally('subnets', len(subnets))

    if 'router' not in disabled_quotas:
        routers = neutron.router_list(request, tenant_id=tenant_id)
        usages.tally('routers', len(routers))
Ejemplo n.º 3
0
 def get_initial(self):
     self.domain = self.get_domain()
     results = {'domain_id': self.domain.id,
                'domain_name': self.domain.name, }
     if limit_records_to_fips():
         results.update({'fips': tenant_floating_ip_list(self.request),
                         'instances': server_list(self.request)[0]})
     return results
Ejemplo n.º 4
0
    def _release_floating_ip(self, request, server_networks, network, server_id):
        # release floating ip only if the server was in the specific network and has no other networks
        if not self._has_no_other_networks(server_networks, network):
            return

        tenant_floating_ips = tenant_floating_ip_list(request)
        for ip in self._get_floating_ips(server_networks[network]):
            tenant_floating_ip = self._get_floating_ip_from_tenant(tenant_floating_ips, ip, server_id)
            if tenant_floating_ip:
                tenant_floating_ip_release(request, tenant_floating_ip.id)
Ejemplo n.º 5
0
def add_floating_ip_info(request, loadbalancers):
    """Add floating IP address info to each load balancer.

    """
    floating_ips = neutron.tenant_floating_ip_list(request)
    for lb in loadbalancers:
        floating_ip = {}
        associated_ip = next((fip for fip in floating_ips
                              if fip['fixed_ip'] == lb['vip_address']), None)
        if associated_ip is not None:
            floating_ip['id'] = associated_ip['id']
            floating_ip['ip'] = associated_ip['ip']
        lb['floating_ip'] = floating_ip