use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project netvirt by opendaylight.
the class ElanServiceChainHandler method programElanScfPipeline.
/**
* Programs the needed flows for sending traffic to the SCF pipeline when
* it is comming from an L2-GW (ELAN) and also for handing over that
* traffic from SCF to ELAN when the packets does not match any Service
* Chain.
*
* @param elanName Name of the ELAN to be considered
* @param tableId Table id, in the SCF Pipeline, to which the traffic must
* go to.
* @param scfTag Tag of the ServiceChain
* @param elanLportTag LPortTag of the ElanPseudoPort that participates in
* the ServiceChain
* @param addOrRemove States if the flows must be created or removed
*/
public void programElanScfPipeline(String elanName, short tableId, long scfTag, int elanLportTag, int addOrRemove) {
LOG.info("programElanScfPipeline: elanName={} scfTag={} elanLportTag={} addOrRemove={}", elanName, scfTag, elanLportTag, addOrRemove);
// There are 3 rules to be considered:
// 1. LportDispatcher To Scf. Matches on elanPseudoPort + SI=1. Goes to DL Subscriber table
// 2. LportDispatcher From Scf. Matches on elanPseudoPort + SI=3. Goes to ELAN DMAC
// 3. ExtTunnelTable From L2GwDevice. Matches on VNI + SI=1. Sets ElanPseudoPort tag and goes
// to LportDispatcher table.
// And these rules must be programmed in all the Elan footprint
// Find the ElanInstance
Optional<ElanInstance> elanInstance = ElanServiceChainUtils.getElanInstanceByName(broker, elanName);
if (!elanInstance.isPresent()) {
LOG.debug("Could not find an Elan Instance with name={}", elanName);
return;
}
Collection<BigInteger> elanDpnsOpc = ElanServiceChainUtils.getElanDpnsByName(broker, elanName);
if (elanDpnsOpc.isEmpty()) {
LOG.debug("Could not find any DPN related to Elan {}", elanName);
return;
}
// updates map which stores relationship between elan and elanLPortTag and scfTag
ElanServiceChainUtils.updateElanToLportTagMap(broker, elanName, elanLportTag, scfTag, addOrRemove);
Long vni = elanInstance.get().getSegmentationId();
if (vni == null) {
LOG.warn("There is no VNI for elan {}. VNI is mandatory. Returning", elanName);
return;
}
int elanTag = elanInstance.get().getElanTag().intValue();
LOG.debug("elanName={} -> vni={} elanTag={}", elanName, vni, elanTag);
// Program ExtTunnelTable.
for (BigInteger dpnId : elanDpnsOpc) {
ElanServiceChainUtils.programLPortDispatcherToScf(mdsalManager, dpnId, elanTag, elanLportTag, tableId, scfTag, addOrRemove);
ElanServiceChainUtils.programLPortDispatcherFromScf(mdsalManager, dpnId, elanLportTag, elanTag, addOrRemove);
ElanServiceChainUtils.programExternalTunnelTable(mdsalManager, dpnId, elanLportTag, vni, elanTag, addOrRemove);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project netvirt by opendaylight.
the class QosInterfaceStateChangeListener method getNeutronPortForRemove.
private Optional<Port> getNeutronPortForRemove(Interface intrf) {
final String portName = intrf.getName();
Optional<Uuid> uuid = uuidUtil.newUuidIfValidPattern(portName);
if (uuid.isPresent()) {
Port port = neutronVpnManager.getNeutronPort(portName);
if (port != null) {
return Optional.fromJavaUtil(uuid.toJavaUtil().map(neutronVpnManager::getNeutronPort));
}
LOG.trace("Qos Service : interface {} clearing stale flow entries if any", portName);
qosNeutronUtils.removeStaleFlowEntry(intrf);
}
return Optional.absent();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project netvirt by opendaylight.
the class QosNeutronUtils method setPortDscpMarking.
public void setPortDscpMarking(Port port, DscpmarkingRules dscpMark) {
if (!qosEosHandler.isQosClusterOwner()) {
LOG.trace("Not Qos Cluster Owner. Ignoring setting DSCP marking");
return;
}
LOG.trace("Setting DSCP value {} on Port {}", port, dscpMark);
BigInteger dpnId = getDpnForInterface(port.getUuid().getValue());
String ifName = port.getUuid().getValue();
IpAddress ipAddress = port.getFixedIps().get(0).getIpAddress();
Short dscpValue = dscpMark.getDscpMark();
if (dpnId.equals(BigInteger.ZERO)) {
LOG.info("DPN ID for interface {} not found", port.getUuid().getValue());
return;
}
// 1. OF rules
addFlow(dpnId, dscpValue, ifName, ipAddress, getInterfaceStateFromOperDS(ifName));
if (qosServiceConfiguredPorts.add(port.getUuid())) {
// bind qos service to interface
bindservice(ifName);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project netvirt by opendaylight.
the class GeniusProvider method getDpnIdFromInterfaceName.
public Optional<DpnIdType> getDpnIdFromInterfaceName(String interfaceName) {
LOG.debug("getDpnIdFromInterfaceName: starting (logical interface={})", interfaceName);
GetDpidFromInterfaceInputBuilder builder = new GetDpidFromInterfaceInputBuilder();
builder.setIntfName(interfaceName);
GetDpidFromInterfaceInput input = builder.build();
if (interfaceManagerRpcService == null) {
LOG.error("getDpnIdFromInterfaceName({}) failed (service couldn't be retrieved)", input);
return Optional.empty();
}
try {
LOG.debug("getDpnIdFromInterfaceName: invoking rpc");
RpcResult<GetDpidFromInterfaceOutput> output = interfaceManagerRpcService.getDpidFromInterface(input).get();
if (!output.isSuccessful()) {
LOG.error("getDpnIdFromInterfaceName({}) failed: {}", input, output);
return Optional.empty();
}
BigInteger dpnId = output.getResult().getDpid();
if (dpnId == null) {
return Optional.empty();
}
LOG.debug("getDpnIdFromInterfaceName({}) succeeded: {}", input, output);
return Optional.of(new DpnIdType(dpnId));
} catch (InterruptedException | ExecutionException e) {
LOG.error("getDpnIdFromInterfaceName failed to retrieve target interface name: ", e);
}
return Optional.empty();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.Service in project netvirt by opendaylight.
the class GeniusProvider method getNodeConnectorIdFromInterfaceName.
public Optional<String> getNodeConnectorIdFromInterfaceName(String interfaceName) {
LOG.debug("getDpnIdFromInterfaceName: starting (logical interface={})", interfaceName);
GetNodeconnectorIdFromInterfaceInputBuilder builder = new GetNodeconnectorIdFromInterfaceInputBuilder();
builder.setIntfName(interfaceName);
GetNodeconnectorIdFromInterfaceInput input = builder.build();
if (interfaceManagerRpcService == null) {
LOG.error("getNodeConnectorIdFromInterfaceName({}) failed (service couldn't be retrieved)", input);
return Optional.empty();
}
try {
LOG.debug("getNodeConnectorIdFromInterfaceName: invoking rpc");
RpcResult<GetNodeconnectorIdFromInterfaceOutput> output = interfaceManagerRpcService.getNodeconnectorIdFromInterface(input).get();
if (!output.isSuccessful()) {
LOG.error("getNodeConnectorIdFromInterfaceName({}) failed: {}", input, output);
return Optional.empty();
}
NodeConnectorId nodeConnId = output.getResult().getNodeconnectorId();
if (nodeConnId == null) {
return Optional.empty();
}
LOG.debug("getNodeConnectorIdFromInterfaceName({}) succeeded: {}", input, output);
return Optional.ofNullable(nodeConnId.getValue());
} catch (InterruptedException | ExecutionException e) {
LOG.error("getNodeConnectorIdFromInterfaceName failed to retrieve target interface name: ", e);
}
return Optional.empty();
}
Aggregations