/** * Record a log message that indicates the VTN has been created or removed. * * @param vtn A {@link Vtn} instance. * @param type {@link VtnUpdateType#CREATED} on created. * {@link VtnUpdateType#REMOVED} on removed. */ private void log(Vtn vtn, VtnUpdateType type) { if (LOG.isInfoEnabled()) { VTenantIdentifier vtnId = new VTenantIdentifier(vtn.getName()); LOG.info("{}: VTN has been {}: value={{}}", vtnId, MiscUtils.toLowerCase(type), toString(vtn.getVtenantConfig())); } }
return false; if (!Objects.equals(_name, other.getName())) { return false;
public VtnBuilder(Vtn base) { if (base.getKey() == null) { this._key = new VtnKey( base.getName() ); this._name = base.getName(); } else { this._key = base.getKey(); this._name = _key.getName(); } this._vbridge = base.getVbridge(); this._vtenantConfig = base.getVtenantConfig(); this._vterminal = base.getVterminal(); this._vtnInputFilter = base.getVtnInputFilter(); this._vtnPathMaps = base.getVtnPathMaps(); if (base instanceof VtnImpl) { VtnImpl impl = (VtnImpl) 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.vtn.rev150328.vtns.Vtn> casted =(AugmentationHolder<org.opendaylight.yang.gen.v1.urn.opendaylight.vtn.rev150328.vtns.Vtn>) base; if (!casted.augmentations().isEmpty()) { this.augmentation = new HashMap<>(casted.augmentations()); } } }
/** * Record the given VTN tree for saving configuration. * * @param ectx A {@link VTenantChange} instance. * @param data A {@link IdentifiedData} instance that contains a * VTN data tree. * @param created {@code true} indicates that the given VTN has been * created. * @return The VTN in {@code data}. */ private Vtn onChanged(VTenantChange ectx, IdentifiedData<?> data, boolean created) { IdentifiedData<Vtn> cdata = cast(data); Vtn vtn = cdata.getValue(); String name = vtn.getName().getValue(); ectx.addUpdatedVtn(name, vtn, created); return vtn; }
/** * {@inheritDoc} */ @Override void onRemoved(VTenantChange ectx, IdentifiedData<?> data) { IdentifiedData<Vtn> cdata = cast(data); Vtn vtn = cdata.getValue(); String name = vtn.getName().getValue(); ectx.addRemoved(name); log(vtn, VtnUpdateType.REMOVED); }
/** * Called when a test suite quits. * * @throws Exception An error occurred. */ @After public void tearDown() throws Exception { // Remove all global path maps. clearPathMap(pathMapService, null); // Remove all flow conditions. getRpcOutput(flowCondService.clearFlowCondition()); // Remove all path policies. getRpcOutput(pathPolicyService.clearPathPolicy()); // Remove all VTNs. for (Vtn vtn: getVtns(this)) { removeVtn(vtnService, vtn.getName().getValue()); } }
/** * Scan all the virtual nodes in the specified VTN. * * @param ctx A runtime context for transaction task. * @param vtn A {@link Vtn} instance. * @param data An arbitrary data to be passed to virtual nodes. * @throws VTNException An error occurred. */ private void scan(TxContext ctx, Vtn vtn, T data) throws VTNException { VnodeName tname = vtn.getName(); List<Vbridge> vbridges = vtn.getVbridge(); if (vbridges != null) { for (Vbridge vbridge: vbridges) { VnodeName bname = vbridge.getName(); VBridgeIdentifier vbrId = new VBridgeIdentifier(tname, bname); scan(ctx, new VBridge(vbrId, vbridge), data); } } List<Vterminal> vterminals = vtn.getVterminal(); if (vterminals != null) { for (Vterminal vterm: vterminals) { VnodeName bname = vterm.getName(); VTerminalIdentifier vtmId = new VTerminalIdentifier(tname, bname); scan(ctx, new VTerminal(vtmId, vterm), data); } } } }