Search in sources :

Example 36 with InterfaceKey

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey in project genius by opendaylight.

the class InterfaceManagerTestUtil method updateInterfaceAdminState.

static void updateInterfaceAdminState(DataBroker dataBroker, String ifaceName, boolean isEnabled) throws TransactionCommitFailedException {
    InstanceIdentifier<Interface> vlanInterfaceEnabledInterfaceInstanceIdentifier = IfmUtil.buildId(ifaceName);
    InterfaceBuilder builder = new InterfaceBuilder().setKey(new InterfaceKey(ifaceName)).setName(ifaceName).setEnabled(isEnabled);
    WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
    tx.merge(CONFIGURATION, vlanInterfaceEnabledInterfaceInstanceIdentifier, builder.build());
    tx.submit().checkedGet();
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)

Example 37 with InterfaceKey

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey in project genius by opendaylight.

the class OvsVlanMemberConfigAddHelper method addConfiguration.

public List<ListenableFuture<Void>> addConfiguration(ParentRefs parentRefs, Interface interfaceNew) {
    LOG.info("adding vlan member configuration for interface {}", interfaceNew.getName());
    List<ListenableFuture<Void>> futures = new ArrayList<>();
    futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> interfaceManagerCommonUtils.createInterfaceChildEntry(parentRefs.getParentInterface(), interfaceNew.getName(), tx)));
    InterfaceKey interfaceKey = new InterfaceKey(parentRefs.getParentInterface());
    Interface ifaceParent = interfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey);
    if (ifaceParent == null) {
        LOG.info("Parent Interface: {} not found when adding child interface: {}", parentRefs.getParentInterface(), interfaceNew.getName());
        return futures;
    }
    IfL2vlan parentIfL2Vlan = ifaceParent.getAugmentation(IfL2vlan.class);
    if (parentIfL2Vlan == null || parentIfL2Vlan.getL2vlanMode() != IfL2vlan.L2vlanMode.Trunk) {
        LOG.error("Parent Interface: {} not of trunk Type when adding trunk-member: {}", ifaceParent, interfaceNew);
        return futures;
    }
    org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = interfaceManagerCommonUtils.getInterfaceState(parentRefs.getParentInterface());
    interfaceManagerCommonUtils.addStateEntry(interfaceNew.getName(), futures, ifState);
    return futures;
}
Also used : Logger(org.slf4j.Logger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) LoggerFactory(org.slf4j.LoggerFactory) InterfaceManagerCommonUtils(org.opendaylight.genius.interfacemanager.commons.InterfaceManagerCommonUtils) Singleton(javax.inject.Singleton) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) ArrayList(java.util.ArrayList) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) Inject(javax.inject.Inject) List(java.util.List) ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) IfL2vlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)

Example 38 with InterfaceKey

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey in project genius by opendaylight.

the class InterfaceInstanceRecoveryHandler method recoverService.

@Override
public void recoverService(String entityId) {
    if (!entityOwnershipUtils.isEntityOwner(IfmConstants.INTERFACE_CONFIG_ENTITY, IfmConstants.INTERFACE_CONFIG_ENTITY)) {
        return;
    }
    LOG.info("recover interface instance {}", entityId);
    // Fetch the interface from interface config DS first.
    Interface interfaceConfig = interfaceManagerCommonUtils.getInterfaceFromConfigDS(entityId);
    if (interfaceConfig != null) {
        // Do a delete and recreate of the interface configuration.
        InstanceIdentifier<Interface> interfaceId = InterfaceManagerCommonUtils.getInterfaceIdentifier(new InterfaceKey(entityId));
        LOG.trace("deleting interface instance {}", entityId);
        jobCoordinator.enqueueJob(entityId, () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> tx.delete(LogicalDatastoreType.CONFIGURATION, interfaceId))), IfmConstants.JOB_MAX_RETRIES);
        LOG.trace("recreating interface instance {}, {}", entityId, interfaceConfig);
        jobCoordinator.enqueueJob(entityId, () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> tx.put(LogicalDatastoreType.CONFIGURATION, interfaceId, interfaceConfig))), IfmConstants.JOB_MAX_RETRIES);
    }
}
Also used : InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) GeniusIfmInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.srm.types.rev170711.GeniusIfmInterface) ServiceRecoveryInterface(org.opendaylight.genius.srm.ServiceRecoveryInterface)

Aggregations

InterfaceKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey)34 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)20 IfTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)11 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)11 InterfaceBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder)9 ParentRefsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder)8 IfTunnelBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnelBuilder)7 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)6 BigInteger (java.math.BigInteger)5 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)5 DpnToInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterface)5 DpnToInterfaceKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterfaceKey)5 InterfaceKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey)4 PhysAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)4 IfIndexInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._if.indexes._interface.map.IfIndexInterface)4 IfIndexInterfaceKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._if.indexes._interface.map.IfIndexInterfaceKey)4 Collections (java.util.Collections)3 List (java.util.List)3