use of org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate 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());
}
}
use of org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate in project onos by opennetworkinglab.
the class DmCreateCodecTest method testDecodeObjectNodeCodecContext2.
@Test
public void testDecodeObjectNodeCodecContext2() throws JsonProcessingException, IOException {
String moStr = "{\"dm\": {" + "\"version\":\"Y17312008\"," + "\"dmType\":\"DMDMM\"," + "\"remoteMepId\":12," + "\"priority\":\"PRIO6\"," + "\"measurementsEnabled\" :" + "[\"FRAME_DELAY_RANGE_BACKWARD_AVERAGE\", " + "\"INTER_FRAME_DELAY_VARIATION_FORWARD_AVERAGE\"]" + "}}";
InputStream input = new ByteArrayInputStream(moStr.getBytes(StandardCharsets.UTF_8));
JsonNode cfg = mapper.readTree(input);
DelayMeasurementCreate dmCreate = context.codec(DelayMeasurementCreate.class).decode((ObjectNode) cfg, context);
assertEquals(Version.Y17312008, dmCreate.version());
assertEquals(DmType.DMDMM, dmCreate.dmCfgType());
assertEquals(12, dmCreate.remoteMepId().id().shortValue());
}
use of org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate in project onos by opennetworkinglab.
the class SoamManagerTest method testCreateDm.
@Test
public void testCreateDm() throws CfmConfigException, SoamConfigException {
expect(deviceService.getDevice(DEVICE_ID1)).andReturn(device1).anyTimes();
replay(deviceService);
expect(mepService.getMep(MDNAME1, MANAME1, MEPID1)).andReturn(mep1).anyTimes();
replay(mepService);
expect(driverService.getDriver(DEVICE_ID1)).andReturn(testDriver).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();
assertEquals(1000, soamManager.createDm(MDNAME1, MANAME1, MEPID1, dmCreate1).get().value());
}
use of org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate in project onos by opennetworkinglab.
the class DmWebResource method createDm.
/**
* Create DM with MD name, MA name, Mep id and DM Json.
*
* @onos.rsModel DmCreate
* @param mdName The name of a Maintenance Domain
* @param maName The name of a Maintenance Association belonging to the MD
* @param mepId The Id of the MEP belonging to the MEP
* @param input A JSON formatted input stream specifying the DM parameters
* @return 201 Created or 304 if already exists or 500 on error
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createDm(@PathParam("md_name") String mdName, @PathParam("ma_name") String maName, @PathParam("mep_id") short mepId, InputStream input) {
log.debug("POST called to Create Dm");
try {
MdId mdId = MdIdCharStr.asMdId(mdName);
MaIdShort maId = MaIdCharStr.asMaId(maName);
MepId mepIdObj = MepId.valueOf(mepId);
Mep mep = get(CfmMepService.class).getMep(mdId, maId, mepIdObj);
if (mep == null) {
return Response.serverError().entity("{ \"failure\":\"mep " + mdName + "/" + maName + "/" + mepId + " does not exist\" }").build();
}
ObjectMapper mapper = new ObjectMapper();
JsonNode cfg = readTreeFromStream(mapper, input);
JsonCodec<DelayMeasurementCreate> dmCodec = codec(DelayMeasurementCreate.class);
DelayMeasurementCreate dm = dmCodec.decode((ObjectNode) cfg, this);
get(SoamService.class).createDm(mdId, maId, mepIdObj, dm);
return Response.created(new URI("md/" + mdName + "/ma/" + maName + "/mep/" + mepId + "/dm")).entity("{ \"success\":\"dm " + mdName + "/" + maName + "/" + mepId + " created\" }").build();
} catch (CfmConfigException | SoamConfigException | IllegalArgumentException | IOException | URISyntaxException e) {
log.error("Create DM on " + mdName + "/" + maName + "/" + mepId + " failed because of exception {}", e.toString());
return Response.serverError().entity("{ \"failure\":\"" + e.toString() + "\" }").build();
}
}
Aggregations