Search in sources :

Example 26 with CfmConfigException

use of org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException in project onos by opennetworkinglab.

the class DelayMeasurementCreateTest method setUp.

@Before
public void setUp() throws Exception, CfmConfigException, SoamConfigException {
    DelayMeasurementThreshold dmT1 = DefaultDelayMeasurementThreshold.builder(SoamId.valueOf(1)).averageFrameDelayBackward(Duration.ofMillis(123)).averageInterFrameDelayVariationForward(Duration.ofMillis(321)).build();
    DelayMeasurementThreshold dmT2 = DefaultDelayMeasurementThreshold.builder(SoamId.valueOf(2)).averageFrameDelayBackward(Duration.ofMillis(456)).averageInterFrameDelayVariationForward(Duration.ofMillis(654)).build();
    try {
        DefaultDmCreateBuilder builder = (DefaultDmCreateBuilder) DefaultDelayMeasurementCreate.builder(DmType.DMDMM, Version.Y17312011, MepId.valueOf((short) 12), Priority.PRIO6).addToMeasurementsEnabled(MeasurementOption.FRAME_DELAY_FORWARD_MIN).addToMeasurementsEnabled(MeasurementOption.FRAME_DELAY_FORWARD_AVERAGE).addToMeasurementsEnabled(MeasurementOption.FRAME_DELAY_FORWARD_MAX).addToMeasurementsEnabled(MeasurementOption.FRAME_DELAY_FORWARD_BINS).binsPerFdInterval((short) 8).binsPerIfdvInterval((short) 9).ifdvSelectionOffset((short) 10).binsPerFdrInterval((short) 12).addToThresholds(dmT1).addToThresholds(dmT2).messagePeriod(Duration.ofMillis(100L)).frameSize((short) 64).dataPattern(DataPattern.ONES).testTlvIncluded(true).testTlvPattern(TestTlvPattern.NULL_SIGNAL_WITHOUT_CRC_32).measurementInterval(Duration.ofMinutes(15)).numberIntervalsStored((short) 32).alignMeasurementIntervals(true).alignMeasurementOffset(Duration.ofMinutes(4)).sessionType(SessionType.ONDEMAND).startTime(StartTime.relative(Duration.ofMinutes(7))).stopTime(StopTime.relative(Duration.ofMinutes(8)));
        dm1 = builder.build();
    } catch (SoamConfigException e) {
        throw new Exception(e);
    }
}
Also used : SoamConfigException(org.onosproject.incubator.net.l2monitoring.soam.SoamConfigException) DefaultDmCreateBuilder(org.onosproject.incubator.net.l2monitoring.soam.delay.DefaultDelayMeasurementCreate.DefaultDmCreateBuilder) SoamConfigException(org.onosproject.incubator.net.l2monitoring.soam.SoamConfigException) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException) Before(org.junit.Before)

Example 27 with CfmConfigException

use of org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException in project onos by opennetworkinglab.

the class MaintenanceAssociationTest method setUp.

@Before
public void setUp() throws Exception {
    try {
        ma1 = DefaultMaintenanceAssociation.builder(MaIdCharStr.asMaId("ma-1"), 10).ccmInterval(CcmInterval.INTERVAL_1MIN).maNumericId((short) 1).build();
        ma2 = DefaultMaintenanceAssociation.builder(MaIdPrimaryVid.asMaId("1024"), 10).build();
        ma3 = DefaultMaintenanceAssociation.builder(MaId2Octet.asMaId("33333"), 10).build();
        ma4 = DefaultMaintenanceAssociation.builder(MaIdRfc2685VpnId.asMaIdHex("0A:0B:0C:0D:0E:0F:00"), 10).build();
    } catch (CfmConfigException e) {
        throw new Exception(e);
    }
}
Also used : CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException) Before(org.junit.Before)

Example 28 with CfmConfigException

use of org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException in project onos by opennetworkinglab.

the class CfmMepManager method abortLoopback.

@Override
public void abortLoopback(MdId mdName, MaIdShort maName, MepId mepId) throws CfmConfigException {
    MepKeyId key = new MepKeyId(mdName, maName, mepId);
    Mep mep = mepStore.getMep(key).orElseThrow(() -> new CfmConfigException("Mep " + mdName + "/" + maName + "/" + mepId + " not found when calling Aborting Loopback"));
    log.debug("Aborting Loopback on MEP {} on Device {}", key, mep.deviceId());
    deviceService.getDevice(mep.deviceId()).as(CfmMepProgrammable.class).abortLoopback(mdName, maName, mepId);
}
Also used : CfmMepProgrammable(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMepProgrammable) Mep(org.onosproject.incubator.net.l2monitoring.cfm.Mep) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException) MepKeyId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepKeyId)

Example 29 with CfmConfigException

use of org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException in project onos by opennetworkinglab.

the class CfmMepManager method getAllMeps.

