Search in sources :

Example 76 with RouterId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.RouterId in project netvirt by opendaylight.

the class NeutronPortChangeListener method handleRouterInterfaceAdded.

private void handleRouterInterfaceAdded(Port routerPort) {
    if (routerPort.getDeviceId() != null) {
        Uuid routerId = new Uuid(routerPort.getDeviceId());
        Uuid infNetworkId = routerPort.getNetworkId();
        Uuid existingVpnId = neutronvpnUtils.getVpnForNetwork(infNetworkId);
        elanService.addKnownL3DmacAddress(routerPort.getMacAddress().getValue(), infNetworkId.getValue());
        if (existingVpnId == null) {
            Set<Uuid> listVpnIds = new HashSet<>();
            Uuid vpnId = neutronvpnUtils.getVpnForRouter(routerId, true);
            if (vpnId == null) {
                vpnId = routerId;
            }
            listVpnIds.add(vpnId);
            Uuid internetVpnId = neutronvpnUtils.getInternetvpnUuidBoundToRouterId(routerId);
            List<Subnetmap> subnetMapList = new ArrayList<>();
            List<FixedIps> portIps = routerPort.getFixedIps();
            boolean portIsIpv6 = false;
            for (FixedIps portIP : portIps) {
                // and addSubnetToVpn here
                if (internetVpnId != null && portIP.getIpAddress().getIpv6Address() != null) {
                    portIsIpv6 = true;
                }
                String ipValue = String.valueOf(portIP.getIpAddress().getValue());
                Uuid subnetId = portIP.getSubnetId();
                nvpnManager.updateSubnetNodeWithFixedIp(subnetId, routerId, routerPort.getUuid(), ipValue, routerPort.getMacAddress().getValue(), vpnId);
                Subnetmap sn = neutronvpnUtils.getSubnetmap(subnetId);
                subnetMapList.add(sn);
            }
            if (portIsIpv6) {
                listVpnIds.add(internetVpnId);
                if (neutronvpnUtils.shouldVpnHandleIpVersionChoiceChangeToAdd(IpVersionChoice.IPV6, internetVpnId)) {
                    neutronvpnUtils.updateVpnInstanceWithIpFamily(internetVpnId.getValue(), IpVersionChoice.IPV6, true);
                    neutronvpnUtils.updateVpnInstanceWithFallback(internetVpnId.getValue(), true);
                }
            }
            if (!subnetMapList.isEmpty()) {
                nvpnManager.createVpnInterface(listVpnIds, routerPort, null);
            }
            for (FixedIps portIP : routerPort.getFixedIps()) {
                String ipValue = String.valueOf(portIP.getIpAddress().getValue());
                IpVersionChoice version = neutronvpnUtils.getIpVersionFromString(ipValue);
                if (neutronvpnUtils.shouldVpnHandleIpVersionChoiceChangeToAdd(version, vpnId)) {
                    neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), version, true);
                }
                if (version.isIpVersionChosen(IpVersionChoice.IPV4)) {
                    nvpnManager.addSubnetToVpn(vpnId, portIP.getSubnetId(), null);
                } else {
                    nvpnManager.addSubnetToVpn(vpnId, portIP.getSubnetId(), internetVpnId);
                }
                LOG.trace("NeutronPortChangeListener Add Subnet Gateway IP {} MAC {} Interface {} VPN {}", ipValue, routerPort.getMacAddress(), routerPort.getUuid().getValue(), vpnId.getValue());
            }
            nvpnManager.addToNeutronRouterInterfacesMap(routerId, routerPort.getUuid().getValue());
            nvpnNatManager.handleSubnetsForExternalRouter(routerId);
            WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
            String portInterfaceName = createOfPortInterface(routerPort, wrtConfigTxn);
            createElanInterface(routerPort, portInterfaceName, wrtConfigTxn);
            wrtConfigTxn.submit();
        } else {
            LOG.error("Neutron network {} corresponding to router interface port {} for neutron router {}" + " already associated to VPN {}", infNetworkId.getValue(), routerPort.getUuid().getValue(), routerId.getValue(), existingVpnId.getValue());
        }
    }
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ArrayList(java.util.ArrayList) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) FixedIps(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps) HashSet(java.util.HashSet) IpVersionChoice(org.opendaylight.netvirt.neutronvpn.api.enums.IpVersionChoice)

Example 77 with RouterId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.RouterId in project netvirt by opendaylight.

the class NeutronRouterChangeListener method update.

