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());
}
}
}
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);
}
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;
}
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;
}
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);
}
Aggregations