@Override protected Object doExecute() throws Exception { UUID uuid = UUID.randomUUID(); List<Subjects> subjects = createSubjects(); List<Actions> intentActions = createActions(); Intent intent = new IntentBuilder(). setId(new Uuid(uuid.toString())) .setSubjects(subjects) .setActions(intentActions) .build(); if (provider.addIntent(intent)) { return String.format("Intent created (id: %s)", uuid.toString()); } else { return "Error creating new intent"; } }
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); } }
/** * 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); }
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); } }
String fromString = "any"; String toString = "any"; IntentBuilder intentBuilder = new IntentBuilder(); UUID uuid = UUID.randomUUID(); intentBuilder. setId(new Uuid(uuid.toString())); intentBuilder.setActions(Arrays.asList( new ActionsBuilder().setOrder((short) 1).setAction( new org.opendaylight.yang.gen.v1.urn.opendaylight.intent.rev150122.intent.actions.action intentBuilder.setSubjects(Arrays.asList(from, to)); intentBuilder.setConstraints(Arrays.asList(new ConstraintsBuilder().setOrder((short) 1).setConstraints(constraint).build())); intentBuilder. setId(new Uuid(uuid.toString())); return intentBuilder.build();