public Intent build() { return new IntentImpl(this); }
public IntentBuilder addAugmentation(java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.intent.rev150122.intents.Intent>> augmentationType, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.intent.rev150122.intents.Intent> augmentation) { if (augmentation == null) { return removeAugmentation(augmentationType); } if (!(this.augmentation instanceof HashMap)) { this.augmentation = new HashMap<>(); } this.augmentation.put(augmentationType, augmentation); return this; }
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 IntentImpl(IntentBuilder 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(); switch (base.augmentation.size()) { case 0: this.augmentation = Collections.emptyMap(); break; case 1: final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.intent.rev150122.intents.Intent>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.intent.rev150122.intents.Intent>> e = base.augmentation.entrySet().iterator().next(); this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.intent.rev150122.intents.Intent>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.intent.rev150122.intents.Intent>>singletonMap(e.getKey(), e.getValue()); break; default : this.augmentation = new HashMap<>(base.augmentation); } }
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; }
/** * Put an operational information of an intent into the OPERATIONAL data store. * * @param intent The intent to be added into the OPERATIONAL data store. * @param status The intent status. * * @return {@code true} if the intent is added successfully. */ public boolean addIntent(Intent intent, Status status) { MdsalUtils mdsal = new MdsalUtils(dataBroker); InstanceIdentifier<Intent> identifier = InstanceIdentifier.builder(Intents.class) .child(Intent.class, new IntentKey(intent.getId())) .build(); Intent operationalIntent = new IntentBuilder(intent).setStatus(status).build(); return mdsal.put(LogicalDatastoreType.OPERATIONAL, identifier, operationalIntent); }
/** * 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; } }
/** * Delete an intent information from the OPERATIONAL data store. * * @param intent The intent to be deleted from the OPERATIONAL data store. * * @return {@code true} if the intent is deleted successfully. */ public boolean deleteIntent(Intent intent) { MdsalUtils mdsal = new MdsalUtils(dataBroker); InstanceIdentifier<Intent> identifier = InstanceIdentifier.builder(Intents.class) .child(Intent.class, new IntentKey(intent.getId())) .build(); return mdsal.delete(LogicalDatastoreType.OPERATIONAL, identifier); }
@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 void removeIntent(Uuid id) { try { InstanceIdentifier<Intent> iid = InstanceIdentifier.create(Intents.class) .child(Intent.class, new IntentKey(id)); // Removes default config data in data store tree WriteTransaction tx = dataBroker.newWriteOnlyTransaction(); tx.delete(LogicalDatastoreType.CONFIGURATION, iid); // Perform the tx.submit synchronously tx.submit(); } catch (Exception e) { LOG.info("RemoveIntent: failed: {}", e); } }
/** * * @param intentKey * @return the user that created this intent */ private static UserId getUserId(IntentKey intentKey) { // for this release, assume userId to be the same as the NIC intent ID return new UserId(intentKey.getId().getValue()); }
/** * * @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)); }
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); } } }
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;
private IntentImpl(IntentBuilder 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(); switch (base.augmentation.size()) { case 0: this.augmentation = Collections.emptyMap(); break; case 1: final Map.Entry<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.intent.rev150122.intents.Intent>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.intent.rev150122.intents.Intent>> e = base.augmentation.entrySet().iterator().next(); this.augmentation = Collections.<java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.intent.rev150122.intents.Intent>>, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.intent.rev150122.intents.Intent>>singletonMap(e.getKey(), e.getValue()); break; default : this.augmentation = new HashMap<>(base.augmentation); } }
@Override public void execute(IntentUpdated event) { final Intent intent = event.getIntent(); stateMachineExecutorService.removeTransactions(intent.getId(), EventType.INTENT_UPDATE); stateMachineExecutorService.createTransaction(intent, EventType.INTENT_UPDATE); } };
@Override public boolean removeIntent(Uuid id) { try { InstanceIdentifier<Intent> iid = InstanceIdentifier .create(Intents.class).child(Intent.class, new IntentKey(id)); // Removes default config data in data store tree WriteTransaction tx = dataBroker.newWriteOnlyTransaction(); tx.delete(LogicalDatastoreType.CONFIGURATION, iid); // Perform the tx.submit synchronously tx.submit(); } catch (Exception e) { LOG.info("RemoveIntent: failed: {}", e); return false; } return true; }
public Intent build() { return new IntentImpl(this); }
public IntentBuilder addAugmentation(java.lang.Class<? extends Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.intent.rev150122.intents.Intent>> augmentationType, Augmentation<org.opendaylight.yang.gen.v1.urn.opendaylight.intent.rev150122.intents.Intent> augmentation) { if (augmentation == null) { return removeAugmentation(augmentationType); } if (!(this.augmentation instanceof HashMap)) { this.augmentation = new HashMap<>(); } this.augmentation.put(augmentationType, augmentation); return this; }
/** * 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); } }