Search in sources :

Example 1 with MepEntry

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

the class SoamManager method getDmCurrentStat.

@Override
public DelayMeasurementStatCurrent getDmCurrentStat(MdId mdName, MaIdShort maName, MepId mepId, SoamId dmId) throws CfmConfigException, SoamConfigException {
    MepEntry mep = cfmMepService.getMep(mdName, maName, mepId);
    if (mep == null || mep.deviceId() == null) {
        throw new CfmConfigException("MEP :" + mdName + "/" + maName + "/" + mepId + " does not exist");
    } else if (deviceService.getDevice(mep.deviceId()) == null) {
        throw new CfmConfigException("Device " + mep.deviceId() + " from MEP :" + mdName + "/" + maName + "/" + mepId + " does not exist");
    } else if (!deviceService.getDevice(mep.deviceId()).is(SoamDmProgrammable.class)) {
        throw new CfmConfigException("Device " + mep.deviceId() + " from MEP :" + mdName + "/" + maName + "/" + mepId + " does not implement SoamDmProgrammable");
    }
    log.debug("Retrieving Current Stats for DM {} in MD {}, MA {}, MEP {} " + "on Device {}", dmId, mdName, maName, mepId, mep.deviceId());
    return deviceService.getDevice(mep.deviceId()).as(SoamDmProgrammable.class).getDmCurrentStat(mdName, maName, mepId, dmId);
}
Also used : SoamDmProgrammable(org.onosproject.incubator.net.l2monitoring.soam.SoamDmProgrammable) MepEntry(org.onosproject.incubator.net.l2monitoring.cfm.MepEntry) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException)

Example 2 with MepEntry

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

the class SoamManager method getDm.

@Override
public DelayMeasurementEntry getDm(MdId mdName, MaIdShort maName, MepId mepId, SoamId dmId) throws CfmConfigException, SoamConfigException {
    MepEntry mep = cfmMepService.getMep(mdName, maName, mepId);
    if (mep == null || mep.deviceId() == null) {
        throw new CfmConfigException("MEP :" + mdName + "/" + maName + "/" + mepId + " does not exist");
    } else if (deviceService.getDevice(mep.deviceId()) == null) {
        throw new CfmConfigException("Device " + mep.deviceId() + " from MEP :" + mdName + "/" + maName + "/" + mepId + " does not exist");
    } else if (!deviceService.getDevice(mep.deviceId()).is(SoamDmProgrammable.class)) {
        throw new CfmConfigException("Device " + mep.deviceId() + " from MEP :" + mdName + "/" + maName + "/" + mepId + " does not implement SoamDmProgrammable");
    }
    log.debug("Retrieving DM for DM {} in MD {}, MA {}, MEP {} on Device {}", dmId, mdName, maName, mepId, mep.deviceId());
    return deviceService.getDevice(mep.deviceId()).as(SoamDmProgrammable.class).getDm(mdName, maName, mepId, dmId);
}
Also used : SoamDmProgrammable(org.onosproject.incubator.net.l2monitoring.soam.SoamDmProgrammable) MepEntry(org.onosproject.incubator.net.l2monitoring.cfm.MepEntry) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException)

Example 3 with MepEntry

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

the class SoamManager method getDmHistoricalStats.

@Override
public Collection<DelayMeasurementStatHistory> getDmHistoricalStats(MdId mdName, MaIdShort maName, MepId mepId, SoamId dmId) throws SoamConfigException, CfmConfigException {
    MepEntry mep = cfmMepService.getMep(mdName, maName, mepId);
    if (mep == null || mep.deviceId() == null) {
        throw new CfmConfigException("MEP :" + mdName + "/" + maName + "/" + mepId + " does not exist");
    } else if (deviceService.getDevice(mep.deviceId()) == null) {
        throw new CfmConfigException("Device " + mep.deviceId() + " from MEP :" + mdName + "/" + maName + "/" + mepId + " does not exist");
    } else if (!deviceService.getDevice(mep.deviceId()).is(SoamDmProgrammable.class)) {
        throw new CfmConfigException("Device " + mep.deviceId() + " from MEP :" + mdName + "/" + maName + "/" + mepId + " does not implement SoamDmProgrammable");
    }
    log.debug("Retrieving History Stats for DM {} in MD {}, MA {}, MEP {} " + "on Device {}", dmId, mdName, maName, mepId, mep.deviceId());
    return deviceService.getDevice(mep.deviceId()).as(SoamDmProgrammable.class).getDmHistoricalStats(mdName, maName, mepId, dmId);
}
Also used : SoamDmProgrammable(org.onosproject.incubator.net.l2monitoring.soam.SoamDmProgrammable) MepEntry(org.onosproject.incubator.net.l2monitoring.cfm.MepEntry) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException)

Example 4 with MepEntry

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

the class SoamManagerTest method testCreateDmNoBehavior.

