use of org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId in project onos by opennetworkinglab.
the class CfmMaDeleteCommand method doExecute.
@Override
protected void doExecute() {
CfmMdService service = get(CfmMdService.class);
String[] nameParts = name.split("[()]");
if (nameParts.length != MA_NAME_PARTS_COUNT) {
throw new IllegalArgumentException("Invalid name format. Must be in " + "the format of <identifier(name-type)identifier(name-type)>");
}
MdId mdId = CfmMdListMdCommand.parseMdName(nameParts[0] + "(" + nameParts[1] + ")");
MaIdShort maId = CfmMdListMdCommand.parseMaName(nameParts[2] + "(" + nameParts[3] + ")");
try {
boolean deleted = service.deleteMaintenanceAssociation(mdId, maId);
print("Maintenance Association %s-%s is %ssuccessfully deleted.", mdId, maId, deleted ? "" : "NOT ");
} catch (CfmConfigException e) {
throw new IllegalArgumentException(e);
}
}
use of org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId in project onos by opennetworkinglab.
the class CfmMdDeleteCommand method doExecute.
@Override
protected void doExecute() {
CfmMdService service = get(CfmMdService.class);
String[] nameParts = name.split("[()]");
if (nameParts.length != 2) {
throw new IllegalArgumentException("Invalid name format. " + "Must be in the format of <identifier(name-type)>");
}
MdId mdId = CfmMdListMdCommand.parseMdName(nameParts[0] + "(" + nameParts[1] + ")");
try {
boolean deleted = service.deleteMaintenanceDomain(mdId);
print("Maintenance Domain %s is %ssuccessfully deleted.", mdId, deleted ? "" : "NOT ");
} catch (CfmConfigException e) {
throw new IllegalArgumentException(e);
}
}
use of org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId in project onos by opennetworkinglab.
the class CfmMaAddCommand method doExecute.
@Override
protected void doExecute() {
CfmMdService service = get(CfmMdService.class);
String[] mdNameParts = mdName.split("[()]");
if (mdNameParts.length != 2) {
throw new IllegalArgumentException("Invalid name format. " + "Must be in the format of <identifier(name-type)>");
}
MdId mdId = CfmMdListMdCommand.parseMdName(mdNameParts[0] + "(" + mdNameParts[1] + ")");
MaIdShort maId = CfmMdListMdCommand.parseMaName(name + "(" + nameType + ")");
try {
MaintenanceAssociation.MaBuilder builder = DefaultMaintenanceAssociation.builder(maId, mdId.getNameLength());
if (ccmInterval != null && !ccmInterval.isEmpty()) {
builder = builder.ccmInterval(MaintenanceAssociation.CcmInterval.valueOf(ccmInterval));
}
for (String rmep : rmepArray) {
builder = builder.addToRemoteMepIdList(MepId.valueOf(Short.parseShort(rmep)));
}
if (numericId != null) {
builder = builder.maNumericId(numericId);
}
if (componentId != null) {
Component.ComponentBuilder compBuilder = DefaultComponent.builder(componentId);
if (tagType != null && !tagType.isEmpty()) {
compBuilder = compBuilder.tagType(Component.TagType.valueOf(tagType));
}
if (mhfCreationType != null && !mhfCreationType.isEmpty()) {
compBuilder = compBuilder.mhfCreationType(Component.MhfCreationType.valueOf(mhfCreationType));
}
if (vid != null) {
compBuilder = compBuilder.addToVidList(VlanId.vlanId(vid));
}
builder = builder.addToComponentList(compBuilder.build());
}
boolean created = service.createMaintenanceAssociation(mdId, builder.build());
print("Maintenance Association %s is successfully %s on MD %s", maId, created ? "updated" : "created", mdId);
} catch (CfmConfigException e) {
throw new IllegalArgumentException(e);
}
}
use of org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId in project onos by opennetworkinglab.
the class CfmMdListMdCommand method doExecute.
@Override
protected void doExecute() {
CfmMdService service;
service = get(CfmMdService.class);
if (name != null) {
MdId mdId = parseMdName(name);
print("Maintenance Domain:");
service.getMaintenanceDomain(mdId).ifPresent(md -> {
print(printMd(md));
md.maintenanceAssociationList().forEach(CfmMdListMdCommand::printMa);
});
} else {
service.getAllMaintenanceDomain().forEach(md -> print(printMd(md)));
}
}
use of org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId in project onos by opennetworkinglab.
the class MaWebResource method deleteMa.
/**
* Delete the Maintenance Association by MD and MA name.
*
* @param mdName The name of a Maintenance Domain
* @param maName The name of a Maintenance Association belonging to the MD
* @return 200 OK if removed, 304 if item was not found or 500 on Error
*/
@DELETE
@Path("{ma_name}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response deleteMa(@PathParam("md_name") String mdName, @PathParam("ma_name") String maName) {
log.debug("DELETE called for MA {}/{}", mdName, maName);
try {
MdId mdId = MdIdCharStr.asMdId(mdName);
MaIdShort maId = MaIdCharStr.asMaId(maName);
boolean deleted = get(CfmMdService.class).deleteMaintenanceAssociation(mdId, maId);
if (!deleted) {
return Response.notModified(mdName + "/" + maName + " did not exist").build();
} else {
return ok("{ \"success\":\"deleted " + mdName + "/" + maName + "\" }").build();
}
} catch (CfmConfigException e) {
log.error("Delete Maintenance Association {} failed", mdName + "/" + maName, e);
return Response.serverError().entity("{ \"failure\":\"" + e.toString() + "\" }").build();
}
}
Aggregations