コード例 #1
0
    def create_gateway_vport_no_usergroup(self, tenant_id, params=False):
        subnet = params.get('subnet')
        enable_dhcp = params.get('enable_dhcp')
        port = params.get('port')
        type = params.get('type')
        subn_id = subnet['id']

        nuage_subnet = params.get('vsd_subnet')
        if not nuage_subnet:
            msg = (_("Nuage subnet for neutron subnet %(subn)s not found") % {
                'subn': subn_id
            })
            raise restproxy.ResourceNotFoundException(msg)
        # Create a vport with bridge/host interface
        req_params = {
            'nuage_vlan_id':
            params['gatewayinterface'],
            'neutron_subnet':
            subnet,
            'nuage_managed_subnet':
            params.get('nuage_managed_subnet'),
            'gw_type':
            params['personality'],
            'externalid':
            get_vsd_external_id(port['id'] if port else subnet['network_id'])
        }
        if nuage_subnet['parentType'] == 'zone':
            req_params['nuage_subnet_id'] = nuage_subnet['ID']
        else:
            req_params['l2domain_id'] = nuage_subnet['ID']

        # Check if tenant has permission on gw interface
        user_tenant = params.get('tenant')
        if user_tenant:
            # Give permissions for the enterprise
            self.add_ent_perm(tenant_id, params['gatewayinterface'],
                              params['np_id'])

        if type == constants.BRIDGE_VPORT_TYPE:
            req_params[constants.PORTSECURITY] = True
            resp = gw_helper.create_vport_interface(self.restproxy, req_params,
                                                    type)
        else:
            ips = {}
            for fixed_ip in port.get('fixed_ips', []):
                if netaddr.IPAddress(fixed_ip['ip_address']).version == 4:
                    ips[4] = fixed_ip['ip_address']
                else:
                    ips[6] = fixed_ip['ip_address']
            if enable_dhcp:
                req_params['ipaddress'] = ips.get(4)
                req_params['ipaddress_v6'] = ips.get(6)
            else:
                req_params['ipaddress'] = None
                req_params['ipaddress_v6'] = ips.get(6)
            req_params['mac'] = port['mac_address']
            req_params['externalid'] = get_vsd_external_id(port['id'])
            req_params[constants.PORTSECURITY] = port[constants.PORTSECURITY]
            resp = gw_helper.create_vport_interface(self.restproxy, req_params,
                                                    type)

        ret = resp
        ret['vport_gw_type'] = self.get_personality_type(params['personality'])
        return ret
コード例 #2
0
    def create_gateway_vport_no_usergroup(self, tenant_id, params):
        subnet = params.get('subnet')
        enable_dhcp = params.get('enable_dhcp')
        port = params.get('port')

        if subnet:
            subn_id = subnet['id']
            type = constants.BRIDGE_VPORT_TYPE
        else:
            subn_id = port['fixed_ips'][0]['subnet_id']
            type = constants.HOST_VPORT_TYPE

        nuage_subnet = params.get('vsd_subnet')
        if not nuage_subnet:
            msg = (_("Nuage subnet for neutron subnet %(subn)s not found") % {
                'subn': subn_id
            })
            raise restproxy.RESTProxyError(msg)
        # Create a vport with bridge/host interface
        req_params = {
            'nuage_vlan_id': params['gatewayinterface'],
            'neutron_subnet_id': subn_id,
            'nuage_managed_subnet': params.get('nuage_managed_subnet'),
            'gw_type': params['personality']
        }
        if nuage_subnet['parentType'] == 'zone':
            req_params['nuage_subnet_id'] = nuage_subnet['ID']
        else:
            req_params['l2domain_id'] = nuage_subnet['ID']

        # Check if tenant has permission on gw interface
        user_tenant = params.get('tenant')
        if user_tenant:
            # Give permissions for the enterprise
            self.add_ent_perm(tenant_id, params['gatewayinterface'],
                              params['np_id'])
        ret = dict()
        if type == constants.BRIDGE_VPORT_TYPE:
            req_params[constants.PORTSECURITY] = True
            resp = gw_helper.create_vport_interface(self.restproxy,
                                                    self.policygroup,
                                                    req_params, type)
        else:
            if enable_dhcp:
                req_params['ipaddress'] = port['fixed_ips'][0]['ip_address']
            else:
                req_params['ipaddress'] = None
            req_params['mac'] = port['mac_address']
            req_params['externalid'] = get_vsd_external_id(port['id'])
            req_params[constants.PORTSECURITY] = port[constants.PORTSECURITY]
            resp = gw_helper.create_vport_interface(self.restproxy,
                                                    self.policygroup,
                                                    req_params, type)

        ret = resp
        # Determine the vport_gw_type
        if params['personality'] == constants.GW_TYPE['VSG']:
            ret['vport_gw_type'] = constants.HARDWARE
        else:
            ret['vport_gw_type'] = constants.SOFTWARE

        return ret
コード例 #3
0
    def create_gateway_vport(self, tenant_id, params):
        subnet = params.get('subnet')
        enable_dhcp = params.get('enable_dhcp')
        port = params.get('port')
        type = params.get('type')
        subn_id = subnet['id']

        nuage_subnet = params.get('vsd_subnet')
        if not nuage_subnet:
            msg = (_("Nuage subnet for neutron subnet %(subn)s not found") % {
                'subn': subn_id
            })
            raise restproxy.ResourceNotFoundException(msg)
        # Create a vport with bridge/host interface
        req_params = {
            'nuage_vlan_id': params['gatewayinterface'],
            'neutron_subnet': subnet,
            'nuage_managed_subnet': params.get('nuage_managed_subnet')
        }

        # Get gateway from gw interface
        gw = gw_helper.get_gateway_by_vlan(self.restproxy,
                                           params['gatewayinterface'])

        if nuage_subnet['parentType'] == 'zone':
            req_params['nuage_subnet_id'] = nuage_subnet['ID']
        else:
            req_params['l2domain_id'] = nuage_subnet['ID']

        req_params['gw_type'] = gw['personality']

        # Check if tenant has permission on gw interface
        user_tenant = params.get('tenant')
        if user_tenant:
            # Give permissions for the enterprise
            self.add_ent_perm(tenant_id, params['gatewayinterface'],
                              params['np_id'])

            # Give permissions for the tenant
            self.add_tenant_perm(params['gatewayinterface'], user_tenant,
                                 params['np_id'])

        ret = dict()
        if type == constants.BRIDGE_VPORT_TYPE:
            req_params[constants.PORTSECURITY] = True
            req_params['externalid'] = get_vsd_external_id(
                port['id'] if port else subnet['network_id'])
            resp = gw_helper.create_vport_interface(self.restproxy, req_params,
                                                    type)
        else:
            if enable_dhcp:
                req_params['ipaddress'] = port['fixed_ips'][0]['ip_address']
            else:
                req_params['ipaddress'] = None
            req_params['mac'] = port['mac_address']
            req_params['externalid'] = get_vsd_external_id(port['id'])
            req_params[constants.PORTSECURITY] = port[constants.PORTSECURITY]
            resp = gw_helper.create_vport_interface(self.restproxy, req_params,
                                                    type)

        ret = resp
        ret['vport_gw_type'] = self.get_personality_type(gw['personality'])
        return ret