@Override
protected void update(InstanceIdentifier<Router> identifier, Router original, Router update) {
    LOG.trace("Updating Router : key: {}, original value={}, update value={}", identifier, original, update);
    neutronvpnUtils.addToRouterCache(update);
    Uuid routerId = update.getUuid();
    neutronvpnUtils.addToRouterCache(update);
    Uuid vpnId = neutronvpnUtils.getVpnForRouter(routerId, true);
    // internal vpn always present in case external vpn not found
    if (vpnId == null) {
        vpnId = routerId;
    }
    List<Routes> oldRoutes = original.getRoutes() != null ? original.getRoutes() : new ArrayList<>();
    List<Routes> newRoutes = update.getRoutes() != null ? update.getRoutes() : new ArrayList<>();
    if (!oldRoutes.equals(newRoutes)) {
        newRoutes.removeIf(oldRoutes::remove);
        handleChangedRoutes(vpnId, newRoutes, NwConstants.ADD_FLOW);
        if (!oldRoutes.isEmpty()) {
            handleChangedRoutes(vpnId, oldRoutes, NwConstants.DEL_FLOW);
        }
    }
    nvpnNatManager.handleExternalNetworkForRouter(original, update);
    gwMacResolver.sendArpRequestsToExtGateways(update);
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.Routes)

Example 78 with RouterId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.RouterId in project bgpcep by opendaylight.

the class BaseAbstractRouteEntry method addRoute.

@Override
public int addRoute(final UnsignedInteger routerId, final long remotePathId, final Route route) {
    final Attributes advertisedAttrs = route.getAttributes();
    int offset = this.offsets.offsetOf(routerId);
    if (offset < 0) {
        final OffsetMap newOffsets = this.offsets.with(routerId);
        offset = newOffsets.offsetOf(routerId);
        this.values = newOffsets.expand(this.offsets, this.values, offset);
        this.offsets = newOffsets;
    }
    this.offsets.setValue(this.values, offset, advertisedAttrs);
    LOG.trace("Added route from {} attributes {}", routerId, advertisedAttrs);
    return offset;
}
Also used : Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)

Example 79 with RouterId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.RouterId in project bgpcep by opendaylight.

the class BaseAbstractRouteEntry method selectBest.

@Override
public final boolean selectBest(final long localAs) {
    /*
         * FIXME: optimize flaps by making sure we consider stability of currently-selected route.
         */
    final BasePathSelector selector = new BasePathSelector(localAs);
    // Select the best route.
    for (int i = 0; i < this.offsets.size(); ++i) {
        final UnsignedInteger routerId = this.offsets.getRouterKey(i);
        final Attributes attributes = this.offsets.getValue(this.values, i);
        LOG.trace("Processing router id {} attributes {}", routerId, attributes);
        selector.processPath(routerId, attributes);
    }
    // Get the newly-selected best path.
    final BaseBestPath newBestPath = selector.result();
    final boolean modified = newBestPath == null || !newBestPath.equals(this.bestPath);
    if (modified) {
        if (this.offsets.isEmpty()) {
            this.removedBestPath = this.bestPath;
        }
        LOG.trace("Previous best {}, current best {}", this.bestPath, newBestPath);
        this.bestPath = newBestPath;
    }
    return modified;
}
Also used : Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes) UnsignedInteger(com.google.common.primitives.UnsignedInteger)

Example 80 with RouterId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.RouterId in project bgpcep by opendaylight.

the class RROUnnumberedInterfaceSubobjectParser method serializeSubobject.

@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
    Preconditions.checkArgument(subobject.getSubobjectType() instanceof UnnumberedCase, "Unknown subobject instance. Passed %s. Needed UnnumberedCase.", subobject.getSubobjectType().getClass());
    final UnnumberedSubobject specObj = ((UnnumberedCase) subobject.getSubobjectType()).getUnnumbered();
    final BitArray flags = new BitArray(FLAGS_SIZE);
    flags.set(LPA_F_OFFSET, subobject.isProtectionAvailable());
    flags.set(LPIU_F_OFFSET, subobject.isProtectionInUse());
    final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
    flags.toByteBuf(body);
    body.writeZero(RESERVED);
    Preconditions.checkArgument(specObj.getRouterId() != null, "RouterId is mandatory.");
    writeUnsignedInt(specObj.getRouterId(), body);
    Preconditions.checkArgument(specObj.getInterfaceId() != null, "InterfaceId is mandatory.");
    writeUnsignedInt(specObj.getInterfaceId(), body);
    RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
}
Also used : UnnumberedCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.UnnumberedCase) BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf) UnnumberedSubobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.UnnumberedSubobject)

Aggregations

Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)86 BigInteger (java.math.BigInteger)35 ArrayList (java.util.ArrayList)34 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)23 Subnetmap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap)22 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)20 Routers (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.Routers)20 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)19 ProviderTypes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ProviderTypes)19 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)17 ExecutionException (java.util.concurrent.ExecutionException)16 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)14 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)12 ExternalIps (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.ext.routers.routers.ExternalIps)12 IpPortMap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.intext.ip.port.map.ip.port.mapping.intext.ip.protocol.type.IpPortMap)12 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)11 InternalToExternalPortMap (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.router.ports.ports.InternalToExternalPortMap)11 HashSet (java.util.HashSet)10 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)10 RouterPorts (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.floating.ip.info.RouterPorts)10