use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefix in project netvirt by opendaylight.
the class TransportZoneNotificationUtil method removeVtep.
private void removeVtep(String zoneName, BigInteger dpId, @Nonnull WriteTransaction tx) {
InstanceIdentifier<Vteps> path = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(zoneName)).child(Subnets.class, new SubnetsKey(new IpPrefix(ALL_SUBNETS.toCharArray()))).child(Vteps.class, new VtepsKey(dpId, TUNNEL_PORT)).build();
tx.delete(LogicalDatastoreType.CONFIGURATION, path);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefix in project netvirt by opendaylight.
the class VpnUtil method getVrfEntry.
static VrfEntry getVrfEntry(DataBroker broker, String rd, String ipPrefix) {
VrfTables vrfTable = getVrfTable(broker, rd);
// TODO: why check VrfTables if we later go for the specific VrfEntry?
if (vrfTable != null) {
InstanceIdentifier<VrfEntry> vrfEntryId = InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd)).child(VrfEntry.class, new VrfEntryKey(ipPrefix)).build();
Optional<VrfEntry> vrfEntry = read(broker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
if (vrfEntry.isPresent()) {
return vrfEntry.get();
}
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefix in project netvirt by opendaylight.
the class FlowClassifierTranslator method buildAcl.
public static Acl buildAcl(SfcFlowClassifier flowClassifier, String sfpName) {
LOG.info("OpenStack Networking SFC pushed Flow classifier : {}", flowClassifier);
AclBuilder aclBuilder = new AclBuilder();
AceBuilder aceBuilder = new AceBuilder();
ActionsBuilder actionsBuilder = new ActionsBuilder();
RedirectToSfcBuilder redirectToSfcBuilder = new RedirectToSfcBuilder();
NeutronPortsBuilder neutronPortsBuilder = new NeutronPortsBuilder();
AceIpBuilder aceIpBuilder = new AceIpBuilder();
DestinationPortRangeBuilder destinationPortRange = new DestinationPortRangeBuilder();
SourcePortRangeBuilder sourcePortRangeBuilder = new SourcePortRangeBuilder();
if (flowClassifier.getUuid() != null) {
if (flowClassifier.getName() != null) {
aclBuilder.setAclName(flowClassifier.getUuid().getValue() + "_" + flowClassifier.getName());
} else {
aclBuilder.setAclName(flowClassifier.getUuid().getValue());
}
}
if (flowClassifier.getEthertype() != null) {
IpPrefix sourceIp = null;
IpPrefix destinationIp = null;
if (flowClassifier.getSourceIpPrefix() != null) {
sourceIp = flowClassifier.getSourceIpPrefix();
}
if (flowClassifier.getDestinationIpPrefix() != null) {
destinationIp = flowClassifier.getDestinationIpPrefix();
}
if (flowClassifier.getEthertype() == EthertypeV4.class) {
AceIpv4Builder aceIpv4Builder = new AceIpv4Builder();
if (sourceIp != null && sourceIp.getIpv4Prefix() != null) {
aceIpv4Builder.setSourceIpv4Network(sourceIp.getIpv4Prefix());
}
if (destinationIp != null && destinationIp.getIpv4Prefix() != null) {
aceIpv4Builder.setDestinationIpv4Network(destinationIp.getIpv4Prefix());
}
aceIpBuilder.setAceIpVersion(aceIpv4Builder.build());
aclBuilder.setAclType(Ipv4Acl.class);
}
if (flowClassifier.getEthertype() == EthertypeV6.class) {
AceIpv6Builder aceIpv6Builder = new AceIpv6Builder();
if (sourceIp != null && sourceIp.getIpv6Prefix() != null) {
aceIpv6Builder.setSourceIpv6Network(sourceIp.getIpv6Prefix());
}
if (sourceIp != null && destinationIp.getIpv6Prefix() != null) {
aceIpv6Builder.setDestinationIpv6Network(destinationIp.getIpv6Prefix());
}
aceIpBuilder.setAceIpVersion(aceIpv6Builder.build());
aclBuilder.setAclType(Ipv6Acl.class);
}
}
if (flowClassifier.getProtocol() != null) {
if (flowClassifier.getProtocol() == ProtocolTcp.class) {
aceIpBuilder.setProtocol(PROTO_TCP);
}
if (flowClassifier.getProtocol() == ProtocolUdp.class) {
aceIpBuilder.setProtocol(PROTO_UDP);
}
}
if (flowClassifier.getSourcePortRangeMin() != null) {
sourcePortRangeBuilder.setLowerPort(new PortNumber(flowClassifier.getSourcePortRangeMin()));
// set source port range only if lower port is specified as it is a mandatory parameter in acl model
aceIpBuilder.setSourcePortRange(sourcePortRangeBuilder.build());
}
if (flowClassifier.getSourcePortRangeMax() != null) {
sourcePortRangeBuilder.setUpperPort(new PortNumber(flowClassifier.getSourcePortRangeMax()));
}
if (flowClassifier.getDestinationPortRangeMin() != null) {
destinationPortRange.setLowerPort(new PortNumber(flowClassifier.getDestinationPortRangeMin()));
// set destination port range only if lower port is specified as it is a mandatory parameter in acl model
aceIpBuilder.setDestinationPortRange(destinationPortRange.build());
}
if (flowClassifier.getDestinationPortRangeMax() != null) {
destinationPortRange.setUpperPort(new PortNumber(flowClassifier.getDestinationPortRangeMax()));
}
if (flowClassifier.getLogicalSourcePort() != null) {
neutronPortsBuilder.setSourcePortUuid(flowClassifier.getLogicalSourcePort().getValue());
}
if (flowClassifier.getLogicalDestinationPort() != null) {
neutronPortsBuilder.setDestinationPortUuid(flowClassifier.getLogicalDestinationPort().getValue());
}
// currently not supported.
// if (flowClassifier.getL7Parameter() != null) {
// }
MatchesBuilder matchesBuilder = new MatchesBuilder();
matchesBuilder.setAceType(aceIpBuilder.build());
matchesBuilder.addAugmentation(NeutronPorts.class, neutronPortsBuilder.build());
// Set redirect-to-rsp action if rsp name is provided
if (sfpName != null) {
redirectToSfcBuilder.setSfpName(sfpName);
actionsBuilder.addAugmentation(RedirectToSfc.class, redirectToSfcBuilder.build());
aceBuilder.setActions(actionsBuilder.build());
}
aceBuilder.setMatches(matchesBuilder.build());
// OpenStack networking-sfc don't pass action information
// with flow classifier. It need to be determined using the
// Port Chain data and then flow calssifier need to be updated
// with the actions.
aceBuilder.setRuleName(aclBuilder.getAclName() + RULE);
aceBuilder.setKey(new AceKey(aceBuilder.getRuleName()));
ArrayList<Ace> aceList = new ArrayList<>();
aceList.add(aceBuilder.build());
AccessListEntriesBuilder accessListEntriesBuilder = new AccessListEntriesBuilder();
accessListEntriesBuilder.setAce(aceList);
aclBuilder.setAccessListEntries(accessListEntriesBuilder.build());
aclBuilder.setKey(new AclKey(aclBuilder.getAclName(), aclBuilder.getAclType()));
LOG.info("Translated ACL Flow classfier : {}", aclBuilder.toString());
return aclBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefix in project netvirt by opendaylight.
the class FibRpcServiceImpl method makeLocalFibEntry.
private void makeLocalFibEntry(long vpnId, BigInteger dpnId, String ipPrefix, List<Instruction> customInstructions) {
String[] values = ipPrefix.split("/");
String ipAddress = values[0];
int prefixLength = values.length == 1 ? 0 : Integer.parseInt(values[1]);
LOG.debug("Adding route to DPN. ip {} masklen {}", ipAddress, prefixLength);
InetAddress destPrefix = null;
try {
destPrefix = InetAddress.getByName(ipAddress);
} catch (UnknownHostException e) {
LOG.error("UnknowHostException in addRoute. Failed to add Route for ipPrefix {} VpnId {} DPN{}", ipAddress, vpnId, dpnId, e);
return;
}
List<MatchInfo> matches = new ArrayList<>();
matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(vpnId), MetaDataUtil.METADATA_MASK_VRFID));
matches.add(MatchEthernetType.IPV4);
if (prefixLength != 0) {
matches.add(new MatchIpv4Destination(destPrefix.getHostAddress(), Integer.toString(prefixLength)));
}
String flowRef = getFlowRef(dpnId, NwConstants.L3_FIB_TABLE, vpnId, ipAddress);
int priority = DEFAULT_FIB_FLOW_PRIORITY + prefixLength;
Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.L3_FIB_TABLE, flowRef, priority, flowRef, 0, 0, NwConstants.COOKIE_VM_FIB_TABLE, matches, customInstructions);
mdsalManager.installFlow(dpnId, flowEntity);
LOG.debug("FIB entry for route {} on dpn {} installed successfully - flow {}", ipAddress, dpnId, flowEntity);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefix in project netvirt by opendaylight.
the class FibRpcServiceImpl method removeLocalFibEntry.
private void removeLocalFibEntry(BigInteger dpnId, long vpnId, String ipPrefix) {
String[] values = ipPrefix.split("/");
String ipAddress = values[0];
int prefixLength = values.length == 1 ? 0 : Integer.parseInt(values[1]);
LOG.debug("Removing route from DPN. ip {} masklen {}", ipAddress, prefixLength);
InetAddress destPrefix = null;
try {
destPrefix = InetAddress.getByName(ipAddress);
} catch (UnknownHostException e) {
LOG.error("UnknowHostException in removeRoute. Failed to remove Route for ipPrefix {} DPN {} Vpn {}", ipAddress, dpnId, vpnId, e);
return;
}
List<MatchInfo> matches = new ArrayList<>();
matches.add(new MatchMetadata(MetaDataUtil.getVpnIdMetadata(vpnId), MetaDataUtil.METADATA_MASK_VRFID));
matches.add(MatchEthernetType.IPV4);
if (prefixLength != 0) {
matches.add(new MatchIpv4Destination(destPrefix.getHostAddress(), Integer.toString(prefixLength)));
}
String flowRef = getFlowRef(dpnId, NwConstants.L3_FIB_TABLE, vpnId, ipAddress);
int priority = DEFAULT_FIB_FLOW_PRIORITY + prefixLength;
Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.L3_FIB_TABLE, flowRef, priority, flowRef, 0, 0, NwConstants.COOKIE_VM_FIB_TABLE, matches, null);
mdsalManager.removeFlow(dpnId, flowEntity);
LOG.info("FIB entry for prefix {} on dpn {} vpn {} removed successfully", ipAddress, dpnId, vpnId);
}
Aggregations