Example #1
0
 def list_floating_ips(self, req, tenant_id):
     '''
     list all floating ip
     '''
     result, headers = self._nova_request(req)
     auth_token = req.context.auth_tok
     try:
         for floating_ip in result['floating_ips']:
             project_id = floating_ip['project_id']
             if project_id is not None:
                 tenant = ops_api.get_tenant(project_id, auth_token)
                 project_name = tenant['name']
                 floating_ip.update(project_name=project_name)
     except KeyError:
         LOG.exception(_("list floating ip error."))
         raise exc.HTTPFailedDependency(_("Nova method deprecated."))
     except exc.HTTPNotFound:
         LOG.error(_("project_id %s not found.") % project_id)
         raise exc.HTTPNotFound(_("project_id %s not found for"
             " floating ip %s.") % (project_id, floating_ip))
     pools = result.get('pools', None)
     ips = result.get('floating_ips', None)
     ips = list_filter.filter_floating_ips(req, ips)
     ips = list_sort.sort_floating_ips(req, ips)
     if pools is not None:
         return dict(pools=pools, floating_ips=ips)
     else:
         return dict(floating_ips=ips)