public IntentBuilder(Intent base) { if (base.getKey() == null) { this._key = new IntentKey( base.getId() ); this._id = base.getId(); } else { this._key = base.getKey(); this._id = _key.getId(); } this._actions = base.getActions(); this._conditions = base.getConditions(); this._constraints = base.getConstraints(); this._detailedStatusMessage = base.getDetailedStatusMessage(); this._status = base.getStatus(); this._subjects = base.getSubjects(); if (base instanceof IntentImpl) { IntentImpl impl = (IntentImpl) base; if (!impl.augmentation.isEmpty()) { this.augmentation = new HashMap<>(impl.augmentation); } } else if (base instanceof AugmentationHolder) { @SuppressWarnings("unchecked") AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.intent.rev150122.intents.Intent> casted =(AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.intent.rev150122.intents.Intent>) base; if (!casted.augmentations().isEmpty()) { this.augmentation = new HashMap<>(casted.augmentations()); } } }
private boolean verifyIntent() { if (intent.getId() == null) { LOG.warn("Intent ID is not specified {}", intent); return false; } if (intent.getActions() == null || intent.getActions().size() > NUM_OF_SUPPORTED_ACTION) { LOG.warn("Intent's action is either null or there is more than {} action {}" , NUM_OF_SUPPORTED_ACTION, intent); return false; } if (intent.getSubjects() == null || intent.getSubjects().size() > NUM_OF_SUPPORTED_EPG) { LOG.warn("Intent's subjects is either null or there is more than {} subjects {}" , NUM_OF_SUPPORTED_EPG, intent); return false; } return true; }
/** * To get the action from the intent. * * @return action type. */ private String getAction(Intent intent) { Action action = intent.getActions().get(0).getAction(); String actionType = null; if (action instanceof Allow) { actionType = "allow"; } else if (action instanceof Block) { actionType = "block"; } else { throw new IntentElementNotFoundException("VTN Renderer supports only allow or block: {}" + intent.getId()); } return actionType; } }
@Deprecated @Override protected String createFlowName() { StringBuilder sb = new StringBuilder(); sb.append(OFRendererConstants.INTENT_L2_FLOW_NAME); sb.append(endPointGroups.get(OFRendererConstants.SRC_END_POINT_GROUP_INDEX)); sb.append(endPointGroups.get(OFRendererConstants.DST_END_POINT_GROUP_INDEX)); sb.append(intent.getId().getValue()); return sb.toString(); }
public static BandwidthOnDemandParameters parseBandwidthOnDemand(Intent intent) { List<Actions> actions = intent.getActions(); Action action = !actions.isEmpty() ? actions.get(0).getAction() : null; return input.getOrder(); }).immutableSortedCopy(intent.getSubjects()); for (Constraints c : intent.getConstraints()) { if (c.getConstraints() instanceof BandwidthConstraint) { constraint = (BandwidthConstraint) c.getConstraints(); List<Conditions> conditions = intent.getConditions(); Daily condition = null; for (Conditions c : conditions) {
EndPointGroup sourceContainer = (EndPointGroup) intent.getSubjects().get(0).getSubject(); EndPointGroup destinationContainer = (EndPointGroup) intent.getSubjects().get(1).getSubject(); org.opendaylight.yang.gen.v1.urn.opendaylight.intent.rev150122.intent.actions.Action actionContainer = (org.opendaylight.yang.gen.v1.urn.opendaylight.intent.rev150122.intent.actions.Action) intent.getActions().get(0).getAction(); Set<Endpoint> sources; Set<Endpoint> destinations;
if (dao instanceof Intent) { Intent intent = (Intent) dao; LOG.trace("A new intent is created: {}", intent.getId()); intentParser(intent); if (dao instanceof Intent) { Intent intent = (Intent) dao; LOG.trace("An intent is updated: {}", intent.getId()); intentParser(intent); if (originalDataObject.get(instanceIdentifier) instanceof Intent) { Intent lclIntent = (Intent) originalDataObject.get(instanceIdentifier); IntentKey lclIntentKey = lclIntent.getKey(); Uuid uuid = lclIntentKey.getId(); LOG.trace(" Intent Deleted :{} ", uuid.getValue());
private Contract getDefaultContract() { ContractBuilder contractBuilder = new ContractBuilder().setId(new ContractId(this.contractId)); Subject subject = null; Action action = intent.getActions().get(0).getAction(); if (action instanceof Block) { subject = this.getBlockSubject(); } else if (action instanceof Allow) { subject = this.getAllowSubject(); } else { LOG.warn("The specified action is not recognized {}", action); } List<SubjectName> subjectNames = new ArrayList<>(); subjectNames.add(subject.getName()); contractBuilder.setSubject(ImmutableList.of(subject)); contractBuilder.setClause(ImmutableList.of(new ClauseBuilder() .setName(new ClauseName(DEFAULT_CONTRACT)) .setSubjectRefs(subjectNames) .build())); return contractBuilder.build(); }
if (intent.getSubjects().size() == NUM_OF_SUPPORTED_EPG) { List<Subjects> subjects = intent.getSubjects();
private void pushFlowsByPortNumber(final NodeId nodeId, final FlowAction flowAction) { for (Constraints cons : intent.getConstraints()) { /** * Code block for security rules flow matches */ if(cons.getConstraints() instanceof ClassificationConstraint) { ClassificationConstraint portConstraint = (ClassificationConstraint) cons.getConstraints(); pushPortFlows(portConstraint, nodeId, flowAction); } } }
/** * * @param intent * @return true if the intent create/update was successful * @throws InterruptedException * @throws ExecutionException */ @VisibleForTesting boolean createOrUpdateIntent(Intent intent) throws InterruptedException, ExecutionException { return executeNemoRpc(getUserId(intent.getKey()), new NemoUpdate(intent)); }
sb.append(String.format("Intent Id: <%s>\n", intent.getId().getValue())); sb.append(String.format("Subjects: \n")); for (Subjects subjects : intent.getSubjects()) { EndPointGroup endPointGroup = (EndPointGroup) subjects.getSubject(); sb.append(String.format(" Order: %d\n", subjects.getOrder())); for (Actions actions : intent.getActions()) { Action action = actions.getAction(); sb.append(String.format(" Order: %d\n", actions.getOrder()));
@Override protected Object doExecute() throws Exception { List<Intent> listIntents = provider.listIntents(isConfigurationData); if (listIntents.size() > 0) { StringBuilder sb = new StringBuilder(); Integer counter = 1; for (Intent intent : listIntents) { sb.append(String.format("#%d - id: %s\n", counter, intent.getId().getValue())); counter++; } return sb.toString(); } else { return String.format("No intents found. Check the logs for more details."); } } }
/** * To set the ingress and egress data to redirect cache * @param intent :intent */ private void addSfcNodeInfoToCache(Intent intent) { String intentId = intent.getId().getValue(); RedirectNodeData redirectNodeData = redirectNodeCache.get(intentId); if (redirectNodeData == null) { addIntentToCache(intent); redirectNodeData = redirectNodeCache.get(intentId); } Redirect actionContainer = (Redirect) intent.getActions().get(0).getAction(); org.opendaylight.yang.gen.v1.urn.opendaylight.intent.rev150122.intent.actions.action.redirect.Redirect redirectForService = actionContainer.getRedirect(); String serviceName = redirectForService.getServiceName(); String[] redirectSfcDataList = readRedirectSfcData(serviceName); redirectNodeData.setIngressNodeId(redirectSfcDataList[0]); redirectNodeData.setEgressNodeId(redirectSfcDataList[1]); deleteArpFlow(new NodeId(extractTopologyNodeId(redirectSfcDataList[0]).getValue())); deleteArpFlow(new NodeId(extractTopologyNodeId(redirectSfcDataList[1]).getValue())); }
@Override public void execute(final Intent intent, final FlowAction flowAction) { try { final Action actionContainer = IntentUtils.getAction(intent); final List<String> endPointGroups = IntentUtils.extractEndPointGroup(intent); final Map<String, Map<String, String>> subjectDetails = MappingServiceUtils.extractSubjectDetails(intent, intentMappingService); mplsIntentFlowManager.setEndPointGroups(endPointGroups); mplsIntentFlowManager.setAction(actionContainer); mplsIntentFlowManager.setSubjectsMapping(subjectDetails); if (intent.getConstraints() != null) { for (Constraints constraints : intent.getConstraints()) { generateMplsFlows(intent, flowAction, constraints); } } } catch (IntentElementNotFoundException | IntentInvalidException ie) { //TODO: Perform fail over LOG.error(ie.getMessage()); } }
public IntentBuilder(Intent base) { if (base.getKey() == null) { this._key = new IntentKey( base.getId() ); this._id = base.getId(); } else { this._key = base.getKey(); this._id = _key.getId(); this._actions = base.getActions(); this._conditions = base.getConditions(); this._constraints = base.getConstraints(); this._detailedStatusMessage = base.getDetailedStatusMessage(); this._qosConfig = base.getQosConfig(); this._state = base.getState(); this._status = base.getStatus(); this._subjects = base.getSubjects(); if (base instanceof IntentImpl) { IntentImpl impl = (IntentImpl) base;
/** * To set the redirect intent data * @param intent :intent */ private void addIntentToCache(Intent intent) { RedirectNodeData redirectNodeData; String intentId = intent.getId().getValue(); if (redirectNodeCache.get(intentId) == null) { redirectNodeData = new RedirectNodeData(); redirectNodeData.setIntent(intent); redirectNodeCache.put(intentId, redirectNodeData); } else { redirectNodeData = redirectNodeCache.get(intentId); redirectNodeData.setIntent(intent); } }
/** * Checks the Constraint name is present in the constraint container. * @param intent Intent * @param actionContainer Action * @param endPointGroups List of Endpoints * @return boolean */ private boolean checkQosConstraint(final Intent intent, final Action actionContainer, final List<String> endPointGroups) { //Check for constrain name in the intent. final org.opendaylight.yang.gen.v1.urn.opendaylight.intent.rev150122.intent.constraints.Constraints constraintContainer = intent.getConstraints().get(0).getConstraints(); if (!constraintContainer.getImplementedInterface().isAssignableFrom(QosConstraint.class)) { return false; } final String qosName = ((QosConstraint)constraintContainer).getQosConstraint().getQosName(); LOG.info("QosConstraint is set to: {}", qosName); if (qosName != null) { //Set the values to QosConstraintManager qosConstraintManager.setQosName(qosName); qosConstraintManager.setEndPointGroups(endPointGroups); qosConstraintManager.setAction(actionContainer); qosConstraintManager.setConstraint(constraintContainer); } else { LOG.trace("QoS Name is not set"); return false; } return true; }
if (!Objects.equals(_actions, other.getActions())) { return false; if (!Objects.equals(_conditions, other.getConditions())) { return false; if (!Objects.equals(_constraints, other.getConstraints())) { return false; if (!Objects.equals(_detailedStatusMessage, other.getDetailedStatusMessage())) { return false; if (!Objects.equals(_id, other.getId())) { return false; if (!Objects.equals(_key, other.getKey())) { return false; if (!Objects.equals(_qosConfig, other.getQosConfig())) { return false; if (!Objects.equals(_state, other.getState())) { return false; if (!Objects.equals(_status, other.getStatus())) { return false; if (!Objects.equals(_subjects, other.getSubjects())) { return false;
@Override public void execute(IntentUpdated event) { final Intent intent = event.getIntent(); stateMachineExecutorService.removeTransactions(intent.getId(), EventType.INTENT_UPDATE); stateMachineExecutorService.createTransaction(intent, EventType.INTENT_UPDATE); } };