import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.groupbasedpolicy.sf.actions.ChainActionDefinition;
-import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.OfWriter;
import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.OfContext;
+import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.OfWriter;
import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.PolicyEnforcer.NetworkElements;
import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.flow.PolicyEnforcer.PolicyPair;
import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.sfcutils.SfcIidFactory;
import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.sfcutils.SfcNshHeader;
import org.opendaylight.groupbasedpolicy.renderer.ofoverlay.sfcutils.SfcNshHeader.SfcNshHeaderBuilder;
+import org.opendaylight.groupbasedpolicy.sf.actions.ChainActionDefinition;
import org.opendaylight.groupbasedpolicy.util.DataStoreHelper;
import org.opendaylight.sfc.provider.api.SfcProviderRenderedPathAPI;
import org.opendaylight.sfc.provider.api.SfcProviderServiceChainAPI;
LOG.error("updateAction: SFC Path was invalid. Either null or name was null.", sfcPath);
return null;
}
+ // TODO Need helper function to get getTenantName() that returns Name or UUID if Name is
+ // null
+
+ String tenantName = netElements.getSrcEp().getTenant().getValue();
// Find existing RSP based on following naming convention, else create it.
- RspName rspName = new RspName(sfcPath.getName() + "-gbp-rsp");
+ RspName rspName = new RspName(sfcPath.getName().getValue() + tenantName + "-gbp-rsp");
ReadOnlyTransaction rTx = ctx.getDataBroker().newReadOnlyTransaction();
RenderedServicePath renderedServicePath;
RenderedServicePath rsp = getRspByName(rspName, rTx);
}
try {
- if (sfcPath.isSymmetric() && direction.equals(Direction.Out)){
+ if (sfcPath.isSymmetric() && direction.equals(Direction.Out)) {
rspName = new RspName(rspName.getValue() + "-Reverse");
rsp = getRspByName(rspName, rTx);
if (rsp == null) {
}
}
} catch (Exception e) {
- LOG.error("updateAction: Attemping to determine if srcEp {} was consumer.", netElements.getSrcEp().getKey(), e);
+ LOG.error("updateAction: Attemping to determine if srcEp {} was consumer.", netElements.getSrcEp().getKey(),
+ e);
return null;
}
return null;
}
- NodeId tunnelDestNodeId=netElements.getDstNodeId();
+ NodeId tunnelDestNodeId = netElements.getDstNodeId();
Long returnVnid = (long) netElements.getSrcEpOrds().getTunnelId();
}
private RenderedServicePath createRsp(ServiceFunctionPath sfcPath, RspName rspName) {
- CreateRenderedPathInput rspInput = new CreateRenderedPathInputBuilder().setParentServiceFunctionPath(
- sfcPath.getName().getValue())
- .setName(rspName.getValue())
- .setSymmetric(sfcPath.isSymmetric())
- .build();
- return SfcProviderRenderedPathAPI.createRenderedServicePathAndState(sfcPath, rspInput);
+ CreateRenderedPathInput rspInput =
+ new CreateRenderedPathInputBuilder().setParentServiceFunctionPath(sfcPath.getName().getValue())
+ .setName(rspName.getValue())
+ .setSymmetric(sfcPath.isSymmetric())
+ .build();
+ return SfcProviderRenderedPathAPI.createRenderedServicePathAndState(sfcPath, rspInput);
}
private RenderedServicePath createSymmetricRsp(RenderedServicePath rsp) {
}
private RenderedServicePath getRspByName(RspName rspName, ReadOnlyTransaction rTx) {
- Optional<RenderedServicePath> optRsp = DataStoreHelper.readFromDs(LogicalDatastoreType.OPERATIONAL,
- SfcIidFactory.rspIid(rspName), rTx);
+ Optional<RenderedServicePath> optRsp =
+ DataStoreHelper.readFromDs(LogicalDatastoreType.OPERATIONAL, SfcIidFactory.rspIid(rspName), rTx);
if (optRsp.isPresent()) {
return optRsp.get();
}
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePath;
import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.HasDirection.Direction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.subject.feature.instances.ActionInstance;
private PolicyPair policyPair;
private EndpointManager endpointManager;
private EgKey egKey;
+ private TenantId tenant = new TenantId("e09a2308-6ffa-40af-92a2-69f54b2cf3e4");
@SuppressWarnings("unchecked")
@Before
when(netElements.getSrcEpOrds()).thenReturn(endpointFwdCtxOrdinals);
endpoint = mock(Endpoint.class);
when(netElements.getSrcEp()).thenReturn(endpoint);
+ when(netElements.getSrcEp().getTenant()).thenReturn(tenant);
policyPair = mock(PolicyPair.class);
when(policyPair.getConsumerEpgId()).thenReturn(Integer.valueOf(5));
doReturn(sfcPath).when(chainAction).getSfcPath(new SfcName(chainName));
- List<ActionBuilder> result = chainAction.updateAction(actions, params, order, netElements, policyPair,
- ofWriter,
- ctx, Direction.Out);
+ List<ActionBuilder> result =
+ chainAction.updateAction(actions, params, order, netElements, policyPair, ofWriter, ctx, Direction.Out);
Assert.assertNull(result);
}
Integer order = Integer.valueOf(0);
OfWriter ofWriter = mock(OfWriter.class);
- List<ActionBuilder> result = chainAction.updateAction(actions, null, order, netElements, policyPair,
- ofWriter,
- ctx, Direction.In);
+ List<ActionBuilder> result =
+ chainAction.updateAction(actions, null, order, netElements, policyPair, ofWriter, ctx, Direction.In);
Assert.assertNull(result);
}
doReturn(sfcPath).when(chainAction).getSfcPath(new SfcName(chainName));
when(sfcPath.getName()).thenReturn(null);
- List<ActionBuilder> result = chainAction.updateAction(actions, params, order, netElements, policyPair,
- ofWriter,
- ctx, Direction.Out);
+ List<ActionBuilder> result =
+ chainAction.updateAction(actions, params, order, netElements, policyPair, ofWriter, ctx, Direction.Out);
Assert.assertNull(result);
}
- @Test
+ @Test
public void isValidTestParameterValueNull() {
- ActionInstance actionInstance = mock(ActionInstance.class);
- Assert.assertFalse(chainAction.isValid(actionInstance));
+ ActionInstance actionInstance = mock(ActionInstance.class);
+ Assert.assertFalse(chainAction.isValid(actionInstance));
}
}