Search in sources :

Example 96 with Path

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.updates.Path in project genius by opendaylight.

the class TepCommandHelper method configureTunnelMonitorInterval.

public void configureTunnelMonitorInterval(int interval) {
    InstanceIdentifier<TunnelMonitorInterval> path = InstanceIdentifier.builder(TunnelMonitorInterval.class).build();
    Optional<TunnelMonitorInterval> storedTunnelMonitor = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker);
    if (!storedTunnelMonitor.isPresent() || storedTunnelMonitor.get().getInterval() != interval) {
        TunnelMonitorInterval tunnelMonitor = new TunnelMonitorIntervalBuilder().setInterval(interval).build();
        ItmUtils.asyncUpdate(LogicalDatastoreType.CONFIGURATION, path, tunnelMonitor, dataBroker, ItmUtils.DEFAULT_CALLBACK);
    }
}
Also used : TunnelMonitorIntervalBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.TunnelMonitorIntervalBuilder) TunnelMonitorInterval(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.TunnelMonitorInterval)

Example 97 with Path

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.updates.Path in project genius by opendaylight.

the class DpnTepStateCache method added.

@Override
protected void added(InstanceIdentifier<DpnsTeps> path, DpnsTeps dpnsTeps) {
    for (RemoteDpns remoteDpns : dpnsTeps.getRemoteDpns()) {
        final String dpn = getDpnId(dpnsTeps.getSourceDpnId(), remoteDpns.getDestinationDpnId());
        DpnTepInterfaceInfo value = new DpnTepInterfaceInfoBuilder().setTunnelName(remoteDpns.getTunnelName()).setGroupId(dpnsTeps.getGroupId()).setIsMonitoringEnabled(remoteDpns.isMonitoringEnabled()).setIsMonitoringEnabled(remoteDpns.isInternal()).setTunnelType(dpnsTeps.getTunnelType()).build();
        dpnTepInterfaceMap.put(dpn, value);
        addTunnelEndPointInfoToCache(remoteDpns.getTunnelName(), dpnsTeps.getSourceDpnId().toString(), remoteDpns.getDestinationDpnId().toString());
    }
}
Also used : DpnTepInterfaceInfoBuilder(org.opendaylight.genius.itm.utils.DpnTepInterfaceInfoBuilder) RemoteDpns(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.teps.state.dpns.teps.RemoteDpns) DpnTepInterfaceInfo(org.opendaylight.genius.itm.utils.DpnTepInterfaceInfo)

Example 98 with Path

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.updates.Path in project genius by opendaylight.

the class TepCommandHelper method configureTunnelMonitorParams.

public void configureTunnelMonitorParams(boolean monitorEnabled, String monitorProtocol) {
    InstanceIdentifier<TunnelMonitorParams> path = InstanceIdentifier.builder(TunnelMonitorParams.class).build();
    Optional<TunnelMonitorParams> storedTunnelMonitor = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker);
    Class<? extends TunnelMonitoringTypeBase> monitorType;
    if (storedTunnelMonitor.isPresent() && storedTunnelMonitor.get().getMonitorProtocol() != null) {
        monitorType = storedTunnelMonitor.get().getMonitorProtocol();
    } else {
        if (monitorProtocol != null && monitorProtocol.equalsIgnoreCase(ITMConstants.MONITOR_TYPE_LLDP)) {
            monitorType = TunnelMonitoringTypeLldp.class;
        } else {
            monitorType = TunnelMonitoringTypeBfd.class;
        }
    }
    if (!storedTunnelMonitor.isPresent() || storedTunnelMonitor.get().isEnabled() != monitorEnabled) {
        TunnelMonitorParams tunnelMonitor = new TunnelMonitorParamsBuilder().setEnabled(monitorEnabled).setMonitorProtocol(monitorType).build();
        ItmUtils.asyncUpdate(LogicalDatastoreType.CONFIGURATION, path, tunnelMonitor, dataBroker, ItmUtils.DEFAULT_CALLBACK);
    }
}
Also used : TunnelMonitorParamsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.TunnelMonitorParamsBuilder) TunnelMonitorParams(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.TunnelMonitorParams)

Example 99 with Path

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.updates.Path in project genius by opendaylight.

the class SrmRpcUtils method callSrmOp.

