use of org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService in project onos by opennetworkinglab.
the class CfmMdAddCommand method doExecute.
@Override
protected void doExecute() {
CfmMdService service = get(CfmMdService.class);
MdId mdId = CfmMdListMdCommand.parseMdName(name + "(" + nameType + ")");
MaintenanceDomain.MdLevel levelEnum = MaintenanceDomain.MdLevel.valueOf(level);
try {
MaintenanceDomain.MdBuilder builder = DefaultMaintenanceDomain.builder(mdId).mdLevel(levelEnum);
if (numericId != null) {
builder = builder.mdNumericId(numericId);
}
boolean created = service.createMaintenanceDomain(builder.build());
print("Maintenance Domain with id %s is successfully %s.", mdId, created ? "updated" : "created");
} catch (CfmConfigException e) {
throw new IllegalArgumentException(e);
}
}
use of org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService in project onos by opennetworkinglab.
the class CfmMepIdCompleter method choices.
@Override
public List<String> choices() {
List<String> choices = new ArrayList<>();
CfmMdService mdService = get(CfmMdService.class);
CfmMepService mepService = get(CfmMepService.class);
mdService.getAllMaintenanceDomain().forEach(md -> {
choices.add(md.mdId().mdName() + "(" + md.mdId().nameType() + ")");
md.maintenanceAssociationList().forEach(ma -> {
choices.add(md.mdId().mdName() + "(" + md.mdId().nameType() + ") " + ma.maId().maName() + "(" + ma.maId().nameType() + ")");
try {
mepService.getAllMeps(md.mdId(), ma.maId()).forEach(mep -> choices.add(md.mdId().mdName() + "(" + md.mdId().nameType() + ") " + ma.maId().maName() + "(" + ma.maId().nameType() + ") " + mep.mepId()));
} catch (CfmConfigException e) {
log.warn("Unable to retrieve mep details", e);
}
});
});
return choices;
}
use of org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService in project onos by opennetworkinglab.
the class CfmMepListCommand method doExecute.
@Override
protected void doExecute() {
CfmMepService mepService = get(CfmMepService.class);
CfmMdService mdService = get(CfmMdService.class);
if (mdStr != null && !mdStr.isEmpty()) {
MdId mdId = parseMdName(mdStr);
print(printMdId(mdId));
if (maStr != null && !maStr.isEmpty()) {
MaIdShort maId = parseMaName(maStr);
print(printMaId(maId));
if (mepStr != null && !mepStr.isEmpty()) {
MepId mepId = MepId.valueOf(Short.parseShort(mepStr));
try {
MepEntry mep = mepService.getMep(mdId, maId, mepId);
if (mep != null) {
print(printMepEntry(mep));
}
} catch (CfmConfigException e) {
log.error("Error retrieving Mep details {}", new MepKeyId(mdId, maId, mepId), e);
}
// MD, MA and MEP given
} else {
// MD and MA given but no MEP given
try {
mepService.getAllMeps(mdId, maId).forEach(mep -> print(printMepEntry(mep)));
} catch (CfmConfigException e) {
log.error("Error retrieving Meps for {}/{}", mdId.mdName(), maId.maName(), e);
}
}
} else {
// MD given but no MA given
mdService.getAllMaintenanceAssociation(mdId).forEach(ma -> {
print(printMaId(ma.maId()));
try {
mepService.getAllMeps(mdId, ma.maId()).forEach(mep -> print(printMepEntry(mep)));
} catch (CfmConfigException e) {
log.error("Error retrieving Meps for {}/{}", mdId.mdName(), ma.maId().maName(), e);
}
});
}
} else {
mdService.getAllMaintenanceDomain().forEach(md -> {
print(printMdId(md.mdId()));
mdService.getAllMaintenanceAssociation(md.mdId()).forEach(ma -> {
print(printMaId(ma.maId()));
try {
mepService.getAllMeps(md.mdId(), ma.maId()).forEach(mep -> print(printMepEntry(mep)));
} catch (CfmConfigException e) {
log.error("Error retrieving Meps for {}/{}", md.mdId().mdName(), ma.maId().maName(), e);
}
});
});
}
}
use of org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService in project onos by opennetworkinglab.
the class CfmMdNameCompleter method choices.
@Override
public List<String> choices() {
List<String> choices = new ArrayList<>();
CfmMdService service = get(CfmMdService.class);
service.getAllMaintenanceDomain().forEach(md -> choices.add(md.mdId().mdName() + "(" + md.mdId().nameType() + ")"));
return choices;
}
Aggregations