@Test
public void testCreateDmNoBehavior() throws CfmConfigException, SoamConfigException {
    final DeviceId deviceId3 = DeviceId.deviceId("netconf:3.2.3.4:830");
    final MepId mepId3 = MepId.valueOf((short) 3);
    Map<Class<? extends Behaviour>, Class<? extends Behaviour>> behaviours = new HashMap<>();
    behaviours.put(DeviceDescriptionDiscovery.class, TestDeviceDiscoveryBehavior.class);
    Driver testDriver3 = new DefaultDriver(TEST_DRIVER_3, new ArrayList<Driver>(), TEST_MFR, TEST_HW_VERSION, TEST_SW_3, behaviours, new HashMap<>());
    Device device3 = new DefaultDevice(ProviderId.NONE, deviceId3, Device.Type.SWITCH, TEST_MFR, TEST_HW_VERSION, TEST_SW_3, TEST_SN, new ChassisId(2), DefaultAnnotations.builder().set(AnnotationKeys.DRIVER, TEST_DRIVER_3).build());
    expect(deviceService.getDevice(deviceId3)).andReturn(device3).anyTimes();
    replay(deviceService);
    MepEntry mep3 = DefaultMepEntry.builder(mepId3, deviceId3, PortNumber.P0, Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).buildEntry();
    expect(mepService.getMep(MDNAME1, MANAME1, mepId3)).andReturn(mep3).anyTimes();
    replay(mepService);
    expect(driverService.getDriver(deviceId3)).andReturn(testDriver3).anyTimes();
    replay(driverService);
    DelayMeasurementCreate dmCreate1 = DefaultDelayMeasurementCreate.builder(DelayMeasurementCreate.DmType.DM1DMTX, DelayMeasurementCreate.Version.Y17312011, MepId.valueOf((short) 11), Mep.Priority.PRIO3).binsPerFdInterval((short) 4).binsPerFdrInterval((short) 5).binsPerIfdvInterval((short) 6).build();
    try {
        soamManager.createDm(MDNAME1, MANAME1, mepId3, dmCreate1);
        fail("Expecting exception since device does not support behavior");
    } catch (CfmConfigException e) {
        assertEquals("Device netconf:3.2.3.4:830 from MEP :md-1/" + "ma-1-1/3 does not implement SoamDmProgrammable", e.getMessage());
    }
}
Also used : ChassisId(org.onlab.packet.ChassisId) Behaviour(org.onosproject.net.driver.Behaviour) HashMap(java.util.HashMap) DeviceId(org.onosproject.net.DeviceId) DefaultDevice(org.onosproject.net.DefaultDevice) Device(org.onosproject.net.Device) DefaultDevice(org.onosproject.net.DefaultDevice) Driver(org.onosproject.net.driver.Driver) DefaultDriver(org.onosproject.net.driver.DefaultDriver) MepEntry(org.onosproject.incubator.net.l2monitoring.cfm.MepEntry) DefaultMepEntry(org.onosproject.incubator.net.l2monitoring.cfm.DefaultMepEntry) DefaultDriver(org.onosproject.net.driver.DefaultDriver) DelayMeasurementCreate(org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate) DefaultDelayMeasurementCreate(org.onosproject.incubator.net.l2monitoring.soam.delay.DefaultDelayMeasurementCreate) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException) MepId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId) Test(org.junit.Test)

Example 5 with MepEntry

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

the class CfmMepManagerTest method testGetMep.

@Test
public void testGetMep() throws CfmConfigException {
    expect(mdService.getMaintenanceAssociation(MDNAME1, MANAME1)).andReturn(Optional.ofNullable(ma1)).anyTimes();
    replay(mdService);
    expect(deviceService.getDevice(DEVICE_ID1)).andReturn(device1).anyTimes();
    replay(deviceService);
    expect(driverService.getDriver(DEVICE_ID1)).andReturn(testDriver).anyTimes();
    replay(driverService);
    MepEntry mepEntry = mepManager.getMep(MDNAME1, MANAME1, MEPID1);
    assertEquals(MEPID1.value(), mepEntry.mepId().value());
}
Also used : MepEntry(org.onosproject.incubator.net.l2monitoring.cfm.MepEntry) Test(org.junit.Test)

Aggregations

MepEntry (org.onosproject.incubator.net.l2monitoring.cfm.MepEntry)15 CfmConfigException (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException)9 Test (org.junit.Test)6 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)5 DefaultMepEntry (org.onosproject.incubator.net.l2monitoring.cfm.DefaultMepEntry)5 SoamDmProgrammable (org.onosproject.incubator.net.l2monitoring.soam.SoamDmProgrammable)4 ArrayList (java.util.ArrayList)3 WebTarget (javax.ws.rs.client.WebTarget)3 MaIdShort (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort)3 MdId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId)3 CfmMepService (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMepService)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Consumes (javax.ws.rs.Consumes)2 GET (javax.ws.rs.GET)2 Produces (javax.ws.rs.Produces)2 Response (javax.ws.rs.core.Response)2 CfmCodecContext (org.onosproject.cfm.CfmCodecContext)2 CfmResourceTest (org.onosproject.cfm.impl.CfmResourceTest)2 Mep (org.onosproject.incubator.net.l2monitoring.cfm.Mep)2