use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv6._case.Ipv6 in project netvirt by opendaylight.
the class ExternalRoutersListener method subnetRegisterMapping.
protected void subnetRegisterMapping(Routers routerEntry, Uint32 segmentId) {
LOG.debug("subnetRegisterMapping : Fetching values from extRouters model");
List<String> externalIps = NatUtil.getIpsListFromExternalIps(new ArrayList<ExternalIps>(routerEntry.nonnullExternalIps().values()));
int counter = 0;
int extIpCounter = externalIps.size();
LOG.debug("subnetRegisterMapping : counter values before looping counter {} and extIpCounter {}", counter, extIpCounter);
@Nullable List<Uuid> subnetIds = routerEntry.getSubnetIds();
if (subnetIds == null) {
return;
}
for (Uuid subnet : subnetIds) {
LOG.debug("subnetRegisterMapping : Looping internal subnets for subnet {}", subnet);
InstanceIdentifier<Subnetmap> subnetmapId = InstanceIdentifier.builder(Subnetmaps.class).child(Subnetmap.class, new SubnetmapKey(subnet)).build();
Optional<Subnetmap> sn;
try {
sn = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, subnetmapId);
} catch (InterruptedException | ExecutionException e) {
LOG.error("Failed to read SubnetMap for subnetmap Id {}", subnetmapId, e);
sn = Optional.empty();
}
if (sn.isPresent()) {
// subnets
Subnetmap subnetmapEntry = sn.get();
String subnetString = subnetmapEntry.getSubnetIp();
String[] subnetSplit = subnetString.split("/");
String subnetIp = subnetSplit[0];
try {
InetAddress address = InetAddress.getByName(subnetIp);
if (address instanceof Inet6Address) {
LOG.debug("subnetRegisterMapping : Skipping ipv6 subnet {} for the router {} with ipv6 address " + "{} ", subnet, routerEntry.getRouterName(), address);
continue;
}
} catch (UnknownHostException e) {
LOG.error("subnetRegisterMapping : Invalid ip address {}", subnetIp, e);
return;
}
String subnetPrefix = "0";
if (subnetSplit.length == 2) {
subnetPrefix = subnetSplit[1];
}
IPAddress subnetAddr = new IPAddress(subnetIp, Integer.parseInt(subnetPrefix));
LOG.debug("subnetRegisterMapping : subnetAddr is {} and subnetPrefix is {}", subnetAddr.getIpAddress(), subnetAddr.getPrefixLength());
// externalIps
LOG.debug("subnetRegisterMapping : counter values counter {} and extIpCounter {}", counter, extIpCounter);
if (extIpCounter != 0) {
if (counter < extIpCounter) {
String[] ipSplit = externalIps.get(counter).split("/");
String externalIp = ipSplit[0];
String extPrefix = Short.toString(NatConstants.DEFAULT_PREFIX);
if (ipSplit.length == 2) {
extPrefix = ipSplit[1];
}
IPAddress externalIpAddr = new IPAddress(externalIp, Integer.parseInt(extPrefix));
LOG.debug("subnetRegisterMapping : externalIp is {} and extPrefix is {}", externalIpAddr.getIpAddress(), externalIpAddr.getPrefixLength());
naptManager.registerMapping(segmentId, subnetAddr, externalIpAddr);
LOG.debug("subnetRegisterMapping : Called registerMapping for subnetIp {}, prefix {}, " + "externalIp {}. prefix {}", subnetIp, subnetPrefix, externalIp, extPrefix);
} else {
// Reset the counter which runs on externalIps for round-robbin effect
counter = 0;
LOG.debug("subnetRegisterMapping : Counter on externalIps got reset");
String[] ipSplit = externalIps.get(counter).split("/");
String externalIp = ipSplit[0];
String extPrefix = Short.toString(NatConstants.DEFAULT_PREFIX);
if (ipSplit.length == 2) {
extPrefix = ipSplit[1];
}
IPAddress externalIpAddr = new IPAddress(externalIp, Integer.parseInt(extPrefix));
LOG.debug("subnetRegisterMapping : externalIp is {} and extPrefix is {}", externalIpAddr.getIpAddress(), externalIpAddr.getPrefixLength());
naptManager.registerMapping(segmentId, subnetAddr, externalIpAddr);
LOG.debug("subnetRegisterMapping : Called registerMapping for subnetIp {}, prefix {}, " + "externalIp {}. prefix {}", subnetIp, subnetPrefix, externalIp, extPrefix);
}
}
counter++;
LOG.debug("subnetRegisterMapping : Counter on externalIps incremented to {}", counter);
} else {
LOG.warn("subnetRegisterMapping : No internal subnets present in extRouters Model");
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv6._case.Ipv6 in project netvirt by opendaylight.
the class SubnetGwMacChangeListener method handleSubnetGwIpChange.
private void handleSubnetGwIpChange(LearntVpnVipToPort learntVpnVipToPort) {
String macAddress = learntVpnVipToPort.getMacAddress();
if (macAddress == null) {
LOG.error("handleSubnetGwIpChange : Mac address is null for LearntVpnVipToPort for vpn {} prefix {}", learntVpnVipToPort.getVpnName(), learntVpnVipToPort.getPortFixedip());
return;
}
String fixedIp = learntVpnVipToPort.getPortFixedip();
if (fixedIp == null) {
LOG.error("handleSubnetGwIpChange : Fixed ip is null for LearntVpnVipToPort for vpn {}", learntVpnVipToPort.getVpnName());
return;
}
try {
InetAddress address = InetAddress.getByName(fixedIp);
if (address instanceof Inet6Address) {
// TODO: Revisit when IPv6 North-South communication support is added.
LOG.debug("handleSubnetGwIpChange : Skipping ipv6 address {}.", address);
return;
}
} catch (UnknownHostException e) {
LOG.warn("handleSubnetGwIpChange : Invalid ip address {}", fixedIp, e);
return;
}
for (Uuid subnetId : nvpnManager.getSubnetIdsForGatewayIp(new IpAddress(new Ipv4Address(fixedIp)))) {
LOG.trace("handleSubnetGwIpChange : Updating MAC resolution on vpn {} for GW ip {} to {}", learntVpnVipToPort.getVpnName(), fixedIp, macAddress);
extNetworkInstaller.installExtNetGroupEntries(subnetId, macAddress);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv6._case.Ipv6 in project netvirt by opendaylight.
the class NeutronvpnUtils method getIpVersionChoicesFromRouterUuid.
/**
* Method to get an ipVersionChosen as IPV4 and/or IPV6 or undefined from the subnetmaps of the router.
* @param routerUuid the Uuid for which find out the IP version associated
* @return an IpVersionChoice used by the router from its attached subnetmaps. IpVersionChoice.UNDEFINED if any
*/
public IpVersionChoice getIpVersionChoicesFromRouterUuid(Uuid routerUuid) {
IpVersionChoice rep = IpVersionChoice.UNDEFINED;
if (routerUuid == null) {
return rep;
}
List<Subnetmap> subnetmapList = getNeutronRouterSubnetMaps(routerUuid);
if (subnetmapList.isEmpty()) {
return rep;
}
for (Subnetmap sn : subnetmapList) {
if (sn.getSubnetIp() != null) {
IpVersionChoice ipVers = getIpVersionFromString(sn.getSubnetIp());
if (rep.choice != ipVers.choice) {
rep = rep.addVersion(ipVers);
}
if (rep.choice == IpVersionChoice.IPV4AND6.choice) {
return rep;
}
}
}
return rep;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv6._case.Ipv6 in project netvirt by opendaylight.
the class QosNeutronUtils method setPortDscpMarking.
public void setPortDscpMarking(Port port, DscpmarkingRules dscpMark) {
Uint64 dpnId = getDpnForInterface(port.getUuid().getValue());
String ifName = port.getUuid().getValue();
if (dpnId.equals(Uint64.ZERO)) {
LOG.info("DPN ID for interface {} not found. Cannot set dscp value {} on port {}", port.getUuid().getValue(), dscpMark, port.getUuid().getValue());
return;
}
if (!qosEosHandler.isQosClusterOwner()) {
qosServiceConfiguredPorts.add(port.getUuid());
LOG.trace("Not Qos Cluster Owner. Ignoring setting DSCP marking");
return;
} else {
Interface ifState = getInterfaceStateFromOperDS(ifName);
Short dscpValue = dscpMark.getDscpMark().toJava();
int ipVersions = getIpVersions(port);
// 1. OF rules
if (hasIpv4Addr(ipVersions)) {
LOG.trace("setting ipv4 flow for port: {}, dscp: {}", ifName, dscpValue);
addFlow(dpnId, dscpValue, ifName, NwConstants.ETHTYPE_IPV4, ifState);
}
if (hasIpv6Addr(ipVersions)) {
LOG.trace("setting ipv6 flow for port: {}, dscp: {}", ifName, dscpValue);
addFlow(dpnId, dscpValue, ifName, NwConstants.ETHTYPE_IPV6, ifState);
}
if (qosServiceConfiguredPorts.add(port.getUuid())) {
// bind qos service to interface
bindservice(ifName);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv6._case.Ipv6 in project netvirt by opendaylight.
the class DisplayAclDataCaches method printAcl.
private void printAcl(String aclId, Acl acl) {
session.getConsole().println();
session.getConsole().println(ACL_HEADER + String.format("%-32s ", aclId));
if (null != acl.getAccessListEntries() && null != acl.getAccessListEntries().getAce()) {
printHeader(ACL_ENTRIES_HEADERS, ACL_ENTRIES_HEADER_LINE);
List<Ace> aceList = acl.getAccessListEntries().getAce();
for (Ace ace : aceList) {
LOG.info("ace data: {}", ace);
SecurityRuleAttr aceAttr = getAccessListAttributes(ace);
Class<? extends DirectionBase> aceAttrDirection = aceAttr.getDirection();
AceIp aceIp = (AceIp) ace.getMatches().getAceType();
AceIpVersion ipVersion = aceIp.getAceIpVersion();
Uint8 protoNum = aceIp.getProtocol();
String protocol = "Any";
if (null != protoNum) {
protocol = protoMap.get(protoNum.toString());
protocol = (protocol == null) ? protoNum.toString() : protocol;
}
String ipVer = "";
String direction = DirectionEgress.class.equals(aceAttrDirection) ? "Egress" : "Ingress";
String ipPrefix = " -- ";
if (null != ipVersion && ipVersion instanceof AceIpv4) {
ipVer = "IPv4";
Ipv4Prefix srcNetwork = ((AceIpv4) ipVersion).getSourceIpv4Network();
if (null != srcNetwork) {
ipPrefix = srcNetwork.getValue();
}
} else if (null != ipVersion && ipVersion instanceof AceIpv6) {
ipVer = "IPv6";
Ipv6Prefix srcNetwork = ((AceIpv6) ipVersion).getSourceIpv6Network();
if (null != srcNetwork) {
ipPrefix = srcNetwork.getValue();
}
}
String remoteGroupId = "-";
if (aceAttr.getRemoteGroupId() != null) {
remoteGroupId = aceAttr.getRemoteGroupId().getValue();
ipPrefix = "-";
}
String prefixAndRemoteId = ipPrefix + " / " + remoteGroupId;
session.getConsole().print(String.format(ACE_ENTRIES_FORMAT_STRING, ace.key().getRuleName(), direction, protocol, ipVer, prefixAndRemoteId));
}
}
session.getConsole().println();
}
Aggregations