You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2012/12/06 00:01:15 UTC

[9/10] git commit: api_refactor: move network api for admin pkg from cloud-server to cloud-api

api_refactor: move network api for admin pkg from cloud-server to cloud-api

- Remove a lot of junk
- Fix commands.prop.
- Move apis from cloud-server to cloud-api
- Rename with org.apache.cloudstack namespace

Signed-off-by: Rohit Yadav <bh...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/c24118e7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/c24118e7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/c24118e7

Branch: refs/heads/api_refactoring
Commit: c24118e7e8988b6cdd9397d394487923898a544f
Parents: 678181a
Author: Rohit Yadav <bh...@apache.org>
Authored: Wed Dec 5 14:06:13 2012 -0800
Committer: Rohit Yadav <bh...@apache.org>
Committed: Wed Dec 5 14:06:13 2012 -0800

----------------------------------------------------------------------
 .../admin/network/command/AddNetworkDeviceCmd.java |   95 ++++++++++++++
 .../network/command/DeleteNetworkDeviceCmd.java    |   90 +++++++++++++
 .../network/command/ListNetworkDeviceCmd.java      |   99 +++++++++++++++
 client/tomcatconf/commands.properties.in           |   11 +--
 .../cloud/api/commands/AddNetworkDeviceCmd.java    |   95 --------------
 .../cloud/api/commands/DeleteNetworkDeviceCmd.java |   90 -------------
 .../cloud/api/commands/ListNetworkDeviceCmd.java   |   99 ---------------
 .../network/ExternalNetworkDeviceManager.java      |    6 +-
 .../network/ExternalNetworkDeviceManagerImpl.java  |    6 +-
 9 files changed, 293 insertions(+), 298 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c24118e7/api/src/org/apache/cloudstack/api/admin/network/command/AddNetworkDeviceCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/admin/network/command/AddNetworkDeviceCmd.java b/api/src/org/apache/cloudstack/api/admin/network/command/AddNetworkDeviceCmd.java
