示例#1
0
    def readable(self, request):
        sFormatted = {
            'id': self.id,
            'name': self.name,
            'description': self.description,
            'admin_state_up': self.admin_state_up,
            'status': self.status,
        }
        try:
            sFormatted['subnet_id'] = self.subnet_id
            sFormatted['subnet_name'] = neutron.subnet_get(
                request, self.subnet_id).cidr
        except Exception:
            sFormatted['subnet_id'] = self.subnet_id
            sFormatted['subnet_name'] = self.subnet_id

        try:
            sFormatted['router_id'] = self.router_id
            sFormatted['router_name'] = neutron.router_get(
                request, self.router_id).name
        except Exception:
            sFormatted['router_id'] = self.router_id
            sFormatted['router_name'] = self.router_id

        return self.AttributeDict(sFormatted)
示例#2
0
 def get_publicips_data(self):
     data = []
     for router in neutron.router_list(
             self.request, tenant_id=self.request.user.tenant_id):
         router_info = neutron.router_get(self.request, router.id)
         for port in router_info.get('ports', []):
             if port.get('device_owner') != 'network:router_gateway':
                 continue
             ips = [i['ip_address'] for i in port.get('fixed_ips', [])]
             data.append(PublicIP(None, router.get('name'), ips))
     return data
示例#3
0
 def get_publicips_data(self):
     data = []
     for router in neutron.router_list(
             self.request, tenant_id=self.request.user.tenant_id):
         router_info = neutron.router_get(self.request, router.id)
         for port in router_info.get('ports', []):
             if port.get('device_owner') != 'network:router_gateway':
                 continue
             ips = [i['ip_address'] for i in port.get('fixed_ips', [])]
             data.append(PublicIP(None, router.get('name'), ips))
     return data
示例#4
0
def routerrule_list(request, **params):
    if 'router_id' in params:
        params['device_id'] = params['router_id']
    if 'router' in request.META:
        router = request.META['router']
    else:
        router = api.router_get(request, params['device_id'])
    try:
        rules = router.router_rules
    except AttributeError:
        return (False, [])
    return (True, rules)
示例#5
0
def routerrule_list(request, **params):
    if 'router_id' in params:
        params['device_id'] = params['router_id']
    if 'router' in request.META:
        router = request.META['router']
    else:
        router = api.router_get(request, params['device_id'])
    try:
        rules = router.router_rules
    except AttributeError:
        return (False, [])
    return (True, rules)
示例#6
0
def _vpnservice_get(request, vpnservice_id, expand_subnet=False,
                    expand_router=False, expand_conns=False):
    vpnservice = neutronclient(request).show_vpnservice(vpnservice_id).get(
        'vpnservice')
    if expand_subnet:
        vpnservice['subnet'] = neutron.subnet_get(
            request, vpnservice['subnet_id'])
    if expand_router:
        vpnservice['router'] = neutron.router_get(
            request, vpnservice['router_id'])
    if expand_conns:
        ipsecsiteconns = _ipsecsiteconnection_list(request)
        vpnservice['ipsecsiteconns'] = [c for c in ipsecsiteconns
                                        if c.vpnservice_id == vpnservice['id']]
    return VPNService(vpnservice)
示例#7
0
def _vpnservice_get(request, vpnservice_id, expand_subnet=False,
                    expand_router=False, expand_conns=False):
    vpnservice = neutronclient(request).show_vpnservice(vpnservice_id).get(
        'vpnservice')
    if expand_subnet:
        vpnservice['subnet'] = neutron.subnet_get(
            request, vpnservice['subnet_id'])
    if expand_router:
        vpnservice['router'] = neutron.router_get(
            request, vpnservice['router_id'])
    if expand_conns:
        ipsecsiteconns = _ipsecsiteconnection_list(request)
        vpnservice['ipsecsiteconns'] = [c for c in ipsecsiteconns
                                        if c.vpnservice_id == vpnservice['id']]
    return VPNService(vpnservice)
示例#8
0
文件: vpn.py 项目: NeCTAR-RC/horizon
    def readable(self, request):
        sFormatted = {'id': self.id,
                      'name': self.name,
                      'description': self.description,
                      'admin_state_up': self.admin_state_up,
                      'status': self.status,
                      }
        try:
            sFormatted['subnet_id'] = self.subnet_id
            sFormatted['subnet_name'] = neutron.subnet_get(
                request, self.subnet_id).cidr
        except Exception:
            sFormatted['subnet_id'] = self.subnet_id
            sFormatted['subnet_name'] = self.subnet_id

        try:
            sFormatted['router_id'] = self.router_id
            sFormatted['router_name'] = neutron.router_get(
                request, self.router_id).name
        except Exception:
            sFormatted['router_id'] = self.router_id
            sFormatted['router_name'] = self.router_id

        return self.AttributeDict(sFormatted)