public static ReinstallOutput callSrmOp(DataBroker broker, ReinstallInput input) {
    ReinstallOutputBuilder outputBuilder = new ReinstallOutputBuilder();
    if (input.getEntityName() == null) {
        outputBuilder.setSuccessful(REINSTALL_FAILED).setMessage("EntityName is null");
        return outputBuilder.build();
    }
    if (input.getEntityType() == null) {
        outputBuilder.setSuccessful(REINSTALL_FAILED).setMessage(String.format("EntityType for %s can't be null", input.getEntityName().getSimpleName()));
        return outputBuilder.build();
    }
    if (!EntityTypeService.class.equals(input.getEntityType())) {
        outputBuilder.setSuccessful(REINSTALL_FAILED).setMessage(String.format("EntityType is %s, Reinstall is only for EntityTypeService", input.getEntityType()));
        return outputBuilder.build();
    }
    Class<? extends EntityNameBase> serviceName = NAME_TO_SERVICE_MAP.get(input.getEntityName());
    if (serviceName == null) {
        outputBuilder.setSuccessful(REINSTALL_FAILED).setMessage(String.format("EntityName %s has no matching service", input.getEntityName().getSimpleName()));
        return outputBuilder.build();
    }
    Class<? extends EntityTypeBase> entityType = NAME_TO_TYPE_MAP.get(input.getEntityName());
    if (entityType == null || !input.getEntityType().equals(entityType)) {
        outputBuilder.setSuccessful(REINSTALL_FAILED).setMessage(String.format("EntityName %s doesn't match with EntityType %s", input.getEntityName().getSimpleName(), entityType));
        return outputBuilder.build();
    }
    OperationsBuilder opsBuilder = new OperationsBuilder().setEntityName(input.getEntityName()).setEntityType(entityType).setTriggerOperation(ServiceOpReinstall.class);
    Operations operation = opsBuilder.build();
    InstanceIdentifier<Operations> opsIid = getInstanceIdentifier(operation, serviceName);
    WriteTransaction tx = broker.newWriteOnlyTransaction();
    tx.put(LogicalDatastoreType.OPERATIONAL, opsIid, operation, CREATE_MISSING_PARENT);
    try {
        tx.submit().get();
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("Error writing RecoveryOp to datastore. path:{}, data:{}", opsIid, operation);
        outputBuilder.setSuccessful(REINSTALL_FAILED).setMessage(e.getMessage());
        return outputBuilder.build();
    }
    outputBuilder.setSuccessful(REINSTALL_SUCCESS).setMessage("Recovery operation successfully triggered");
    return outputBuilder.build();
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) ReinstallOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.srm.rpcs.rev170711.ReinstallOutputBuilder) OperationsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.srm.ops.rev170711.service.ops.services.OperationsBuilder) EntityTypeService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.srm.types.rev170711.EntityTypeService) ExecutionException(java.util.concurrent.ExecutionException) Operations(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.srm.ops.rev170711.service.ops.services.Operations)

Example 100 with Path

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.updates.Path in project bgpcep by opendaylight.

the class BasePathSelectorTest method testBestPathSelectionOptions.

@Test
public void testBestPathSelectionOptions() {
    AttributesBuilder dataContBuilder = createStateFromPrefMedOriginASPath();
    this.selector.processPath(ROUTER_ID2, dataContBuilder.build());
    BaseBestPath processedPath = this.selector.result();
    assertEquals(1, processedPath.getState().getOrigin().getIntValue());
    // prefer the path with the lowest origin type
    addIgpOrigin(dataContBuilder);
    this.selector.processPath(ROUTER_ID2, dataContBuilder.build());
    processedPath = this.selector.result();
    assertEquals(0, processedPath.getState().getOrigin().getIntValue());
    addEgpOrigin(dataContBuilder);
    this.selector.processPath(ROUTER_ID2, dataContBuilder.build());
    processedPath = this.selector.result();
    assertEquals(0, processedPath.getState().getOrigin().getIntValue());
    // prefer the path with the lowest multi-exit discriminator (MED)
    assertEquals(4321L, (long) processedPath.getState().getMultiExitDisc());
    addIgpOrigin(dataContBuilder);
    addLowerMultiExitDisc(dataContBuilder);
    this.selector.processPath(ROUTER_ID2, dataContBuilder.build());
    processedPath = this.selector.result();
    assertEquals(1234L, (long) processedPath.getState().getMultiExitDisc());
    addHigherMultiExitDisc(dataContBuilder);
    this.selector.processPath(ROUTER_ID2, dataContBuilder.build());
    processedPath = this.selector.result();
    assertEquals(1234L, (long) processedPath.getState().getMultiExitDisc());
    addLowerMultiExitDisc(dataContBuilder);
    addAsPath(dataContBuilder, SEQ_SEGMENT2);
    assertEquals(1L, processedPath.getState().getPeerAs());
    assertEquals(3, processedPath.getState().getAsPathLength());
    this.selector.processPath(ROUTER_ID2, dataContBuilder.build());
    processedPath = this.selector.result();
    assertEquals(1L, processedPath.getState().getPeerAs());
    assertEquals(3, processedPath.getState().getAsPathLength());
}
Also used : AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)53 Test (org.junit.Test)48 ExecutionException (java.util.concurrent.ExecutionException)26 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)21 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)20 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)19 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)19 Collections (java.util.Collections)18 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)18 ByteBuf (io.netty.buffer.ByteBuf)16 List (java.util.List)16 TransportZones (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones)16 Logger (org.slf4j.Logger)16 LoggerFactory (org.slf4j.LoggerFactory)16 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)15 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder)15 AsPathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.AsPathBuilder)15 TransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)14 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update)12 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)11