use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs in project genius by opendaylight.
the class InterfacemgrProvider method createVLANInterface.
@Override
public ListenableFuture<Void> createVLANInterface(String interfaceName, String portName, Integer vlanId, String description, IfL2vlan.L2vlanMode l2vlanMode, boolean isExternal) throws InterfaceAlreadyExistsException {
LOG.info("Create VLAN interface : {}", interfaceName);
Interface interfaceOptional = interfaceManagerCommonUtils.getInterfaceFromConfigDS(new InterfaceKey(interfaceName));
if (interfaceOptional != null) {
LOG.debug("VLAN interface already exists {} ", interfaceOptional.getDescription());
throw new InterfaceAlreadyExistsException(interfaceOptional.getName());
}
IfL2vlanBuilder l2vlanBuilder = new IfL2vlanBuilder().setL2vlanMode(l2vlanMode);
if (vlanId != null && vlanId > 0) {
l2vlanBuilder.setVlanId(new VlanId(vlanId));
}
ParentRefs parentRefs = new ParentRefsBuilder().setParentInterface(portName).build();
InterfaceBuilder interfaceBuilder = new InterfaceBuilder().setEnabled(true).setName(interfaceName).setType(L2vlan.class).addAugmentation(IfL2vlan.class, l2vlanBuilder.build()).addAugmentation(ParentRefs.class, parentRefs).setDescription(description);
if (isExternal) {
interfaceBuilder.addAugmentation(IfExternal.class, new IfExternalBuilder().setExternal(true).build());
}
InstanceIdentifier<Interface> interfaceIId = interfaceManagerCommonUtils.getInterfaceIdentifier(new InterfaceKey(interfaceName));
ListenableFuture<Void> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> tx.put(CONFIGURATION, interfaceIId, interfaceBuilder.build(), CREATE_MISSING_PARENTS));
ListenableFutures.addErrorLogging(future, LOG, "Failed to (async) write {}", interfaceIId);
return future;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs in project genius by opendaylight.
the class OvsVlanMemberConfigRemoveHelper method removeConfiguration.
public List<ListenableFuture<Void>> removeConfiguration(ParentRefs parentRefs, Interface interfaceOld) {
LOG.debug("remove vlan member configuration {}", interfaceOld.getName());
List<ListenableFuture<Void>> futures = new ArrayList<>();
InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(parentRefs.getParentInterface());
InstanceIdentifier<InterfaceParentEntry> interfaceParentEntryIid = InterfaceMetaUtils.getInterfaceParentEntryIdentifier(interfaceParentEntryKey);
InterfaceParentEntry interfaceParentEntry = interfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryIid);
if (interfaceParentEntry == null) {
return futures;
}
// Configuration changes
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
// Delete the interface child information
List<InterfaceChildEntry> interfaceChildEntries = interfaceParentEntry.getInterfaceChildEntry();
InterfaceChildEntryKey interfaceChildEntryKey = new InterfaceChildEntryKey(interfaceOld.getName());
InstanceIdentifier<InterfaceChildEntry> interfaceChildEntryIid = InterfaceMetaUtils.getInterfaceChildEntryIdentifier(interfaceParentEntryKey, interfaceChildEntryKey);
tx.delete(LogicalDatastoreType.CONFIGURATION, interfaceChildEntryIid);
// If this is the last child, remove the interface parent info as well.
if (interfaceChildEntries.size() <= 1) {
tx.delete(LogicalDatastoreType.CONFIGURATION, interfaceParentEntryIid);
}
}));
// Operational changes
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = interfaceManagerCommonUtils.getInterfaceState(parentRefs.getParentInterface());
if (ifState != null) {
LOG.debug("delete vlan member interface state {}", interfaceOld.getName());
BigInteger dpId = IfmUtil.getDpnFromInterface(ifState);
interfaceManagerCommonUtils.deleteInterfaceStateInformation(interfaceOld.getName(), tx);
FlowBasedServicesUtils.removeIngressFlow(interfaceOld.getName(), dpId, txRunner, futures);
}
}));
return futures;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs in project genius by opendaylight.
the class InterfaceManagerServiceImpl method getDpidFromInterface.
@Override
public ListenableFuture<GetDpidFromInterfaceOutput> getDpidFromInterface(GetDpidFromInterfaceInput input) {
String interfaceName = input.getIntfName();
BigInteger dpId;
InterfaceKey interfaceKey = new InterfaceKey(interfaceName);
Interface interfaceInfo = interfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey);
if (interfaceInfo == null) {
throw new IllegalArgumentException(getDpidFromInterfaceErrorMessage(interfaceName, "missing Interface in Config DataStore"));
}
if (Tunnel.class.equals(interfaceInfo.getType())) {
ParentRefs parentRefs = interfaceInfo.getAugmentation(ParentRefs.class);
dpId = parentRefs.getDatapathNodeIdentifier();
} else {
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = interfaceManagerCommonUtils.getInterfaceState(interfaceName);
if (ifState != null) {
String lowerLayerIf = ifState.getLowerLayerIf().get(0);
NodeConnectorId nodeConnectorId = new NodeConnectorId(lowerLayerIf);
dpId = IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId);
} else {
throw new IllegalArgumentException(getDpidFromInterfaceErrorMessage(interfaceName, "missing Interface-state"));
}
}
return Futures.immediateFuture(new GetDpidFromInterfaceOutputBuilder().setDpid(dpId).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs in project genius by opendaylight.
the class OvsInterfaceConfigAddHelper method addConfiguration.
public List<ListenableFuture<Void>> addConfiguration(ParentRefs parentRefs, Interface interfaceNew) {
List<ListenableFuture<Void>> futures = new ArrayList<>();
// TODO Disentangle the transactions
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(configTx -> {
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(operTx -> {
IfTunnel ifTunnel = interfaceNew.getAugmentation(IfTunnel.class);
if (ifTunnel != null) {
addTunnelConfiguration(parentRefs, interfaceNew, ifTunnel, configTx, operTx, futures);
} else {
addVlanConfiguration(interfaceNew, parentRefs, configTx, operTx, futures);
}
}));
}));
return futures;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs in project genius by opendaylight.
the class InterfaceManagerTestUtil method putInterfaceConfig.
static void putInterfaceConfig(DataBroker dataBroker, String ifaceName, ParentRefs parentRefs, Class<? extends InterfaceType> ifType) throws TransactionCommitFailedException {
Interface interfaceInfo;
if (!Tunnel.class.equals(ifType)) {
interfaceInfo = InterfaceManagerTestUtil.buildInterface(ifaceName, ifaceName, true, ifType, parentRefs.getParentInterface(), IfL2vlan.L2vlanMode.Trunk);
} else {
interfaceInfo = buildTunnelInterface(parentRefs.getDatapathNodeIdentifier(), ifaceName, ifaceName, true, TunnelTypeVxlan.class, "1.1.1.1", "2.2.2.2");
}
InstanceIdentifier<Interface> interfaceInstanceIdentifier = IfmUtil.buildId(ifaceName);
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
tx.put(CONFIGURATION, interfaceInstanceIdentifier, interfaceInfo, true);
tx.submit().checkedGet();
}
Aggregations