use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.NeutronNetwork in project netvirt by opendaylight.
the class ConfigurationClassifierImpl method getEntriesForAce.
private Set<ClassifierRenderableEntry> getEntriesForAce(Ace ace) {
String ruleName = ace.getRuleName();
LOG.debug("Generating classifier entries for Ace: {}", ruleName);
LOG.trace("Ace details: {}", ace);
Optional<NetvirtsfcAclActions> sfcActions = Optional.ofNullable(ace.getActions()).map(actions -> actions.getAugmentation(RedirectToSfc.class));
String rspName = sfcActions.map(NetvirtsfcAclActions::getRspName).map(Strings::emptyToNull).orElse(null);
String sfpName = sfcActions.map(NetvirtsfcAclActions::getSfpName).map(Strings::emptyToNull).orElse(null);
if (rspName == null && sfpName == null) {
LOG.debug("Ace {} ignored: no valid SFC redirect action", ruleName);
return Collections.emptySet();
}
if (rspName != null && sfpName != null) {
LOG.warn("Ace {} ignored: both SFP and a RSP as redirect actions not supported", ruleName);
return Collections.emptySet();
}
Matches matches = ace.getMatches();
if (matches == null) {
LOG.warn("Ace {} ignored: no matches", ruleName);
return Collections.emptySet();
}
NeutronNetwork network = matches.getAugmentation(NeutronNetwork.class);
if (sfpName != null && network != null) {
LOG.warn("Ace {} ignored: SFP redirect action with neutron network match not supported", ruleName);
return Collections.emptySet();
}
String sourcePort = Optional.ofNullable(matches.getAugmentation(NeutronPorts.class)).map(NeutronPorts::getSourcePortUuid).map(Strings::emptyToNull).orElse(null);
String destinationPort = Optional.ofNullable(matches.getAugmentation(NeutronPorts.class)).map(NeutronPorts::getDestinationPortUuid).map(Strings::emptyToNull).orElse(null);
if (rspName != null) {
return getEntriesForRspRedirect(ruleName, sourcePort, destinationPort, network, rspName, matches);
}
return getEntriesForSfpRedirect(ruleName, sourcePort, destinationPort, sfpName, matches);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.NeutronNetwork in project netvirt by opendaylight.
the class ConfigurationClassifierImpl method getEntriesForRspRedirect.
private Set<ClassifierRenderableEntry> getEntriesForRspRedirect(String ruleName, String sourcePort, String destinationPort, NeutronNetwork neutronNetwork, String rspName, Matches matches) {
RenderedServicePath rsp = sfcProvider.getRenderedServicePath(rspName).orElse(null);
if (rsp == null) {
LOG.debug("Ace {} ignored: RSP {} not yet available", ruleName, rspName);
return Collections.emptySet();
}
if (destinationPort != null) {
LOG.warn("Ace {}: destination port is ignored combined with RSP redirect");
}
List<String> interfaces = new ArrayList<>();
if (neutronNetwork != null) {
interfaces.addAll(netvirtProvider.getLogicalInterfacesFromNeutronNetwork(neutronNetwork));
}
if (sourcePort != null) {
interfaces.add(sourcePort);
}
if (interfaces.isEmpty()) {
LOG.debug("Ace {} ignored: no interfaces to match against", ruleName);
return Collections.emptySet();
}
return this.buildEntries(ruleName, interfaces, matches, rsp);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.sfc.acl.rev150105.NeutronNetwork in project netvirt by opendaylight.
the class NetvirtProvider method getLogicalInterfacesFromNeutronNetwork.
public List<String> getLogicalInterfacesFromNeutronNetwork(NeutronNetwork nw) {
InstanceIdentifier<NetworkMap> networkMapIdentifier = getNetworkMapIdentifier(new Uuid(nw.getNetworkUuid()));
NetworkMap networkMap = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, networkMapIdentifier).orNull();
if (networkMap == null) {
LOG.warn("getLogicalInterfacesFromNeutronNetwork cant get NetworkMap for NW UUID [{}]", nw.getNetworkUuid());
return Collections.emptyList();
}
List<String> interfaces = new ArrayList<>();
List<Uuid> subnetUuidList = networkMap.getSubnetIdList();
if (subnetUuidList != null) {
for (Uuid subnetUuid : subnetUuidList) {
InstanceIdentifier<Subnetmap> subnetId = getSubnetMapIdentifier(subnetUuid);
Subnetmap subnet = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, subnetId).orNull();
if (subnet == null) {
LOG.warn("getLogicalInterfacesFromNeutronNetwork cant get Subnetmap for NW UUID [{}] Subnet UUID " + "[{}]", nw.getNetworkUuid(), subnetUuid.getValue());
continue;
}
if (subnet.getPortList() == null || subnet.getPortList().isEmpty()) {
LOG.warn("getLogicalInterfacesFromNeutronNetwork No ports on Subnet: NW UUID [{}] Subnet UUID [{}]", nw.getNetworkUuid(), subnetUuid.getValue());
continue;
}
subnet.getPortList().forEach(portId -> interfaces.add(portId.getValue()));
}
}
return interfaces;
}
Aggregations