Search in sources :

Example 16 with State

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.State in project netvirt by opendaylight.

the class InterVpnLinkUtil method updateInterVpnLinkState.

/**
 * Updates inter-VPN link state.
 *
 * @param broker dataBroker service reference
 * @param vpnLinkName The name of the InterVpnLink
 * @param state Sets the state of the InterVpnLink to Active or Error
 * @param newFirstEndpointState Updates the lportTag and/or DPNs of the 1st endpoint of the InterVpnLink
 * @param newSecondEndpointState Updates the lportTag and/or DPNs of the 2nd endpoint of the InterVpnLink
 * @param interVpnLinkCache the InterVpnLinkCache
 */
public static void updateInterVpnLinkState(DataBroker broker, String vpnLinkName, InterVpnLinkState.State state, FirstEndpointState newFirstEndpointState, SecondEndpointState newSecondEndpointState, InterVpnLinkCache interVpnLinkCache) {
    Optional<InterVpnLinkState> optOldVpnLinkState = getInterVpnLinkState(broker, vpnLinkName);
    if (optOldVpnLinkState.isPresent()) {
        InterVpnLinkState newVpnLinkState = new InterVpnLinkStateBuilder(optOldVpnLinkState.get()).setState(state).setFirstEndpointState(newFirstEndpointState).setSecondEndpointState(newSecondEndpointState).build();
        VpnUtil.syncUpdate(broker, LogicalDatastoreType.CONFIGURATION, InterVpnLinkUtil.getInterVpnLinkStateIid(vpnLinkName), newVpnLinkState);
        interVpnLinkCache.addInterVpnLinkStateToCaches(newVpnLinkState);
    } else {
        InterVpnLinkState newIVpnLinkState = new InterVpnLinkStateBuilder().setKey(new InterVpnLinkStateKey(vpnLinkName)).setInterVpnLinkName(vpnLinkName).setFirstEndpointState(newFirstEndpointState).setSecondEndpointState(newSecondEndpointState).setState(InterVpnLinkState.State.Active).build();
        VpnUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, InterVpnLinkUtil.getInterVpnLinkStateIid(vpnLinkName), newIVpnLinkState);
        interVpnLinkCache.addInterVpnLinkStateToCaches(newIVpnLinkState);
    }
}
Also used : InterVpnLinkState(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.link.states.InterVpnLinkState) InterVpnLinkStateKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.link.states.InterVpnLinkStateKey) InterVpnLinkStateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.link.states.InterVpnLinkStateBuilder)

Example 17 with State

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.State in project netvirt by opendaylight.

the class DhcpInterfaceEventListener method update.

@Override
protected void update(InstanceIdentifier<Interface> identifier, Interface original, Interface update) {
    // We're only interested in Vlan and Tunnel ports
    if (!L2vlan.class.equals(update.getType()) && !Tunnel.class.equals(update.getType())) {
        return;
    }
    if ((original.getOperStatus().getIntValue() ^ update.getOperStatus().getIntValue()) == 0) {
        LOG.trace("Interface operstatus {} is same", update.getOperStatus());
        return;
    }
    if (original.getOperStatus().equals(OperStatus.Unknown) || update.getOperStatus().equals(OperStatus.Unknown)) {
        LOG.trace("New/old interface state is unknown not handling");
        return;
    }
    List<String> ofportIds = update.getLowerLayerIf();
    if (ofportIds == null || ofportIds.isEmpty()) {
        return;
    }
    NodeConnectorId nodeConnectorId = new NodeConnectorId(ofportIds.get(0));
    BigInteger dpnId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(nodeConnectorId));
    String interfaceName = update.getName();
    DhcpInterfaceUpdateJob job = new DhcpInterfaceUpdateJob(dhcpExternalTunnelManager, dataBroker, interfaceName, dpnId, update.getOperStatus(), interfaceManager);
    jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(interfaceName), job, DhcpMConstants.RETRY_COUNT);
}
Also used : NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) BigInteger(java.math.BigInteger) DhcpInterfaceUpdateJob(org.opendaylight.netvirt.dhcpservice.jobs.DhcpInterfaceUpdateJob)

