1 package org.opendaylight.alto.manager;
3 import java.io.IOException;
5 import org.apache.felix.gogo.commands.Argument;
6 import org.apache.felix.gogo.commands.Command;
7 import org.slf4j.Logger;
8 import org.slf4j.LoggerFactory;
10 @Command(scope = "alto", name = "delete", description = "Destroy a map by resourceId")
11 public class AltoDelete extends AltoManager {
12 private static final Logger log = LoggerFactory.getLogger(AltoDelete.class);
14 @Argument(index = 0, name = "resource-type", description = "Resource Type", required = true, multiValued = false)
15 String resourceType = null;
17 @Argument(index = 1, name = "resource-id", description = "Resource Id", required = true, multiValued = false)
18 String resourceId = null;
25 protected Object doExecute() throws Exception {
26 if (isDefaultNetworkMap(resourceId)) {
27 log.info("Cannot destroy default network map. Aborting");
30 if (networkMapType().equals(resourceType)) {
32 } else if (costMapType().equals(resourceType)) {
34 } else if (endpointPropertyMapType().equals(resourceType)) {
35 deleteEndpointPropertyMap();
37 log.warn("Not supported resource type " + resourceType + ". Aborting...");
42 private boolean deleteEndpointPropertyMap() throws IOException {
43 log.info("Deleting endpoint property map " + this.resourceId);
44 return httpDelete(AltoManagerConstants.RESOURCES_URL + AltoManagerConstants.ENDPOINT_PROPERTY_MAP_NODE);
47 private boolean deleteCostMap() throws IOException {
48 log.info("Deleting endpoint property map " + this.resourceId);
49 return httpDelete(AltoManagerConstants.COST_MAP_URL + resourceId);
52 private boolean deleteNetworkMap() throws IOException {
53 log.info("Deleting endpoint property map " + this.resourceId);
54 return httpDelete(AltoManagerConstants.NETWORK_MAP_URL + resourceId);