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.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.resolver.validator.ValidationResult;
+import org.opendaylight.groupbasedpolicy.resolver.validator.ValidationResultBuilder;
+import org.opendaylight.groupbasedpolicy.util.DataStoreHelper;
import org.opendaylight.sfc.provider.api.SfcProviderRenderedPathAPI;
import org.opendaylight.sfc.provider.api.SfcProviderServiceChainAPI;
import org.opendaylight.sfc.provider.api.SfcProviderServicePathAPI;
if (params != null) {
LOG.debug("updateAction: Searching for named chain");
for (String name : params.keySet()) {
- if (name instanceof String) {
if (name.equals(ChainActionDefinition.SFC_CHAIN_NAME)) {
chainName = (String) params.get(name);
if (chainName == null) {
return null;
}
}
- }
}
} else {
LOG.error("updateAction: Parameters null for chain action");
}
@Override
- public boolean isValid(ActionInstance actionInstance) {
+ public ValidationResult validate(ActionInstance actionInstance) {
return isValidGbpChain(actionInstance.getParameterValue());
}
- private boolean isValidGbpChain(List<ParameterValue> paramValue) {
+ private ValidationResult isValidGbpChain(List<ParameterValue> paramValue) {
ParameterValue pv = getChainNameParameter(paramValue);
if (pv == null) {
- return false;
+ return new ValidationResultBuilder().failed().setMessage(
+ "Chain parameter {" + paramValue + "} not found!").build();
}
SfcName sfcName = new SfcName(pv.getStringValue());
LOG.trace("isValidGbpChain: Invoking RPC for chain {}", pv.getStringValue());
ServiceFunctionChain chain = SfcProviderServiceChainAPI.readServiceFunctionChain(sfcName);
- return (chain != null);
+ if (chain != null){
+ return new ValidationResultBuilder().success().build();
+ } else {
+ return new ValidationResultBuilder().failed().setMessage(
+ "Chain named {" + pv.getStringValue() + "} not found in config DS.").build();
+ }
}
public ServiceFunctionPath getSfcPath(SfcName chainName) {