Example 18 with State

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.State in project bgpcep by opendaylight.

the class NeighborStateCliUtils method printTimerState.

private static void printTimerState(final Timers timers, final ShellTable table) {
    if (timers == null) {
        return;
    }
    final NeighborTimersStateAugmentation state = timers.getState().getAugmentation(NeighborTimersStateAugmentation.class);
    if (state == null) {
        return;
    }
    addHeader(table, "Timer state");
    table.addRow().addContent("Negotiated Hold Time", state.getNegotiatedHoldTime());
    table.addRow().addContent("Uptime", state.getUptime().getValue());
}
Also used : NeighborTimersStateAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborTimersStateAugmentation)

Example 19 with State

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.State in project bgpcep by opendaylight.

the class PeerGroupStateCliUtils method displayState.

private static void displayState(final PeerGroup group, final ShellTable table) {
    addHeader(table, "Peer Group state");
    table.addRow().addContent("Peer Group Name", group.getPeerGroupName());
    final State state = group.getState();
    if (state == null) {
        return;
    }
    final PeerGroupStateAugmentation aug = state.getAugmentation(PeerGroupStateAugmentation.class);
    table.addRow().addContent("Total Prefixes", aug.getTotalPrefixes());
}
Also used : State(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.State) PeerGroupStateAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.PeerGroupStateAugmentation)

Example 20 with State

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.State in project bgpcep by opendaylight.

the class PCEPErrorMessageParser method insertObject.

private static State insertObject(final State state, final List<Errors> errorObjects, final Object obj, final List<Rps> requestParameters, final PcerrMessageBuilder b) {
    switch(state) {
        case RP_IN:
            if (obj instanceof Rp) {
                final Rp o = (Rp) obj;
                requestParameters.add(new RpsBuilder().setRp(o).build());
                return State.RP_IN;
            }
        case ERROR_IN:
            if (obj instanceof ErrorObject) {
                final ErrorObject o = (ErrorObject) obj;
                errorObjects.add(new ErrorsBuilder().setErrorObject(o).build());
                return State.ERROR_IN;
            }
        case OPEN:
            if (obj instanceof Open) {
                b.setErrorType(new SessionCaseBuilder().setSession(new SessionBuilder().setOpen((Open) obj).build()).build());
                return State.OPEN_IN;
            }
        case ERROR:
            if (obj instanceof ErrorObject) {
                final ErrorObject o = (ErrorObject) obj;
                errorObjects.add(new ErrorsBuilder().setErrorObject(o).build());
                return State.ERROR;
            }
        case OPEN_IN:
        case END:
            return State.END;
        default:
            return state;
    }
}
Also used : SessionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.error.type.SessionCaseBuilder) ErrorObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.ErrorObject) ErrorsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.ErrorsBuilder) SessionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.error.type.session._case.SessionBuilder) RpsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.error.type.request._case.request.RpsBuilder) Rp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp) Open(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open)

Aggregations

ArrayList (java.util.ArrayList)31 Test (org.junit.Test)28 BigInteger (java.math.BigInteger)27 List (java.util.List)15 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)14 Collections (java.util.Collections)13 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)13 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)12 Logger (org.slf4j.Logger)12 LoggerFactory (org.slf4j.LoggerFactory)12 Optional (com.google.common.base.Optional)11 Inject (javax.inject.Inject)11 Singleton (javax.inject.Singleton)11 ManagedNewTransactionRunner (org.opendaylight.genius.infra.ManagedNewTransactionRunner)10 ManagedNewTransactionRunnerImpl (org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl)10 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)10 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)10 FutureCallback (com.google.common.util.concurrent.FutureCallback)9 ByteBuf (io.netty.buffer.ByteBuf)9 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)9