import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
+import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.inject.Inject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.RemoveTerminatingServiceActionsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.RemoveTerminatingServiceActionsInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.RemoveTerminatingServiceActionsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagNameKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntryKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.Subnetmaps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
}
}
+ @SuppressWarnings("checkstyle:ForbiddenMethod")
public static <T extends DataObject> void delete(DataBroker broker, LogicalDatastoreType datastoreType,
InstanceIdentifier<T> path) {
WriteTransaction tx = broker.newWriteOnlyTransaction();
Futures.addCallback(tx.submit(), DEFAULT_CALLBACK, MoreExecutors.directExecutor());
}
+ @SuppressWarnings("checkstyle:ForbiddenMethod")
public static <T extends DataObject> void delete(DataBroker broker, LogicalDatastoreType datastoreType,
InstanceIdentifier<T> path, FutureCallback<Void> callback) {
WriteTransaction tx = broker.newWriteOnlyTransaction();
if (etreeInterface == null || etreeInterface.getEtreeInterfaceType() == EtreeInterfaceType.Root) {
return elanInfo.getElanTag();
} else { // Leaf
- EtreeInstance etreeInstance = elanInfo.getAugmentation(EtreeInstance.class);
+ EtreeInstance etreeInstance = elanInfo.augmentation(EtreeInstance.class);
if (etreeInstance == null) {
LOG.warn("EtreeInterface {} is connected to a non-Etree network: {}",
interfaceInfo.getInterfaceName(), elanInfo.getElanInstanceName());
elanTag = retrieveNewElanTag(idManager, elanInstanceName);
}
Elan elanInfo = new ElanBuilder().setName(elanInstanceName).setElanInterfaces(elanInterfaces)
- .setKey(new ElanKey(elanInstanceName)).build();
+ .withKey(new ElanKey(elanInstanceName)).build();
// Add the ElanState in the elan-state operational data-store
tx.put(LogicalDatastoreType.OPERATIONAL, getElanInstanceOperationalDataPath(elanInstanceName),
elanInfo, WriteTransaction.CREATE_MISSING_PARENTS);
// Add the ElanMacTable in the elan-mac-table operational data-store
- MacTable elanMacTable = new MacTableBuilder().setKey(new MacTableKey(elanInstanceName)).build();
+ MacTable elanMacTable = new MacTableBuilder().withKey(new MacTableKey(elanInstanceName)).build();
tx.put(LogicalDatastoreType.OPERATIONAL, getElanMacTableOperationalDataPath(elanInstanceName),
elanMacTable, WriteTransaction.CREATE_MISSING_PARENTS);
ElanTagNameBuilder elanTagNameBuilder = new ElanTagNameBuilder().setElanTag(elanTag)
- .setKey(new ElanTagNameKey(elanTag)).setName(elanInstanceName);
+ .withKey(new ElanTagNameKey(elanTag)).setName(elanInstanceName);
long etreeLeafTag = -1;
if (isEtreeInstance(elanInstanceAdded)) {
etreeLeafTag = retrieveNewElanTag(idManager,elanInstanceName + ElanConstants
.setDescription(elanInstanceAdded.getDescription())
.setMacTimeout(elanInstanceAdded.getMacTimeout() == null
? Long.valueOf(ElanConstants.DEFAULT_MAC_TIME_OUT) : elanInstanceAdded.getMacTimeout())
- .setKey(elanInstanceAdded.getKey()).setElanTag(elanTag);
+ .withKey(elanInstanceAdded.key()).setElanTag(elanTag);
if (isEtreeInstance(elanInstanceAdded)) {
EtreeInstance etreeInstance = new EtreeInstanceBuilder().setEtreeLeafTagVal(new EtreeLeafTag(etreeLeafTag))
.build();
private static void addTheLeafTagAsElanTag(String elanInstanceName, long etreeLeafTag, WriteTransaction tx) {
ElanTagName etreeTagAsElanTag = new ElanTagNameBuilder().setElanTag(etreeLeafTag)
- .setKey(new ElanTagNameKey(etreeLeafTag)).setName(elanInstanceName).build();
+ .withKey(new ElanTagNameKey(etreeLeafTag)).setName(elanInstanceName).build();
tx.put(LogicalDatastoreType.OPERATIONAL,
getElanInfoEntriesOperationalDataPath(etreeLeafTag), etreeTagAsElanTag);
}
private static boolean isEtreeInstance(ElanInstance elanInstanceAdded) {
- return elanInstanceAdded.getAugmentation(EtreeInstance.class) != null;
+ return elanInstanceAdded.augmentation(EtreeInstance.class) != null;
}
public boolean isDpnPresent(BigInteger dpnId) {
BigInteger cookie, List<Instruction> instructions) {
StypeOpenflowBuilder augBuilder = new StypeOpenflowBuilder().setFlowCookie(cookie).setFlowPriority(flowPriority)
.setInstruction(instructions);
- return new BoundServicesBuilder().setKey(new BoundServicesKey(servicePriority)).setServiceName(serviceName)
+ return new BoundServicesBuilder().withKey(new BoundServicesKey(servicePriority)).setServiceName(serviceName)
.setServicePriority(servicePriority).setServiceType(ServiceTypeFlowBased.class)
.addAugmentation(StypeOpenflow.class, augBuilder.build()).build();
}
public void removeTerminatingServiceAction(BigInteger destDpId, int serviceId) {
RemoveTerminatingServiceActionsInput input = new RemoveTerminatingServiceActionsInputBuilder()
.setDpnId(destDpId).setServiceId(serviceId).build();
- Future<RpcResult<Void>> futureObject = itmRpcService.removeTerminatingServiceActions(input);
+ Future<RpcResult<RemoveTerminatingServiceActionsOutput>> futureObject =
+ itmRpcService.removeTerminatingServiceActions(input);
try {
- RpcResult<Void> result = futureObject.get();
+ RpcResult<RemoveTerminatingServiceActionsOutput> result = futureObject.get();
if (result.isSuccessful()) {
LOG.debug("Successfully completed removeTerminatingServiceActions for ELAN with serviceId {} on "
+ "dpn {}", serviceId, destDpId);
return idBuilder.build();
}
+ @CheckReturnValue
public static CheckedFuture<Void, TransactionCommitFailedException> waitForTransactionToComplete(
WriteTransaction tx) {
CheckedFuture<Void, TransactionCommitFailedException> futures = tx.submit();
try {
futures.get();
} catch (InterruptedException | ExecutionException e) {
- LOG.error("Error writing to datastore {}", e);
+ // NETVIRT-1215: Do not log.error() here, only debug(); but callers *MUST* @CheckReturnValue
+ LOG.debug("Error writing to datastore", e);
}
return futures;
}
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
.ietf.interfaces.rev140508.interfaces.Interface configIface =
interfaceManager.getInterfaceInfoFromConfigDataStore(interfaceName);
- IfTunnel ifTunnel = configIface.getAugmentation(IfTunnel.class);
+ IfTunnel ifTunnel = configIface.augmentation(IfTunnel.class);
if (ifTunnel != null && ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeVxlan.class)) {
- ParentRefs refs = configIface.getAugmentation(ParentRefs.class);
+ ParentRefs refs = configIface.augmentation(ParentRefs.class);
if (refs != null && !Strings.isNullOrEmpty(refs.getParentInterface())) {
return true; //multiple VxLAN tunnels enabled, i.e. only logical tunnel should be treated
}
org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId nodeId =
new org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId("openflow:" + dpnId);
org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node nodeDpn =
- new NodeBuilder().setId(nodeId).setKey(new NodeKey(nodeId)).build();
+ new NodeBuilder().setId(nodeId).withKey(new NodeKey(nodeId)).build();
return InstanceIdentifier.builder(Nodes.class)
.child(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node.class,
- nodeDpn.getKey()).augmentation(FlowCapableNode.class)
+ nodeDpn.key()).augmentation(FlowCapableNode.class)
.child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flowKey).build();
}
ipAddress);
ArpResponderUtil.removeFlow(mdsalManager, dpnId, ArpResponderUtil.getFlowId(lportTag, ipAddress));
}
+
+ public static String getRouterPordIdFromElanInstance(DataBroker dataBroker, String elanInstanceName) {
+ Optional<Subnetmaps> subnetMapsData =
+ read(dataBroker, LogicalDatastoreType.CONFIGURATION, buildSubnetMapsWildCardPath());
+ if (subnetMapsData.isPresent()) {
+ List<Subnetmap> subnetMapList = subnetMapsData.get().getSubnetmap();
+ if (subnetMapList != null && !subnetMapList.isEmpty()) {
+ for (Subnetmap subnet : subnetMapList) {
+ if (subnet.getNetworkId().getValue().equals(elanInstanceName)) {
+ if (subnet.getRouterInterfacePortId() != null) {
+ return subnet.getRouterInterfacePortId().getValue();
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ static InstanceIdentifier<Subnetmaps> buildSubnetMapsWildCardPath() {
+ return InstanceIdentifier.create(Subnetmaps.class);
+ }
}