[ONOS-7262] Cfm improvements to allow RMeps and Mds and Mas to be added and deleted
Change-Id: Ibffb13d046bfb29dbe88de7b558c95fbf9db046d
diff --git a/apps/cfm/src/main/java/org/onosproject/cfm/cli/CfmMdListMdCommand.java b/apps/cfm/src/main/java/org/onosproject/cfm/cli/CfmMdListMdCommand.java
index 341bd7d..f3c5b6e 100644
--- a/apps/cfm/src/main/java/org/onosproject/cfm/cli/CfmMdListMdCommand.java
+++ b/apps/cfm/src/main/java/org/onosproject/cfm/cli/CfmMdListMdCommand.java
@@ -20,6 +20,12 @@
import org.onosproject.cli.AbstractShellCommand;
import org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation;
import org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain;
+import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaId2Octet;
+import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdCharStr;
+import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdIccY1731;
+import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdPrimaryVid;
+import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdRfc2685VpnId;
+import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort;
import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId;
import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdIdCharStr;
import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdIdDomainName;
@@ -45,29 +51,7 @@
CfmMdService service = get(CfmMdService.class);
if (name != null) {
- 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 = null;
- MdId.MdNameType nameTypeEnum = MdId.MdNameType.valueOf(nameParts[1]);
- switch (nameTypeEnum) {
- case DOMAINNAME:
- mdId = MdIdDomainName.asMdId(nameParts[0]);
- break;
- case MACANDUINT:
- mdId = MdIdMacUint.asMdId(nameParts[0]);
- break;
- case NONE:
- mdId = MdIdNone.asMdId();
- break;
- case CHARACTERSTRING:
- default:
- mdId = MdIdCharStr.asMdId(nameParts[0]);
- }
-
+ MdId mdId = parseMdName(name);
print("Maintenance Domain:");
Optional<MaintenanceDomain> md = service.getMaintenanceDomain(mdId);
print(printMd(md));
@@ -131,4 +115,59 @@
return sb.toString();
}
+
+ public static MdId parseMdName(String mdStr) {
+ String[] nameParts = mdStr.split("[()]");
+ if (nameParts.length != 2) {
+ throw new IllegalArgumentException("Invalid name format. " +
+ "Must be in the format of <identifier(name-type)>");
+ }
+
+ MdId mdId = null;
+ MdId.MdNameType nameTypeEnum = MdId.MdNameType.valueOf(nameParts[1]);
+ switch (nameTypeEnum) {
+ case DOMAINNAME:
+ mdId = MdIdDomainName.asMdId(nameParts[0]);
+ break;
+ case MACANDUINT:
+ mdId = MdIdMacUint.asMdId(nameParts[0]);
+ break;
+ case NONE:
+ mdId = MdIdNone.asMdId();
+ break;
+ case CHARACTERSTRING:
+ default:
+ mdId = MdIdCharStr.asMdId(nameParts[0]);
+ }
+ return mdId;
+ }
+
+ public static MaIdShort parseMaName(String maStr) {
+ String[] nameParts = maStr.split("[()]");
+ if (nameParts.length != 2) {
+ throw new IllegalArgumentException("Invalid name format. " +
+ "Must be in the format of <identifier(name-type)>");
+ }
+
+ MaIdShort maId = null;
+ MaIdShort.MaIdType nameTypeEnum = MaIdShort.MaIdType.valueOf(nameParts[1]);
+ switch (nameTypeEnum) {
+ case ICCY1731:
+ maId = MaIdIccY1731.asMaId(nameParts[0]);
+ break;
+ case PRIMARYVID:
+ maId = MaIdPrimaryVid.asMaId(nameParts[0]);
+ break;
+ case RFC2685VPNID:
+ maId = MaIdRfc2685VpnId.asMaIdHex(nameParts[0]);
+ break;
+ case TWOOCTET:
+ maId = MaId2Octet.asMaId(nameParts[0]);
+ case CHARACTERSTRING:
+ default:
+ maId = MaIdCharStr.asMaId(nameParts[0]);
+ }
+ return maId;
+ }
+
}
diff --git a/apps/cfm/src/main/java/org/onosproject/cfm/cli/CfmMepListCommand.java b/apps/cfm/src/main/java/org/onosproject/cfm/cli/CfmMepListCommand.java
new file mode 100644
index 0000000..b406947
--- /dev/null
+++ b/apps/cfm/src/main/java/org/onosproject/cfm/cli/CfmMepListCommand.java
@@ -0,0 +1,173 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.cfm.cli;
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.incubator.net.l2monitoring.cfm.MepEntry;
+import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort;
+import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId;
+import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId;
+import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepKeyId;
+import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException;
+import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService;
+import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMepService;
+import org.slf4j.Logger;
+
+import static org.onosproject.cfm.cli.CfmMdListMdCommand.parseMaName;
+import static org.onosproject.cfm.cli.CfmMdListMdCommand.parseMdName;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Lists a particular Maintenance Domain.
+ */
+@Command(scope = "onos", name = "cfm-mep-list",
+ description = "Lists a filtered set of MEPs or all if no parameters specified.")
+public class CfmMepListCommand extends AbstractShellCommand {
+ private final Logger log = getLogger(getClass());
+ @Argument(index = 0, name = "md",
+ description = "Maintenance Domain name and type (in brackets) - will use all MDs if not specified",
+ required = false, multiValued = false)
+ String mdStr = null;
+ @Argument(index = 1, name = "ma",
+ description = "Maintenance Association name and type (in brackets) - requires MD",
+ required = false, multiValued = false)
+ String maStr = null;
+ @Argument(index = 2, name = "mep",
+ description = "MEP identifier - requires MD and MA",
+ required = false, multiValued = false)
+ String mepStr = null;
+
+ @Override
+ protected void execute() {
+ 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);
+ }
+ });
+ });
+ }
+ }
+
+ /**
+ * Print the whole MEP Entry (config and status).
+ * @param mep The MEPEntry to print
+ * @return A string with MepEntry details
+ */
+ public static String printMepEntry(MepEntry mep) {
+ StringBuffer sb = new StringBuffer("MEP: ");
+ sb.append(mep.mepId());
+ sb.append(" Device:" + mep.deviceId());
+ sb.append(", Port: " + mep.port());
+ sb.append(", Vlan: " + mep.primaryVid());
+ sb.append(", AdminSt: " + mep.administrativeState());
+ sb.append(", CciEnabled: " + mep.cciEnabled());
+ sb.append(", Priority: " + mep.ccmLtmPriority());
+ sb.append("\n"); //The following are state
+ sb.append(", Total CCMs: " + mep.totalCcmsTransmitted());
+ sb.append(", MAC: " + mep.macAddress());
+ sb.append(", Fault: " + mep.fngState());
+
+ mep.activeRemoteMepList().forEach(rmep -> {
+ sb.append("\n\tRmep: " + rmep.remoteMepId());
+ sb.append(", Mac: " + rmep.macAddress());
+ sb.append(", State: " + rmep.state());
+ sb.append(", Failed Time: " + rmep.failedOrOkTime());
+
+ });
+
+
+ return sb.toString();
+ }
+
+ public static String printMdId(MdId mdId) {
+ StringBuffer sb = new StringBuffer("MD: ");
+ sb.append(mdId.mdName());
+ sb.append("(" + mdId.nameType() + ")");
+ return sb.toString();
+ }
+
+ public static String printMaId(MaIdShort maId) {
+ StringBuffer sb = new StringBuffer("MA: ");
+ sb.append(maId.maName());
+ sb.append("(" + maId.nameType() + ")");
+ return sb.toString();
+ }
+
+}
diff --git a/apps/cfm/src/main/java/org/onosproject/cfm/cli/CfmMepListDeviceCommand.java b/apps/cfm/src/main/java/org/onosproject/cfm/cli/CfmMepListDeviceCommand.java
new file mode 100644
index 0000000..c99399a
--- /dev/null
+++ b/apps/cfm/src/main/java/org/onosproject/cfm/cli/CfmMepListDeviceCommand.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.cfm.cli;
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.incubator.net.l2monitoring.cfm.Mep;
+import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException;
+import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMepService;
+import org.onosproject.net.DeviceId;
+import org.slf4j.Logger;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Lists all the MEPs on a particular device.
+ */
+@Command(scope = "onos", name = "cfm-mep-device-list",
+ description = "Lists a set of MEPs filtered by device.")
+public class CfmMepListDeviceCommand extends AbstractShellCommand {
+ private final Logger log = getLogger(getClass());
+ @Argument(index = 0, name = "device",
+ description = "Device Id",
+ required = true, multiValued = false)
+ String deviceStr = null;
+
+ @Override
+ protected void execute() {
+ CfmMepService mepService = get(CfmMepService.class);
+ if (deviceStr != null) {
+ DeviceId deviceId = DeviceId.deviceId(deviceStr);
+ try {
+ mepService.getAllMepsByDevice(deviceId).forEach(mep -> {
+ print(printMep(mep));
+ });
+ } catch (CfmConfigException e) {
+ log.error("Error retrieving Meps for Device {}",
+ deviceId, e);
+ }
+ }
+ }
+
+ /**
+ * Print only the config part of the MEP.
+ * @param mep The MEP to print
+ * @return A string with MD name, MA name and Mep details
+ */
+ public static String printMep(Mep mep) {
+ StringBuffer sb = new StringBuffer("MEP: ");
+ sb.append(mep.mdId().mdName() + "/");
+ sb.append(mep.maId().maName() + "/");
+ sb.append(mep.mepId());
+ sb.append(" Device:" + mep.deviceId());
+ sb.append(", Port: " + mep.port());
+ sb.append(", Vlan: " + mep.primaryVid());
+ sb.append(", AdminSt: " + mep.administrativeState());
+ sb.append(", CciEnabled: " + mep.cciEnabled());
+ sb.append(", Priority: " + mep.ccmLtmPriority());
+
+ return sb.toString();
+ }
+
+}
diff --git a/apps/cfm/src/main/java/org/onosproject/cfm/cli/completer/CfmDeviceIdCompleter.java b/apps/cfm/src/main/java/org/onosproject/cfm/cli/completer/CfmDeviceIdCompleter.java
new file mode 100644
index 0000000..6e2e29f
--- /dev/null
+++ b/apps/cfm/src/main/java/org/onosproject/cfm/cli/completer/CfmDeviceIdCompleter.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.cfm.cli.completer;
+
+import org.apache.karaf.shell.console.Completer;
+import org.apache.karaf.shell.console.completer.StringsCompleter;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMepProgrammable;
+import org.onosproject.net.Device;
+import org.onosproject.net.device.DeviceService;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.SortedSet;
+
+/**
+ * CLI completer for Devices that support Meps.
+ */
+public class CfmDeviceIdCompleter implements Completer {
+ @Override
+ public int complete(String buffer, int cursor, List<String> candidates) {
+ // Delegate string completer
+ StringsCompleter delegate = new StringsCompleter();
+
+ // Fetch our service and feed it's offerings to the string completer
+ DeviceService service = AbstractShellCommand.get(DeviceService.class);
+ Iterator<Device> it = service.getDevices().iterator();
+ SortedSet<String> strings = delegate.getStrings();
+ while (it.hasNext()) {
+ Device device = it.next();
+ if (device.is(CfmMepProgrammable.class)) {
+ strings.add(device.id().toString());
+ }
+ }
+
+ // Now let the completer do the work for figuring out what to offer.
+ return delegate.complete(buffer, cursor, candidates);
+ }
+}
diff --git a/apps/cfm/src/main/java/org/onosproject/cfm/cli/completer/CfmMepIdCompleter.java b/apps/cfm/src/main/java/org/onosproject/cfm/cli/completer/CfmMepIdCompleter.java
new file mode 100644
index 0000000..6019916
--- /dev/null
+++ b/apps/cfm/src/main/java/org/onosproject/cfm/cli/completer/CfmMepIdCompleter.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.cfm.cli.completer;
+
+import org.onosproject.cli.AbstractChoicesCompleter;
+import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException;
+import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService;
+import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMepService;
+import org.slf4j.Logger;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.onosproject.cli.AbstractShellCommand.get;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * CLI completer for Mep Id creation.
+ */
+public class CfmMepIdCompleter extends AbstractChoicesCompleter {
+ private final Logger log = getLogger(getClass());
+
+ @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(new StringBuilder(md.mdId().mdName())
+ .append("(")
+ .append(md.mdId().nameType())
+ .append(")").toString());
+
+ md.maintenanceAssociationList().forEach(ma -> {
+ choices.add(new StringBuilder(md.mdId().mdName())
+ .append("(")
+ .append(md.mdId().nameType())
+ .append(") ")
+ .append(ma.maId().maName())
+ .append("(")
+ .append(ma.maId().nameType())
+ .append(")").toString());
+
+ try {
+ mepService.getAllMeps(md.mdId(), ma.maId()).forEach(mep ->
+ choices.add(new StringBuilder(md.mdId().mdName())
+ .append("(")
+ .append(md.mdId().nameType())
+ .append(") ")
+ .append(ma.maId().maName())
+ .append("(")
+ .append(ma.maId().nameType())
+ .append(") ")
+ .append(mep.mepId()).toString())
+ );
+ } catch (CfmConfigException e) {
+ log.warn("Unable to retrieve mep details", e);
+ }
+ }
+ );
+ });
+
+ return choices;
+ }
+
+}
diff --git a/apps/cfm/src/main/java/org/onosproject/cfm/rest/CfmWebApplication.java b/apps/cfm/src/main/java/org/onosproject/cfm/rest/CfmWebApplication.java
index 13157f2..b32174e 100644
--- a/apps/cfm/src/main/java/org/onosproject/cfm/rest/CfmWebApplication.java
+++ b/apps/cfm/src/main/java/org/onosproject/cfm/rest/CfmWebApplication.java
@@ -32,6 +32,7 @@
MdWebResource.class,
MaWebResource.class,
MepWebResource.class,
+ DeviceMepWebResource.class,
DmWebResource.class,
LmWebResource.class);
}
diff --git a/apps/cfm/src/main/java/org/onosproject/cfm/rest/DeviceMepWebResource.java b/apps/cfm/src/main/java/org/onosproject/cfm/rest/DeviceMepWebResource.java
new file mode 100644
index 0000000..5fbed6d
--- /dev/null
+++ b/apps/cfm/src/main/java/org/onosproject/cfm/rest/DeviceMepWebResource.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.cfm.rest;
+
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import org.onosproject.incubator.net.l2monitoring.cfm.Mep;
+import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException;
+import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMepService;
+import org.onosproject.net.DeviceId;
+import org.onosproject.rest.AbstractWebResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.util.Collection;
+
+/**
+ * Layer 2 CFM Maintenance Association Endpoint (MEP) by Device web resource.
+ */
+@Path("device")
+public class DeviceMepWebResource extends AbstractWebResource {
+
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ /**
+ * Get all MEPs by Device Id. The device should support Meps
+ *
+ * @param deviceId The id of a device.
+ * @return 200 OK with a list of MEPS or 500 on error
+ */
+ @GET
+ @Path("{device_id}")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response getAllMepsForDevice(@PathParam("device_id") String deviceId) {
+ DeviceId deviceIdObj = DeviceId.deviceId(deviceId);
+ log.debug("GET all Meps called for Device {}", deviceIdObj);
+ try {
+ Collection<Mep> mepCollection = get(CfmMepService.class)
+ .getAllMepsByDevice(deviceIdObj);
+ ArrayNode an = mapper().createArrayNode();
+ an.add(codec(Mep.class).encode(mepCollection, this));
+ return ok(mapper().createObjectNode().set("meps", an)).build();
+ } catch (CfmConfigException e) {
+ log.error("Get all Meps on device {} failed because of exception",
+ deviceIdObj, e);
+ return Response.serverError().entity("{ \"failure\":\"" + e.toString() + "\" }").build();
+ }
+ }
+}
diff --git a/apps/cfm/src/main/java/org/onosproject/cfm/rest/MdWebResource.java b/apps/cfm/src/main/java/org/onosproject/cfm/rest/MdWebResource.java
index c642f4a..0e523a7 100644
--- a/apps/cfm/src/main/java/org/onosproject/cfm/rest/MdWebResource.java
+++ b/apps/cfm/src/main/java/org/onosproject/cfm/rest/MdWebResource.java
@@ -82,6 +82,7 @@
log.debug("GET called for MD {}", mdName);
try {
MaintenanceDomain md = get(CfmMdService.class)
+ //FIXME Handle other types of name constructs e.g. DomainName
.getMaintenanceDomain(MdIdCharStr.asMdId(mdName))
.orElseThrow(() -> new IllegalArgumentException(
"MD " + mdName + " not Found"));
diff --git a/apps/cfm/src/main/java/org/onosproject/cfm/rest/MepWebResource.java b/apps/cfm/src/main/java/org/onosproject/cfm/rest/MepWebResource.java
index fa8c728..52d4150 100644
--- a/apps/cfm/src/main/java/org/onosproject/cfm/rest/MepWebResource.java
+++ b/apps/cfm/src/main/java/org/onosproject/cfm/rest/MepWebResource.java
@@ -18,6 +18,7 @@
import java.io.InputStream;
import java.net.URI;
import java.util.Collection;
+import java.util.Optional;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
@@ -145,7 +146,7 @@
MdId mdId = MdIdCharStr.asMdId(mdName);
MaIdShort maId = MaIdCharStr.asMaId(maName);
boolean deleted = get(CfmMepService.class)
- .deleteMep(mdId, maId, MepId.valueOf(mepIdShort));
+ .deleteMep(mdId, maId, MepId.valueOf(mepIdShort), Optional.empty());
if (!deleted) {
return Response.notModified(mdName + "/" + maName + "/" +
mepIdShort + " did not exist").build();
@@ -187,8 +188,8 @@
Mep mep = ((MepCodec) mepCodec).decode((ObjectNode) cfg, this, mdName, maName);
- Boolean issuccess = get(CfmMepService.class).createMep(mdId, maId, mep);
- if (!issuccess) {
+ Boolean didNotExist = get(CfmMepService.class).createMep(mdId, maId, mep);
+ if (!didNotExist) {
return Response.notModified(mdName + "/" + ma.maId() + "/" + mep.mepId() +
" already exists").build();
}
diff --git a/apps/cfm/src/main/java/org/onosproject/cfm/web/MaintenanceAssociationCodec.java b/apps/cfm/src/main/java/org/onosproject/cfm/web/MaintenanceAssociationCodec.java
index 62be35d..6c3829f 100644
--- a/apps/cfm/src/main/java/org/onosproject/cfm/web/MaintenanceAssociationCodec.java
+++ b/apps/cfm/src/main/java/org/onosproject/cfm/web/MaintenanceAssociationCodec.java
@@ -124,10 +124,13 @@
builder = builder.addToComponentList(component);
}
- List<MepId> remoteMeps = (new RMepCodec()).decode(
- (ArrayNode) nullIsIllegal(maNode.get(RMEP_LIST), "rmep-list is required"), context);
- for (MepId remoteMep:remoteMeps) {
- builder = builder.addToRemoteMepIdList(remoteMep);
+ JsonNode rmepListJson = maNode.get(RMEP_LIST);
+ if (rmepListJson != null) {
+ List<MepId> remoteMeps = (new RMepCodec()).decode(
+ (ArrayNode) rmepListJson, context);
+ for (MepId remoteMep:remoteMeps) {
+ builder = builder.addToRemoteMepIdList(remoteMep);
+ }
}
return builder.build();