@Override public Intent getIntent(Uuid id) { Intent intent = null; try { InstanceIdentifier<Intent> iid = InstanceIdentifier .create(Intents.class).child(Intent.class, new IntentKey(id)); ReadOnlyTransaction tx = dataBroker.newReadOnlyTransaction(); intent = tx.read(LogicalDatastoreType.CONFIGURATION, iid).checkedGet().get(); if (intent == null) { intent = tx.read(LogicalDatastoreType.OPERATIONAL, iid).checkedGet().get(); } } catch (Exception e) { LOG.error("getIntent: failed: {}", e); return null; } LOG.info("getIntent: Intent retrieved sucessfully"); return intent; }
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); } }
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); } }
@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; }
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); } }
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()); } } }
public IntentBuilder(Intent base) { if (base.getKey() == null) { this._key = new IntentKey( base.getId() );
/** * 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); }
/** * 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); }