@VisibleForTesting void createAllowActionInstanceIfNotExists(TenantId tenantId, ReadWriteTransaction rwTx) { InstanceIdentifier<ActionInstance> actionInstanceIid = IidFactory.actionInstanceIid(tenantId, MappingUtils.ACTION_ALLOW.getName()); if (!createdActionInstances.contains(actionInstanceIid)) { rwTx.put(LogicalDatastoreType.CONFIGURATION, actionInstanceIid, MappingUtils.ACTION_ALLOW, true); } createdActionInstances.add(actionInstanceIid); }
@Override public ValidationResult validate(ActionInstance actionInstance) { return isValidGbpChain(actionInstance.getParameterValue()); }
LOG.warn("Action instance {} is not found -- will only use the Action ref info", actionRef.getName()); } else { if (actionInstance.getActionDefinitionId() != null) { ruleActionBuilder.setAdditionalInfo(new Text(actionInstance.getActionDefinitionId().getValue())); if (actionInstance.getParameterValue() != null) { LOG.trace("Action Instance {} has {} parameters", actionInstance.getName().getValue(), actionInstance.getParameterValue().size()); parms = new ArrayList<>(); for (org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.ParameterValue instance : actionInstance.getParameterValue()) { ParameterValueBuilder pBuilder = new ParameterValueBuilder(); pBuilder.setIntValue(instance.getIntValue()); LOG.trace("Added Parm {} from Action Instance {}", parm, actionInstance.getName().getValue()); parms.add(parm); LOG.trace("Action Instance {} has no parameters", actionInstance.getName().getValue());
return null; Action action = SubjectFeatures.getAction(actionInstance.getActionDefinitionId()); if (action == null) { LOG.warn("Action definition {} not found", actionInstance.getActionDefinitionId().getValue()); return null; if (actionInstance.getParameterValue() != null) { for (ParameterValue v : actionInstance.getParameterValue()) { if (v.getName() == null) continue;
public MatchActionDefTask(ActionInstance actionInstance, ActionInstance originalInstance, ActionState state) { this.actionInstance = actionInstance; this.originalInstance = originalInstance; if (actionInstance != null) { this.id = actionInstance.getActionDefinitionId(); } else { this.id = null; } this.state = state; adIid = InstanceIdentifier.builder(SubjectFeatureDefinitions.class) .child(ActionDefinition.class, new ActionDefinitionKey(this.id)) .build(); }
continue; Action action = SubjectFeatures.getAction(actionInstance.getActionDefinitionId()); if (action == null) { continue; continue; Action oppositeAction = SubjectFeatures.getAction(oppositeActionInstance.getActionDefinitionId()); if (oppositeAction == null) { continue;
private ParameterValue getChainNameParameter(List<ParameterValue> pvl) { if (pvl == null) return null; for (ParameterValue pv: actionInstance.getParameterValue()) { if (pv.getName().getValue().equals(SFC_CHAIN_NAME)) { return pv; } } return null; }
public static RuleName getRuleName(SecurityRule secRule) { ClassifierName classifierRefName = SecRuleNameDecoder.getClassifierRefName(secRule); String ruleName = new StringBuilder(MappingUtils.ACTION_ALLOW.getName().getValue()) .append(MappingUtils.NAME_DOUBLE_DELIMETER).append(classifierRefName.getValue()).toString(); return new RuleName(ruleName); }
private void deleteSfcRsp() { ParameterValue pv = getChainNameParameter(originalInstance.getParameterValue()); if (pv == null) return; rspMap.remove(pv.getStringValue()); }
@VisibleForTesting void deleteAllowActionInstanceIfNotUsed(TenantId tenantId, ReadWriteTransaction rwTx) { InstanceIdentifier<ActionInstance> actionInstanceIid = IidFactory.actionInstanceIid(tenantId, MappingUtils.ACTION_ALLOW.getName()); createdActionInstances.remove(actionInstanceIid); if (!createdActionInstances.contains(actionInstanceIid)) { DataStoreHelper.removeIfExists(LogicalDatastoreType.CONFIGURATION, actionInstanceIid, rwTx); } }
private void changeSfcRsp() { ParameterValue newPv = getChainNameParameter(actionInstance.getParameterValue()); ParameterValue origPv = getChainNameParameter(originalInstance.getParameterValue()); if (!newPv.getStringValue().equals(origPv.getStringValue())) { if (rspMap.containsKey(origPv.getStringValue())) { /* * Flow cleanup will happen as part of the * resolved policy * * TODO: can we guarantee that this * happens after we remove the RSP?). */ rspMap.remove(origPv.getStringValue()); } addSfcRsp(); } }
private List<String> getSymetricChainNames(ActionInstance action) { List<String> chainNames = new ArrayList<>(); for (ParameterValue param : action.getParameterValue()) { if (param.getStringValue() != null && param.getName().getValue().equals(ChainActionDefinition.SFC_CHAIN_NAME)) { String chainName = param.getStringValue(); ServiceFunctionPath sfcPath = ChainAction.getSfcPath(new SfcName(chainName)); if (sfcPath == null || sfcPath.getName() == null) { continue; } if (sfcPath.isSymmetric()) { chainNames.add(param.getStringValue()); } } } return chainNames; }
private void getSfcChain() { ParameterValue pv = getChainNameParameter(actionInstance.getParameterValue()); if (pv == null) return; LOG.trace("Invoking RPC for chain {}", pv.getStringValue()); SfcName chainName=new SfcName(pv.getStringValue()); ServiceFunctionChain chain = SfcProviderServiceChainAPI.readServiceFunctionChain(chainName); ServiceFunctionPaths paths = SfcProviderServicePathAPI.readAllServiceFunctionPaths(); for(ServiceFunctionPath path: paths.getServiceFunctionPath()) { if(path.getServiceChainName().equals(chainName)) { LOG.info("Found path {} for chain {}",path.getName(),path.getServiceChainName()); } } } }
getChainNameParameter(actionInstance.getParameterValue()); if (pv == null) return;