Adding evc-remove and evc-remove-all commands
Change-Id: I42bbff6c20e04742a723f265805d5d3799535389
diff --git a/.gitignore b/.gitignore
index a4f1f28..c50367d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,4 @@
target
*.iml
.idea
+*.DS_Store
diff --git a/global/ce-orchestration/src/main/java/org/opencord/ce/global/orchestration/cli/commands/CarrierEthernetRemoveEvcAllCommand.java b/global/ce-orchestration/src/main/java/org/opencord/ce/global/orchestration/cli/commands/CarrierEthernetRemoveEvcAllCommand.java
new file mode 100644
index 0000000..e677b66
--- /dev/null
+++ b/global/ce-orchestration/src/main/java/org/opencord/ce/global/orchestration/cli/commands/CarrierEthernetRemoveEvcAllCommand.java
@@ -0,0 +1,41 @@
+/*
+ * 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.opencord.ce.global.orchestration.cli.commands;
+
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.cli.AbstractShellCommand;
+import org.opencord.ce.api.services.MetroOrchestrationService;
+
+/**
+ * CLI command for removing a single Ethernet Virtual Connection.
+ */
+
+@Command(scope = "onos", name = "ce-evc-remove-all", description = "Carrier Ethernet all EVC removal command")
+public class CarrierEthernetRemoveEvcAllCommand extends AbstractShellCommand {
+
+ @Override
+ protected void execute() {
+ MetroOrchestrationService ceManager = get(MetroOrchestrationService.class);
+ final int size = ceManager.evcMap().size();
+ if (size == 0) {
+ print("No EVCs were found");
+ } else {
+ ceManager.removeAllEvcs();
+ print("Removed all %d EVCs", size);
+ }
+ }
+}
\ No newline at end of file
diff --git a/global/ce-orchestration/src/main/java/org/opencord/ce/global/orchestration/cli/commands/CarrierEthernetRemoveEvcCommand.java b/global/ce-orchestration/src/main/java/org/opencord/ce/global/orchestration/cli/commands/CarrierEthernetRemoveEvcCommand.java
new file mode 100644
index 0000000..ebcd69f
--- /dev/null
+++ b/global/ce-orchestration/src/main/java/org/opencord/ce/global/orchestration/cli/commands/CarrierEthernetRemoveEvcCommand.java
@@ -0,0 +1,53 @@
+/*
+ * 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.opencord.ce.global.orchestration.cli.commands;
+
+import com.google.common.collect.Lists;
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+
+import org.onosproject.cli.AbstractShellCommand;
+import org.opencord.ce.api.models.EvcConnId;
+import org.opencord.ce.api.services.MetroOrchestrationService;
+
+import java.util.List;
+
+/**
+ * CLI command for removing a list of Ethernet Virtual Connections.
+ */
+
+@Command(scope = "onos", name = "ce-evc-remove", description = "Carrier Ethernet specific EVC removal command")
+public class CarrierEthernetRemoveEvcCommand extends AbstractShellCommand {
+
+ @Argument(index = 0, name = "argEvcIdList",
+ description = "EVC ID List", required = true, multiValued = true)
+ List<String> argEvcConnIdList = Lists.newArrayList();
+
+ @Override
+ protected void execute() {
+ MetroOrchestrationService ceManager = get(MetroOrchestrationService.class);
+ argEvcConnIdList.forEach(id -> {
+ EvcConnId evcId = EvcConnId.of(id);
+ if (ceManager.evcMap().containsKey(evcId)) {
+ ceManager.removeEvc(evcId);
+ print("Removed EVC %s", evcId.toString());
+ } else {
+ print("EVC %s doesn't exist", evcId.toString());
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/global/ce-orchestration/src/main/java/org/opencord/ce/global/orchestration/cli/completers/CarrierEthernetEvcConnIdCompleter.java b/global/ce-orchestration/src/main/java/org/opencord/ce/global/orchestration/cli/completers/CarrierEthernetEvcConnIdCompleter.java
new file mode 100644
index 0000000..0aa2f96
--- /dev/null
+++ b/global/ce-orchestration/src/main/java/org/opencord/ce/global/orchestration/cli/completers/CarrierEthernetEvcConnIdCompleter.java
@@ -0,0 +1,49 @@
+/*
+ * 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.opencord.ce.global.orchestration.cli.completers;
+
+import org.apache.karaf.shell.console.completer.StringsCompleter;
+import org.onosproject.cli.AbstractCompleter;
+import org.onosproject.cli.AbstractShellCommand;
+
+import org.opencord.ce.api.models.EvcConnId;
+import org.opencord.ce.api.services.MetroOrchestrationService;
+
+import java.util.List;
+import java.util.SortedSet;
+
+/**
+ * EVC ID completer excluding EVC IDs already included in the preceding argument list.
+ * */
+
+public class CarrierEthernetEvcConnIdCompleter extends AbstractCompleter {
+
+ @Override
+ public int complete(String buffer, int cursor, List<String> candidates) {
+
+ StringsCompleter delegate = new UniqueStringsCompleter();
+ SortedSet<String> strings = delegate.getStrings();
+
+ MetroOrchestrationService ceManager = AbstractShellCommand.get(MetroOrchestrationService.class);
+ for (EvcConnId evcConnId : ceManager.evcMap().keySet()) {
+ strings.add(evcConnId.toString());
+ }
+
+ return delegate.complete(buffer, cursor, candidates);
+ }
+
+}
diff --git a/global/ce-orchestration/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/global/ce-orchestration/src/main/resources/OSGI-INF/blueprint/shell-config.xml
index ea08bbd..bc5d745 100644
--- a/global/ce-orchestration/src/main/resources/OSGI-INF/blueprint/shell-config.xml
+++ b/global/ce-orchestration/src/main/resources/OSGI-INF/blueprint/shell-config.xml
@@ -31,9 +31,19 @@
<command>
<action class="org.opencord.ce.global.orchestration.cli.commands.CarrierEthernetListEvcsCommand"/>
</command>
+ <command>
+ <action class="org.opencord.ce.global.orchestration.cli.commands.CarrierEthernetRemoveEvcAllCommand"/>
+ </command>
+ <command>
+ <action class="org.opencord.ce.global.orchestration.cli.commands.CarrierEthernetRemoveEvcCommand"/>
+ <completers>
+ <ref component-id="carrierEthernetEvcConnIdCompleter"/>
+ </completers>
+ </command>
</command-bundle>
<bean id="placeholderCompleter" class="org.onosproject.cli.PlaceholderCompleter"/>
+ <bean id="carrierEthernetEvcConnIdCompleter" class="org.opencord.ce.global.orchestration.cli.completers.CarrierEthernetEvcConnIdCompleter"/>
<bean id="carrierEthernetEvcTypeCompleter" class="org.opencord.ce.global.orchestration.cli.completers.CarrierEthernetEvcTypeCompleter"/>
<bean id="carrierEthernetUniCompleter" class="org.opencord.ce.global.orchestration.cli.completers.CarrierEthernetUniCompleter"/>
<bean id="carrierEthernetValidUniCompleter" class="org.opencord.ce.global.orchestration.cli.completers.CarrierEthernetValidUniCompleter"/>
diff --git a/global/http-channel/src/main/java/org/opencord/ce/global/channel/client/HttpClientInstance.java b/global/http-channel/src/main/java/org/opencord/ce/global/channel/client/HttpClientInstance.java
index 4c17837..6fdb8e9 100644
--- a/global/http-channel/src/main/java/org/opencord/ce/global/channel/client/HttpClientInstance.java
+++ b/global/http-channel/src/main/java/org/opencord/ce/global/channel/client/HttpClientInstance.java
@@ -86,7 +86,7 @@
private final ExecutorService networkExecutor =
newSingleThreadExecutor();
- // newFixedThreadPool(5, groupedThreads("opencord/ecord-http", "event-handler"));
+ // newFixedThreadPool(5, groupedThreads("opencord/ecord-http", "event-handler"));
public void configure(ClusterService clusterService, LeadershipService leadershipService,
DomainService domainService, Set<DomainEndPoint> endPoints) {
@@ -260,15 +260,15 @@
if (isLeader(getTopic(domainId))) {
networkExecutor.execute(new NetworkTask(domainId, DELETE, resource,
null, new RequestCallback() {
- @Override
- public void onSuccess(Response response) {
+ @Override
+ public void onSuccess(Response response) {
- }
+ }
- @Override
- public void onError(Response response) {
+ @Override
+ public void onError(Response response) {
- }
+ }
}));
}
});
diff --git a/local/http-channel/src/main/java/org/opencord/ce/local/channel/server/MetroNetworkResource.java b/local/http-channel/src/main/java/org/opencord/ce/local/channel/server/MetroNetworkResource.java
index acd04cd..3d194da 100644
--- a/local/http-channel/src/main/java/org/opencord/ce/local/channel/server/MetroNetworkResource.java
+++ b/local/http-channel/src/main/java/org/opencord/ce/local/channel/server/MetroNetworkResource.java
@@ -28,8 +28,8 @@
import org.slf4j.Logger;
import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
import javax.ws.rs.POST;
+import javax.ws.rs.DELETE;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
@@ -77,7 +77,7 @@
niCodec.decode((ObjectNode) responseBody.path(SRC_NI), this);
Set<CarrierEthernetNetworkInterface> dstNiSet = new HashSet<>();
responseBody.path(DST_NI_LIST).forEach(jsonDstNi ->
- dstNiSet.add(niCodec.decode((ObjectNode) jsonDstNi, this)));
+ dstNiSet.add(niCodec.decode((ObjectNode) jsonDstNi, this)));
localNodeService.setNodeForwarding(fc, srcNi, dstNiSet);
return Response.status(200).build();
@@ -124,9 +124,9 @@
log.info(responseBody.toString());
CarrierEthernetForwardingConstruct fc =
- fcCodec.decode((ObjectNode) responseBody.path(FC), this);
+ fcCodec.decode((ObjectNode) responseBody.path(FC), this);
CarrierEthernetUni uni = (CarrierEthernetUni)
- niCodec.decode((ObjectNode) responseBody.path(UNI), this);
+ niCodec.decode((ObjectNode) responseBody.path(UNI), this);
localNodeService.applyBandwidthProfileResources(fc, uni);
return Response.status(200).build();
@@ -164,7 +164,7 @@
@Path("deleteFcResources/{fcId}")
@Produces(MediaType.APPLICATION_JSON)
- @GET
+ @DELETE
public Response removeAllForwardingResources(@PathParam("{fcId}") String fcId) {
EvcConnId evcId = EvcConnId.of(fcId);
MetroNetworkVirtualNodeService localNodeService =