new file mode 100644
index 0000000..8c597d5
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/admin/network/command/AddNetworkDeviceCmd.java
@@ -0,0 +1,95 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you 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.apache.cloudstack.api.admin.network.command;
+
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.host.Host;
+import com.cloud.network.ExternalNetworkDeviceManager;
+import com.cloud.server.ManagementService;
+import com.cloud.server.api.response.NetworkDeviceResponse;
+import com.cloud.utils.component.ComponentLocator;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@Implementation(description="Adds a network device of one of the following types: ExternalDhcp, ExternalFirewall, ExternalLoadBalancer, PxeServer", responseObject = NetworkDeviceResponse.class)
+public class AddNetworkDeviceCmd extends BaseCmd {
+	public static final Logger s_logger = Logger.getLogger(AddNetworkDeviceCmd.class);
+	private static final String s_name = "addnetworkdeviceresponse";
+	
+	// ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+	
+	@Parameter(name = ApiConstants.NETWORK_DEVICE_TYPE, type = CommandType.STRING, description = "Network device type, now supports ExternalDhcp, PxeServer, NetscalerMPXLoadBalancer, NetscalerVPXLoadBalancer, NetscalerSDXLoadBalancer, F5BigIpLoadBalancer, JuniperSRXFirewall")
+    private String type;
+	
+	@Parameter(name = ApiConstants.NETWORK_DEVICE_PARAMETER_LIST, type = CommandType.MAP, description = "parameters for network device")
+    private Map paramList;
+	
+	
+	public String getDeviceType() {
+		return type;
+	}
+	
+	public Map getParamList() {
+		return paramList;
+	}
+	
+	@Override
+	public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
+			ResourceAllocationException {
+		try {
+			ExternalNetworkDeviceManager nwDeviceMgr;
+			ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
+			nwDeviceMgr = locator.getManager(ExternalNetworkDeviceManager.class);
+			Host device = nwDeviceMgr.addNetworkDevice(this);
+			NetworkDeviceResponse response = nwDeviceMgr.getApiResponse(device);
+			response.setObjectName("networkdevice");
+			response.setResponseName(getCommandName());
+			this.setResponseObject(response);
+		} catch (InvalidParameterValueException ipve) {
+			throw new ServerApiException(BaseCmd.PARAM_ERROR, ipve.getMessage());
+		} catch (CloudRuntimeException cre) {
+			throw new ServerApiException(BaseCmd.INTERNAL_ERROR, cre.getMessage());
+		}
+
+	}
+
+	@Override
+	public String getCommandName() {
+		return s_name;
+	}
+
+	@Override
+	public long getEntityOwnerId() {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c24118e7/api/src/org/apache/cloudstack/api/admin/network/command/DeleteNetworkDeviceCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/admin/network/command/DeleteNetworkDeviceCmd.java b/api/src/org/apache/cloudstack/api/admin/network/command/DeleteNetworkDeviceCmd.java
new file mode 100644
index 0000000..491e49a
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/admin/network/command/DeleteNetworkDeviceCmd.java
@@ -0,0 +1,90 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you 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.apache.cloudstack.api.admin.network.command;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.SuccessResponse;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.ExternalNetworkDeviceManager;
+import com.cloud.server.ManagementService;
+import com.cloud.utils.component.ComponentLocator;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@Implementation(description="Deletes network device.", responseObject=SuccessResponse.class)
+public class DeleteNetworkDeviceCmd extends BaseCmd {
+	public static final Logger s_logger = Logger.getLogger(DeleteNetworkDeviceCmd.class);
+	private static final String s_name = "deletenetworkdeviceresponse";
+	
+	/////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="host")
+	@Parameter(name = ApiConstants.ID, type = CommandType.LONG, required=true, description = "Id of network device to delete")
+    private Long id;
+    
+	
+	public Long getId() {
+		return id;
+	}
+	
+	@Override
+	public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
+			ResourceAllocationException {
+		try {
+			ExternalNetworkDeviceManager nwDeviceMgr;
+			ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
+			nwDeviceMgr = locator.getManager(ExternalNetworkDeviceManager.class);
+			boolean result = nwDeviceMgr.deleteNetworkDevice(this);
+			if (result) {
+				SuccessResponse response = new SuccessResponse(getCommandName());
+				response.setResponseName(getCommandName());
+				this.setResponseObject(response);
+			} else {
+				throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete network device:" + getId());
+			}
+		} catch (InvalidParameterValueException ipve) {
+			throw new ServerApiException(BaseCmd.PARAM_ERROR, ipve.getMessage());
+		} catch (CloudRuntimeException cre) {
+			throw new ServerApiException(BaseCmd.INTERNAL_ERROR, cre.getMessage());
+		}
+
+	}
+
+	@Override
+	public String getCommandName() {
+		return s_name;
+	}
+
+	@Override
+	public long getEntityOwnerId() {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c24118e7/api/src/org/apache/cloudstack/api/admin/network/command/ListNetworkDeviceCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/admin/network/command/ListNetworkDeviceCmd.java b/api/src/org/apache/cloudstack/api/admin/network/command/ListNetworkDeviceCmd.java
new file mode 100644
index 0000000..65c9e1c
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/admin/network/command/ListNetworkDeviceCmd.java
@@ -0,0 +1,99 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you 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.apache.cloudstack.api.admin.network.command;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.ListResponse;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.host.Host;
+import com.cloud.network.ExternalNetworkDeviceManager;
+import com.cloud.server.ManagementService;
+import com.cloud.server.api.response.NetworkDeviceResponse;
+import com.cloud.utils.component.ComponentLocator;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@Implementation(description="List network devices", responseObject = NetworkDeviceResponse.class)
+public class ListNetworkDeviceCmd extends BaseListCmd {
+	public static final Logger s_logger = Logger.getLogger(ListNetworkDeviceCmd.class);
+	private static final String s_name = "listnetworkdevice";
+	
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+	@Parameter(name = ApiConstants.NETWORK_DEVICE_TYPE, type = CommandType.STRING, description = "Network device type, now supports ExternalDhcp, PxeServer, NetscalerMPXLoadBalancer, NetscalerVPXLoadBalancer, NetscalerSDXLoadBalancer, F5BigIpLoadBalancer, JuniperSRXFirewall")
+    private String type;
+	
+	@Parameter(name = ApiConstants.NETWORK_DEVICE_PARAMETER_LIST, type = CommandType.MAP, description = "parameters for network device")
+    private Map paramList;
+    
+	public String getDeviceType() {
+		return type;
+	}
+	
+	public Map getParamList() {
+		return paramList;
+	}
+	
+	@Override
+	public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
+			ResourceAllocationException {
+		try {
+			ExternalNetworkDeviceManager nwDeviceMgr;
+			ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
+			nwDeviceMgr = locator.getManager(ExternalNetworkDeviceManager.class);
+			List<Host> devices = nwDeviceMgr.listNetworkDevice(this);
+			List<NetworkDeviceResponse> nwdeviceResponses = new ArrayList<NetworkDeviceResponse>();
+			ListResponse<NetworkDeviceResponse> listResponse = new ListResponse<NetworkDeviceResponse>();
+			for (Host d : devices) {
+				NetworkDeviceResponse response = nwDeviceMgr.getApiResponse(d);
+				response.setObjectName("networkdevice");
+				response.setResponseName(getCommandName());
+				nwdeviceResponses.add(response);
+			}
+			
+	        listResponse.setResponses(nwdeviceResponses);
+	        listResponse.setResponseName(getCommandName());
+	        this.setResponseObject(listResponse);
+		} catch (InvalidParameterValueException ipve) {
+			throw new ServerApiException(BaseCmd.PARAM_ERROR, ipve.getMessage());
+		} catch (CloudRuntimeException cre) {
+			throw new ServerApiException(BaseCmd.INTERNAL_ERROR, cre.getMessage());
+		}
+	}
+
+	@Override
+	public String getCommandName() {
+		return s_name;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c24118e7/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index 2c50991..af0e45f 100755
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -370,14 +370,9 @@ listStorageNetworkIpRange=org.apache.cloudstack.api.admin.network.command.ListSt
 updateStorageNetworkIpRange=org.apache.cloudstack.api.admin.network.command.UpdateStorageNetworkIpRangeCmd;1
 
 ### Network Devices commands
-addNetworkDevice=com.cloud.api.commands.AddNetworkDeviceCmd;1
-listNetworkDevice=com.cloud.api.commands.ListNetworkDeviceCmd;1
-deleteNetworkDevice=com.cloud.api.commands.DeleteNetworkDeviceCmd;1
-
-### Network Devices commands
-addNetworkDevice=com.cloud.api.commands.AddNetworkDeviceCmd;1
-listNetworkDevice=com.cloud.api.commands.ListNetworkDeviceCmd;1
-deleteNetworkDevice=com.cloud.api.commands.DeleteNetworkDeviceCmd;1
+addNetworkDevice=org.apache.cloudstack.api.admin.network.command.AddNetworkDeviceCmd;1
+listNetworkDevice=org.apache.cloudstack.api.admin.network.command.ListNetworkDeviceCmd;1
+deleteNetworkDevice=org.apache.cloudstack.api.admin.network.command.DeleteNetworkDeviceCmd;1
 
 ### VPC commands
 createVPC=org.apache.cloudstack.api.user.vpc.command.CreateVPCCmd;15

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c24118e7/server/src/com/cloud/api/commands/AddNetworkDeviceCmd.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/commands/AddNetworkDeviceCmd.java b/server/src/com/cloud/api/commands/AddNetworkDeviceCmd.java
deleted file mode 100644
index 20fd7f1..0000000
--- a/server/src/com/cloud/api/commands/AddNetworkDeviceCmd.java
+++ /dev/null
@@ -1,95 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you 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 com.cloud.api.commands;
-
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.host.Host;
-import com.cloud.network.ExternalNetworkDeviceManager;
-import com.cloud.server.ManagementService;
-import com.cloud.server.api.response.NetworkDeviceResponse;
-import com.cloud.utils.component.ComponentLocator;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-@Implementation(description="Adds a network device of one of the following types: ExternalDhcp, ExternalFirewall, ExternalLoadBalancer, PxeServer", responseObject = NetworkDeviceResponse.class)
-public class AddNetworkDeviceCmd extends BaseCmd {
-	public static final Logger s_logger = Logger.getLogger(AddNetworkDeviceCmd.class);
-	private static final String s_name = "addnetworkdeviceresponse";
-	
-	// ///////////////////////////////////////////////////
-    // ////////////// API parameters /////////////////////
-    // ///////////////////////////////////////////////////
-	
-	@Parameter(name = ApiConstants.NETWORK_DEVICE_TYPE, type = CommandType.STRING, description = "Network device type, now supports ExternalDhcp, PxeServer, NetscalerMPXLoadBalancer, NetscalerVPXLoadBalancer, NetscalerSDXLoadBalancer, F5BigIpLoadBalancer, JuniperSRXFirewall")
-    private String type;
-	
-	@Parameter(name = ApiConstants.NETWORK_DEVICE_PARAMETER_LIST, type = CommandType.MAP, description = "parameters for network device")
-    private Map paramList;
-	
-	
-	public String getDeviceType() {
-		return type;
-	}
-	
-	public Map getParamList() {
-		return paramList;
-	}
-	
-	@Override
-	public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
-			ResourceAllocationException {
-		try {
-			ExternalNetworkDeviceManager nwDeviceMgr;
-			ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
-			nwDeviceMgr = locator.getManager(ExternalNetworkDeviceManager.class);
-			Host device = nwDeviceMgr.addNetworkDevice(this);
-			NetworkDeviceResponse response = nwDeviceMgr.getApiResponse(device);
-			response.setObjectName("networkdevice");
-			response.setResponseName(getCommandName());
-			this.setResponseObject(response);
-		} catch (InvalidParameterValueException ipve) {
-			throw new ServerApiException(BaseCmd.PARAM_ERROR, ipve.getMessage());
-		} catch (CloudRuntimeException cre) {
-			throw new ServerApiException(BaseCmd.INTERNAL_ERROR, cre.getMessage());
-		}
-
-	}
-
-	@Override
-	public String getCommandName() {
-		return s_name;
-	}
-
-	@Override
-	public long getEntityOwnerId() {
-		// TODO Auto-generated method stub
-		return 0;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c24118e7/server/src/com/cloud/api/commands/DeleteNetworkDeviceCmd.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/commands/DeleteNetworkDeviceCmd.java b/server/src/com/cloud/api/commands/DeleteNetworkDeviceCmd.java
deleted file mode 100644
index cd0c0b7..0000000
--- a/server/src/com/cloud/api/commands/DeleteNetworkDeviceCmd.java
+++ /dev/null
@@ -1,90 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you 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 com.cloud.api.commands;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.SuccessResponse;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.ExternalNetworkDeviceManager;
-import com.cloud.server.ManagementService;
-import com.cloud.utils.component.ComponentLocator;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-@Implementation(description="Deletes network device.", responseObject=SuccessResponse.class)
-public class DeleteNetworkDeviceCmd extends BaseCmd {
-	public static final Logger s_logger = Logger.getLogger(DeleteNetworkDeviceCmd.class);
-	private static final String s_name = "deletenetworkdeviceresponse";
-	
-	/////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-
-    @IdentityMapper(entityTableName="host")
-	@Parameter(name = ApiConstants.ID, type = CommandType.LONG, required=true, description = "Id of network device to delete")
-    private Long id;
-    
-	
-	public Long getId() {
-		return id;
-	}
-	
-	@Override
-	public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
-			ResourceAllocationException {
-		try {
-			ExternalNetworkDeviceManager nwDeviceMgr;
-			ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
-			nwDeviceMgr = locator.getManager(ExternalNetworkDeviceManager.class);
-			boolean result = nwDeviceMgr.deleteNetworkDevice(this);
-			if (result) {
-				SuccessResponse response = new SuccessResponse(getCommandName());
-				response.setResponseName(getCommandName());
-				this.setResponseObject(response);
-			} else {
-				throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete network device:" + getId());
-			}
-		} catch (InvalidParameterValueException ipve) {
-			throw new ServerApiException(BaseCmd.PARAM_ERROR, ipve.getMessage());
-		} catch (CloudRuntimeException cre) {
-			throw new ServerApiException(BaseCmd.INTERNAL_ERROR, cre.getMessage());
-		}
-
-	}
-
-	@Override
-	public String getCommandName() {
-		return s_name;
-	}
-
-	@Override
-	public long getEntityOwnerId() {
-		// TODO Auto-generated method stub
-		return 0;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c24118e7/server/src/com/cloud/api/commands/ListNetworkDeviceCmd.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/commands/ListNetworkDeviceCmd.java b/server/src/com/cloud/api/commands/ListNetworkDeviceCmd.java
deleted file mode 100644
index c3f206c..0000000
--- a/server/src/com/cloud/api/commands/ListNetworkDeviceCmd.java
+++ /dev/null
@@ -1,99 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you 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 com.cloud.api.commands;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.BaseListCmd;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import com.cloud.api.response.ListResponse;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.host.Host;
-import com.cloud.network.ExternalNetworkDeviceManager;
-import com.cloud.server.ManagementService;
-import com.cloud.server.api.response.NetworkDeviceResponse;
-import com.cloud.utils.component.ComponentLocator;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-@Implementation(description="List network devices", responseObject = NetworkDeviceResponse.class)
-public class ListNetworkDeviceCmd extends BaseListCmd {
-	public static final Logger s_logger = Logger.getLogger(ListNetworkDeviceCmd.class);
-	private static final String s_name = "listnetworkdevice";
-	
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-
-	@Parameter(name = ApiConstants.NETWORK_DEVICE_TYPE, type = CommandType.STRING, description = "Network device type, now supports ExternalDhcp, PxeServer, NetscalerMPXLoadBalancer, NetscalerVPXLoadBalancer, NetscalerSDXLoadBalancer, F5BigIpLoadBalancer, JuniperSRXFirewall")
-    private String type;
-	
-	@Parameter(name = ApiConstants.NETWORK_DEVICE_PARAMETER_LIST, type = CommandType.MAP, description = "parameters for network device")
-    private Map paramList;
-    
-	public String getDeviceType() {
-		return type;
-	}
-	
-	public Map getParamList() {
-		return paramList;
-	}
-	
-	@Override
-	public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
-			ResourceAllocationException {
-		try {
-			ExternalNetworkDeviceManager nwDeviceMgr;
-			ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
-			nwDeviceMgr = locator.getManager(ExternalNetworkDeviceManager.class);
-			List<Host> devices = nwDeviceMgr.listNetworkDevice(this);
-			List<NetworkDeviceResponse> nwdeviceResponses = new ArrayList<NetworkDeviceResponse>();
-			ListResponse<NetworkDeviceResponse> listResponse = new ListResponse<NetworkDeviceResponse>();
-			for (Host d : devices) {
-				NetworkDeviceResponse response = nwDeviceMgr.getApiResponse(d);
-				response.setObjectName("networkdevice");
-				response.setResponseName(getCommandName());
-				nwdeviceResponses.add(response);
-			}
-			
-	        listResponse.setResponses(nwdeviceResponses);
-	        listResponse.setResponseName(getCommandName());
-	        this.setResponseObject(listResponse);
-		} catch (InvalidParameterValueException ipve) {
-			throw new ServerApiException(BaseCmd.PARAM_ERROR, ipve.getMessage());
-		} catch (CloudRuntimeException cre) {
-			throw new ServerApiException(BaseCmd.INTERNAL_ERROR, cre.getMessage());
-		}
-	}
-
-	@Override
-	public String getCommandName() {
-		return s_name;
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c24118e7/server/src/com/cloud/network/ExternalNetworkDeviceManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/ExternalNetworkDeviceManager.java b/server/src/com/cloud/network/ExternalNetworkDeviceManager.java
index b1de86f..fc66f87 100644
--- a/server/src/com/cloud/network/ExternalNetworkDeviceManager.java
+++ b/server/src/com/cloud/network/ExternalNetworkDeviceManager.java
@@ -18,9 +18,9 @@ package com.cloud.network;
 
 import java.util.ArrayList;
 import java.util.List;
-import com.cloud.api.commands.AddNetworkDeviceCmd;
-import com.cloud.api.commands.DeleteNetworkDeviceCmd;
-import com.cloud.api.commands.ListNetworkDeviceCmd;
+import org.apache.cloudstack.api.admin.network.command.AddNetworkDeviceCmd;
+import org.apache.cloudstack.api.admin.network.command.DeleteNetworkDeviceCmd;
+import org.apache.cloudstack.api.admin.network.command.ListNetworkDeviceCmd;
 import com.cloud.host.Host;
 import com.cloud.server.api.response.NetworkDeviceResponse;
 import com.cloud.utils.component.Manager;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c24118e7/server/src/com/cloud/network/ExternalNetworkDeviceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/ExternalNetworkDeviceManagerImpl.java b/server/src/com/cloud/network/ExternalNetworkDeviceManagerImpl.java
index 3c1f87a..f73b0f9 100755
--- a/server/src/com/cloud/network/ExternalNetworkDeviceManagerImpl.java
+++ b/server/src/com/cloud/network/ExternalNetworkDeviceManagerImpl.java
@@ -26,14 +26,14 @@ import java.util.concurrent.ScheduledExecutorService;
 import javax.ejb.Local;
 import javax.naming.ConfigurationException;
 
+import org.apache.cloudstack.api.admin.network.command.AddNetworkDeviceCmd;
+import org.apache.cloudstack.api.admin.network.command.ListNetworkDeviceCmd;
 import org.apache.log4j.Logger;
 
 import com.cloud.agent.AgentManager;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.IdentityService;
-import com.cloud.api.commands.AddNetworkDeviceCmd;
-import com.cloud.api.commands.DeleteNetworkDeviceCmd;
-import com.cloud.api.commands.ListNetworkDeviceCmd;
+import org.apache.cloudstack.api.admin.network.command.DeleteNetworkDeviceCmd;
 import com.cloud.baremetal.ExternalDhcpManager;
 import com.cloud.baremetal.PxeServerManager;
 import com.cloud.baremetal.PxeServerProfile;