use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.object.Of in project netvirt by opendaylight.
the class AclServiceTestBase method newMatch.
// TODO refactor this instead of stealing it from org.opendaylight.netvirt.neutronvpn.NeutronSecurityRuleListener
protected Matches newMatch(int srcLowerPort, int srcUpperPort, int destLowerPort, int destupperPort, int srcRemoteIpPrefix, int dstRemoteIpPrefix, short protocol) {
AceIpBuilder aceIpBuilder = new AceIpBuilder();
if (destLowerPort != -1) {
DestinationPortRangeBuilder destinationPortRangeBuilder = new DestinationPortRangeBuilder();
destinationPortRangeBuilder.setLowerPort(new PortNumber(destLowerPort));
destinationPortRangeBuilder.setUpperPort(new PortNumber(destupperPort));
aceIpBuilder.setDestinationPortRange(destinationPortRangeBuilder.build());
}
AceIpv4Builder aceIpv4Builder = new AceIpv4Builder();
if (srcRemoteIpPrefix == AclConstants.SOURCE_REMOTE_IP_PREFIX_SPECIFIED) {
aceIpv4Builder.setSourceIpv4Network(new Ipv4Prefix(AclConstants.IPV4_ALL_NETWORK));
}
if (dstRemoteIpPrefix == AclConstants.DEST_REMOTE_IP_PREFIX_SPECIFIED) {
aceIpv4Builder.setSourceIpv4Network(new Ipv4Prefix(AclConstants.IPV4_ALL_NETWORK));
}
if (protocol != -1) {
aceIpBuilder.setProtocol(protocol);
}
aceIpBuilder.setAceIpVersion(aceIpv4Builder.build());
MatchesBuilder matchesBuilder = new MatchesBuilder();
matchesBuilder.setAceType(aceIpBuilder.build());
return matchesBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.object.Of in project netvirt by opendaylight.
the class AclDataUtil method getRemoteAclInterfaces.
/**
* Gets the set of ACL interfaces per ACL (in a map) which has specified
* remote ACL ID.
*
* @param remoteAclId the remote acl id
* @param direction the direction
* @return the set of ACL interfaces per ACL (in a map) which has specified
* remote ACL ID.
*/
public Map<String, Set<AclInterface>> getRemoteAclInterfaces(Uuid remoteAclId, Class<? extends DirectionBase> direction) {
Collection<Uuid> remoteAclList = getRemoteAcl(remoteAclId, direction);
if (remoteAclList == null) {
return null;
}
Map<String, Set<AclInterface>> mapOfAclWithInterfaces = new HashMap<>();
for (Uuid acl : remoteAclList) {
Set<AclInterface> interfaceSet = new HashSet<>();
Collection<AclInterface> interfaces = getInterfaceList(acl);
if (interfaces != null && !interfaces.isEmpty()) {
interfaceSet.addAll(interfaces);
mapOfAclWithInterfaces.put(acl.getValue(), interfaceSet);
}
}
return mapOfAclWithInterfaces;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.object.Of in project netvirt by opendaylight.
the class ExternalNetworksChangeListener method disassociateExternalNetworkFromVPN.
private void disassociateExternalNetworkFromVPN(Networks network, String vpnName) {
List<Uuid> routerIds = network.getRouterIds();
for (Uuid routerId : routerIds) {
InstanceIdentifier<RouterPorts> routerPortsId = NatUtil.getRouterPortsId(routerId.getValue());
Optional<RouterPorts> optRouterPorts = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, routerPortsId);
if (!optRouterPorts.isPresent()) {
LOG.debug("disassociateExternalNetworkFromVPN : Could not read Router Ports data object with id: {} " + "to handle disassociate ext nw {}", routerId, network.getId());
continue;
}
RouterPorts routerPorts = optRouterPorts.get();
List<Ports> interfaces = routerPorts.getPorts();
WriteTransaction removeFlowInvTx = dataBroker.newWriteOnlyTransaction();
for (Ports port : interfaces) {
String portName = port.getPortName();
BigInteger dpnId = NatUtil.getDpnForInterface(interfaceManager, portName);
if (dpnId.equals(BigInteger.ZERO)) {
LOG.debug("disassociateExternalNetworkFromVPN : DPN not found for {}," + "skip handling of ext nw {} disassociation", portName, network.getId());
continue;
}
List<InternalToExternalPortMap> intExtPortMapList = port.getInternalToExternalPortMap();
for (InternalToExternalPortMap intExtPortMap : intExtPortMapList) {
floatingIpListener.removeNATFlowEntries(dpnId, portName, vpnName, routerId.getValue(), intExtPortMap, removeFlowInvTx);
}
}
NatUtil.waitForTransactionToComplete(removeFlowInvTx);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.object.Of in project netvirt by opendaylight.
the class ExternalNetworksChangeListener method associateExternalNetworkWithVPN.
private void associateExternalNetworkWithVPN(Networks network, WriteTransaction writeFlowInvTx) {
List<Uuid> routerIds = network.getRouterIds();
for (Uuid routerId : routerIds) {
// long router = NatUtil.getVpnId(dataBroker, routerId.getValue());
InstanceIdentifier<RouterPorts> routerPortsId = NatUtil.getRouterPortsId(routerId.getValue());
Optional<RouterPorts> optRouterPorts = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, routerPortsId);
if (!optRouterPorts.isPresent()) {
LOG.debug("associateExternalNetworkWithVPN : Could not read Router Ports data object with id: {} " + "to handle associate ext nw {}", routerId, network.getId());
continue;
}
RouterPorts routerPorts = optRouterPorts.get();
List<Ports> interfaces = routerPorts.getPorts();
for (Ports port : interfaces) {
String portName = port.getPortName();
BigInteger dpnId = NatUtil.getDpnForInterface(interfaceManager, portName);
if (dpnId.equals(BigInteger.ZERO)) {
LOG.debug("associateExternalNetworkWithVPN : DPN not found for {}, " + "skip handling of ext nw {} association", portName, network.getId());
continue;
}
List<InternalToExternalPortMap> intExtPortMapList = port.getInternalToExternalPortMap();
for (InternalToExternalPortMap ipMap : intExtPortMapList) {
// remove all VPN related entries
floatingIpListener.createNATFlowEntries(dpnId, portName, routerId.getValue(), network.getId(), ipMap, writeFlowInvTx);
}
}
}
// SNAT
for (Uuid routerId : routerIds) {
LOG.debug("associateExternalNetworkWithVPN() : for routerId {}", routerId);
Uuid networkId = network.getId();
if (networkId == null) {
LOG.error("associateExternalNetworkWithVPN : networkId is null for the router ID {}", routerId);
return;
}
final String vpnName = network.getVpnid().getValue();
if (vpnName == null) {
LOG.error("associateExternalNetworkWithVPN : No VPN associated with ext nw {} for router {}", networkId, routerId);
return;
}
BigInteger dpnId = new BigInteger("0");
InstanceIdentifier<RouterToNaptSwitch> routerToNaptSwitch = NatUtil.buildNaptSwitchRouterIdentifier(routerId.getValue());
Optional<RouterToNaptSwitch> rtrToNapt = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, routerToNaptSwitch);
if (rtrToNapt.isPresent()) {
dpnId = rtrToNapt.get().getPrimarySwitchId();
}
LOG.debug("associateExternalNetworkWithVPN : got primarySwitch as dpnId{} ", dpnId);
if (dpnId == null || dpnId.equals(BigInteger.ZERO)) {
LOG.warn("associateExternalNetworkWithVPN : primary napt Switch not found for router {} on dpn: {}", routerId, dpnId);
return;
}
Long routerIdentifier = NatUtil.getVpnId(dataBroker, routerId.getValue());
InstanceIdentifierBuilder<org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.intext.ip.map.IpMapping> idBuilder = InstanceIdentifier.builder(IntextIpMap.class).child(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.intext.ip.map.IpMapping.class, new org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.intext.ip.map.IpMappingKey(routerIdentifier));
InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.intext.ip.map.IpMapping> id = idBuilder.build();
Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.natservice.rev160111.intext.ip.map.IpMapping> ipMapping = MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
if (ipMapping.isPresent()) {
List<IpMap> ipMaps = ipMapping.get().getIpMap();
for (IpMap ipMap : ipMaps) {
String externalIp = ipMap.getExternalIp();
LOG.debug("associateExternalNetworkWithVPN : Calling advToBgpAndInstallFibAndTsFlows for dpnId {}," + "vpnName {} and externalIp {}", dpnId, vpnName, externalIp);
if (natMode == NatMode.Controller) {
externalRouterListener.advToBgpAndInstallFibAndTsFlows(dpnId, NwConstants.INBOUND_NAPT_TABLE, vpnName, routerIdentifier, routerId.getValue(), externalIp, network.getId(), null, /* external-router */
writeFlowInvTx);
}
}
} else {
LOG.warn("associateExternalNetworkWithVPN : No ipMapping present fot the routerId {}", routerId);
}
long vpnId = NatUtil.getVpnId(dataBroker, vpnName);
// Install 47 entry to point to 21
if (natMode == NatMode.Controller) {
externalRouterListener.installNaptPfibEntriesForExternalSubnets(routerId.getValue(), dpnId, writeFlowInvTx);
if (vpnId != -1) {
LOG.debug("associateExternalNetworkWithVPN : Calling externalRouterListener installNaptPfibEntry " + "for dpnId {} and vpnId {}", dpnId, vpnId);
externalRouterListener.installNaptPfibEntry(dpnId, vpnId, writeFlowInvTx);
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.object.Of in project netvirt by opendaylight.
the class ExternalRoutersListener method changeLocalVpnIdToBgpVpnId.
/**
* router association to vpn.
*
* @param routerName - Name of router
* @param routerId - router id
* @param bgpVpnName BGP VPN name
*/
public void changeLocalVpnIdToBgpVpnId(String routerName, long routerId, String bgpVpnName, WriteTransaction writeFlowInvTx, ProviderTypes extNwProvType) {
LOG.debug("changeLocalVpnIdToBgpVpnId : Router associated to BGP VPN");
if (chkExtRtrAndSnatEnbl(new Uuid(routerName))) {
long bgpVpnId = NatUtil.getVpnId(dataBroker, bgpVpnName);
LOG.debug("changeLocalVpnIdToBgpVpnId : BGP VPN ID value {} ", bgpVpnId);
if (bgpVpnId != NatConstants.INVALID_ID) {
LOG.debug("changeLocalVpnIdToBgpVpnId : Populate the router-id-name container with the " + "mapping BGP VPN-ID {} -> BGP VPN-NAME {}", bgpVpnId, bgpVpnName);
RouterIds rtrs = new RouterIdsBuilder().setKey(new RouterIdsKey(bgpVpnId)).setRouterId(bgpVpnId).setRouterName(bgpVpnName).build();
MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, getRoutersIdentifier(bgpVpnId), rtrs);
// Get the allocated Primary NAPT Switch for this router
LOG.debug("changeLocalVpnIdToBgpVpnId : Router ID value {} ", routerId);
LOG.debug("changeLocalVpnIdToBgpVpnId : Update the Router ID {} to the BGP VPN ID {} ", routerId, bgpVpnId);
addOrDelDefaultFibRouteForSnatWithBgpVpn(routerName, routerId, bgpVpnId, true, writeFlowInvTx);
// Get the group ID
BigInteger primarySwitchId = NatUtil.getPrimaryNaptfromRouterName(dataBroker, routerName);
createGroupId(getGroupIdKey(routerName));
installFlowsWithUpdatedVpnId(primarySwitchId, routerName, bgpVpnId, routerId, true, writeFlowInvTx, extNwProvType);
}
}
}
Aggregations