@Override
public Collection<MepEntry> getAllMeps(MdId mdName, MaIdShort maName) throws CfmConfigException {
    // Will throw IllegalArgumentException if ma does not exist
    cfmMdService.getMaintenanceAssociation(mdName, maName);
    Collection<Mep> mepStoreCollection = mepStore.getAllMeps();
    Collection<MepEntry> mepEntryCollection = new ArrayList<>();
    for (Mep mep : mepStoreCollection) {
        if (mep.mdId().equals(mdName) && mep.maId().equals(maName)) {
            DeviceId mepDeviceId = mep.deviceId();
            if (deviceService.getDevice(mepDeviceId) == null) {
                log.warn("Device not found/available " + mepDeviceId + " for MEP: " + mdName + "/" + maName + "/" + mep.mepId());
                continue;
            } else if (!deviceService.getDevice(mepDeviceId).is(CfmMepProgrammable.class)) {
                throw new CfmConfigException("Device " + mepDeviceId + " does not support CfmMepProgrammable behaviour.");
            }
            log.debug("Retrieving MEP results for Mep {} in MD {}, MA {} " + "on Device {}", mep.mepId(), mdName, maName, mepDeviceId);
            mepEntryCollection.add(deviceService.getDevice(mepDeviceId).as(CfmMepProgrammable.class).getMep(mdName, maName, mep.mepId()));
        }
    }
    return mepEntryCollection;
}
Also used : MepEntry(org.onosproject.incubator.net.l2monitoring.cfm.MepEntry) DeviceId(org.onosproject.net.DeviceId) ArrayList(java.util.ArrayList) Mep(org.onosproject.incubator.net.l2monitoring.cfm.Mep) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException)

Example 30 with CfmConfigException

use of org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException in project onos by opennetworkinglab.

the class CfmMepManager method deleteMep.

@Override
public boolean deleteMep(MdId mdName, MaIdShort maName, MepId mepId, Optional<MaintenanceDomain> oldMd) throws CfmConfigException {
    MepKeyId key = new MepKeyId(mdName, maName, mepId);
    // Will throw IllegalArgumentException if ma does not exist
    cfmMdService.getMaintenanceAssociation(mdName, maName);
    // Get the device ID from the MEP
    Optional<Mep> deletedMep = mepStore.getMep(key);
    if (!deletedMep.isPresent()) {
        log.warn("MEP {} not found when deleting Mep", key);
        return false;
    }
    DeviceId mepDeviceId = deletedMep.get().deviceId();
    boolean deleted = mepStore.deleteMep(key);
    Device mepDevice = deviceService.getDevice(mepDeviceId);
    if (mepDevice == null || !mepDevice.is(CfmMepProgrammable.class)) {
        throw new CfmConfigException("Unexpeced fault on device driver for " + mepDeviceId);
    }
    try {
        deleted = mepDevice.as(CfmMepProgrammable.class).deleteMep(mdName, maName, mepId, oldMd);
    } catch (CfmConfigException e) {
        log.warn("MEP could not be deleted on device - perhaps it " + "does not exist. Continuing");
    }
    // Iterate through all other devices and remove as a Remote Mep
    int mepsOnMdCount = 0;
    int mepsOnMaCount = 0;
    List<DeviceId> alreadyHandledDevices = new ArrayList<>();
    for (Mep mep : mepStore.getAllMeps()) {
        if (mep.deviceId().equals(mepDeviceId) && mdName.equals(mep.mdId())) {
            mepsOnMdCount++;
            if (maName.equals(mep.maId())) {
                mepsOnMaCount++;
            }
        }
        if (mep.deviceId().equals(mepDeviceId) || !mep.mdId().equals(mdName) || !mep.maId().equals(maName) || alreadyHandledDevices.contains(mep.deviceId())) {
            continue;
        }
        deviceService.getDevice(mep.deviceId()).as(CfmMepProgrammable.class).deleteMaRemoteMepOnDevice(mdName, maName, mepId);
        alreadyHandledDevices.add(mep.deviceId());
        log.info("Deleted RMep entry on {} on device {}", mdName.mdName() + "/" + maName.maName(), mep.deviceId());
    }
    // If this is the last MA in this MD on device, then delete the MD from the device
    if (mepsOnMdCount == 0) {
        boolean deletedMd = deviceService.getDevice(mepDeviceId).as(CfmMepProgrammable.class).deleteMdOnDevice(mdName, oldMd);
        log.info("Deleted MD {} from Device {}", mdName.mdName(), mepDeviceId);
    } else if (mepsOnMaCount == 0) {
        boolean deletedMa = deviceService.getDevice(mepDeviceId).as(CfmMepProgrammable.class).deleteMaOnDevice(mdName, maName, oldMd);
        log.info("Deleted MA {} from Device {}", mdName.mdName() + "/" + maName.maName(), mepDeviceId);
    }
    return deleted;
}
Also used : DeviceId(org.onosproject.net.DeviceId) Device(org.onosproject.net.Device) CfmMepProgrammable(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMepProgrammable) ArrayList(java.util.ArrayList) Mep(org.onosproject.incubator.net.l2monitoring.cfm.Mep) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException) MepKeyId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepKeyId)

Aggregations

CfmConfigException (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException)50 MdId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId)27 MaIdShort (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort)23 Consumes (javax.ws.rs.Consumes)22 Produces (javax.ws.rs.Produces)22 MepId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId)17 Path (javax.ws.rs.Path)14 Mep (org.onosproject.incubator.net.l2monitoring.cfm.Mep)14 CfmMdService (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService)13 CfmMepService (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMepService)12 DeviceId (org.onosproject.net.DeviceId)11 JsonNode (com.fasterxml.jackson.databind.JsonNode)10 SoamService (org.onosproject.incubator.net.l2monitoring.soam.SoamService)10 MepEntry (org.onosproject.incubator.net.l2monitoring.cfm.MepEntry)9 CfmMepProgrammable (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMepProgrammable)8 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)7 GET (javax.ws.rs.GET)7 MaintenanceDomain (org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain)7 MepKeyId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepKeyId)7 MaintenanceAssociation (org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation)6