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 20:14:32 UTC

[13/14] git commit: api_refactor: Move host apis to admin pkg

api_refactor: Move host apis to admin pkg

- Moved host related apis to admin pkg
- Change namespace to org.a.cs.api, fix mappings in commands-prop.

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/2a7fa674
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/2a7fa674
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/2a7fa674

Branch: refs/heads/api_refactoring
Commit: 2a7fa674c73dd88c34136bd94fc68a3c53f1e2a1
Parents: b0ce8fd
Author: Rohit Yadav <bh...@apache.org>
Authored: Thu Dec 6 10:21:10 2012 -0800
Committer: Rohit Yadav <bh...@apache.org>
Committed: Thu Dec 6 10:21:10 2012 -0800

----------------------------------------------------------------------
 api/src/com/cloud/api/commands/AddHostCmd.java     |  161 ------------
 .../cloud/api/commands/AddSecondaryStorageCmd.java |   97 --------
 .../cloud/api/commands/CancelMaintenanceCmd.java   |  113 ---------
 api/src/com/cloud/api/commands/DeleteHostCmd.java  |   90 -------
 api/src/com/cloud/api/commands/ListHostsCmd.java   |  192 ---------------
 .../api/commands/PrepareForMaintenanceCmd.java     |  111 ---------
 .../com/cloud/api/commands/ReconnectHostCmd.java   |  114 ---------
 api/src/com/cloud/api/commands/UpdateHostCmd.java  |  114 ---------
 .../cloud/api/commands/UpdateHostPasswordCmd.java  |   95 -------
 api/src/com/cloud/resource/ResourceService.java    |   14 +-
 api/src/com/cloud/server/ManagementService.java    |    5 +-
 .../api/admin/host/command/AddHostCmd.java         |  161 ++++++++++++
 .../admin/host/command/AddSecondaryStorageCmd.java |   97 ++++++++
 .../admin/host/command/CancelMaintenanceCmd.java   |  113 +++++++++
 .../api/admin/host/command/DeleteHostCmd.java      |   90 +++++++
 .../api/admin/host/command/ListHostsCmd.java       |  192 +++++++++++++++
 .../host/command/PrepareForMaintenanceCmd.java     |  111 +++++++++
 .../api/admin/host/command/ReconnectHostCmd.java   |  114 +++++++++
 .../api/admin/host/command/UpdateHostCmd.java      |  114 +++++++++
 .../admin/host/command/UpdateHostPasswordCmd.java  |   95 +++++++
 .../cloud/api/commands/test/AddHostCmdTest.java    |    2 +-
 .../commands/test/AddSecondaryStorageCmdTest.java  |    2 +-
 client/tomcatconf/commands.properties.in           |   18 +-
 .../com/cloud/resource/ResourceManagerImpl.java    |   13 +-
 .../src/com/cloud/server/ManagementServerImpl.java |    7 +-
 25 files changed, 1115 insertions(+), 1120 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2a7fa674/api/src/com/cloud/api/commands/AddHostCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/AddHostCmd.java b/api/src/com/cloud/api/commands/AddHostCmd.java
deleted file mode 100755
index d2e06de..0000000
--- a/api/src/com/cloud/api/commands/AddHostCmd.java
+++ /dev/null
@@ -1,161 +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 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.HostResponse;
-import com.cloud.api.response.ListResponse;
-import com.cloud.exception.DiscoveryException;
-import com.cloud.host.Host;
-import com.cloud.user.Account;
-
-@Implementation(description="Adds a new host.", responseObject=HostResponse.class)
-public class AddHostCmd extends BaseCmd {
-    public static final Logger s_logger = Logger.getLogger(AddHostCmd.class.getName());
-
-    private static final String s_name = "addhostresponse";
-
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-
-    @IdentityMapper(entityTableName="cluster")
-    @Parameter(name=ApiConstants.CLUSTER_ID, type=CommandType.LONG, description="the cluster ID for the host")
-    private Long clusterId;
-
-    @Parameter(name=ApiConstants.CLUSTER_NAME, type=CommandType.STRING, description="the cluster name for the host")
-    private String clusterName;
-
-    @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required=true, description="the password for the host")
-    private String password;
-
-    @IdentityMapper(entityTableName="host_pod_ref")
-    @Parameter(name=ApiConstants.POD_ID, required=true, type=CommandType.LONG, description="the Pod ID for the host")
-    private Long podId;
-
-    @Parameter(name=ApiConstants.URL, type=CommandType.STRING, required=true, description="the host URL")
-    private String url;
-
-    @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required=true, description="the username for the host")
-    private String username;
-
-    @IdentityMapper(entityTableName="data_center")
-    @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="the Zone ID for the host")
-    private Long zoneId;
-
-    @Parameter(name=ApiConstants.HYPERVISOR, type=CommandType.STRING, required=true, description="hypervisor type of the host")
-    private String hypervisor;
-
-    @Parameter(name=ApiConstants.ALLOCATION_STATE, type=CommandType.STRING, description="Allocation state of this Host for allocation of new resources")
-    private String allocationState;
-
-    @Parameter(name=ApiConstants.HOST_TAGS, type=CommandType.LIST, collectionType=CommandType.STRING, description="list of tags to be added to the host")
-    private List<String> hostTags;
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-
-    public Long getClusterId() {
-        return clusterId;
-    }
-
-    public String getClusterName() {
-        return clusterName;
-    }
-
-    public String getPassword() {
-        return password;
-    }
-
-    public Long getPodId() {
-        return podId;
-    }
-
-    public String getUrl() {
-        return url;
-    }
-
-    public String getUsername() {
-        return username;
-    }
-
-    public Long getZoneId() {
-        return zoneId;
-    }
-
-    public String getHypervisor() {
-        return hypervisor;
-    }
-
-    public List<String> getHostTags() {
-        return hostTags;
-    }
-
-    public String getAllocationState() {
-        return allocationState;
-    }
-
-    /////////////////////////////////////////////////////
-    /////////////// API Implementation///////////////////
-    /////////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        return Account.ACCOUNT_ID_SYSTEM;
-    }
-
-    @Override
-    public void execute(){
-        try {
-            List<? extends Host> result = _resourceService.discoverHosts(this);
-            ListResponse<HostResponse> response = new ListResponse<HostResponse>();
-            List<HostResponse> hostResponses = new ArrayList<HostResponse>();
-            if (result != null && result.size() > 0) {
-                for (Host host : result) {
-                    HostResponse hostResponse = _responseGenerator.createHostResponse(host);
-                    hostResponses.add(hostResponse);
-                }
-            } else {
-                throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add host");
-            }
-
-            response.setResponses(hostResponses);
-            response.setResponseName(getCommandName());
-
-            this.setResponseObject(response);
-        } catch (DiscoveryException ex) {
-            s_logger.warn("Exception: ", ex);
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2a7fa674/api/src/com/cloud/api/commands/AddSecondaryStorageCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/AddSecondaryStorageCmd.java b/api/src/com/cloud/api/commands/AddSecondaryStorageCmd.java
deleted file mode 100644
index c1946d0..0000000
--- a/api/src/com/cloud/api/commands/AddSecondaryStorageCmd.java
+++ /dev/null
@@ -1,97 +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.List;
-
-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.HostResponse;
-import com.cloud.exception.DiscoveryException;
-import com.cloud.host.Host;
-import com.cloud.user.Account;
-
-@Implementation(description="Adds secondary storage.", responseObject=HostResponse.class)
-public class AddSecondaryStorageCmd extends BaseCmd {
-    public static final Logger s_logger = Logger.getLogger(AddSecondaryStorageCmd.class.getName());
-    private static final String s_name = "addsecondarystorageresponse";
-
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-
-    @Parameter(name=ApiConstants.URL, type=CommandType.STRING, required=true, description="the URL for the secondary storage")
-    private String url;
-
-    @IdentityMapper(entityTableName="data_center")
-    @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="the Zone ID for the secondary storage")
-    private Long zoneId;
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-
-    public String getUrl() {
-        return url;
-    }
-
-    public Long getZoneId() {
-        return zoneId;
-    }
-
-    /////////////////////////////////////////////////////
-    /////////////// API Implementation///////////////////
-    /////////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        return Account.ACCOUNT_ID_SYSTEM;
-    }
-
-    @Override
-    public void execute(){
-        try {
-            List<? extends Host> result = _resourceService.discoverHosts(this);
-            HostResponse hostResponse = null;
-            if (result != null && result.size() > 0) {
-                for (Host host : result) {
-                    // There should only be one secondary storage host per add
-                    hostResponse = _responseGenerator.createHostResponse(host);
-                    hostResponse.setResponseName(getCommandName());
-                    hostResponse.setObjectName("secondarystorage");
-                    this.setResponseObject(hostResponse);
-                }
-            } else {
-                throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add secondary storage");
-            }
-        } catch (DiscoveryException ex) {
-            s_logger.warn("Exception: ", ex);
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2a7fa674/api/src/com/cloud/api/commands/CancelMaintenanceCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/CancelMaintenanceCmd.java b/api/src/com/cloud/api/commands/CancelMaintenanceCmd.java
deleted file mode 100644
index dfd7c88..0000000
--- a/api/src/com/cloud/api/commands/CancelMaintenanceCmd.java
+++ /dev/null
@@ -1,113 +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.BaseAsyncCmd;
-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.HostResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.host.Host;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Cancels host maintenance.", responseObject=HostResponse.class)
-public class CancelMaintenanceCmd extends BaseAsyncCmd  {
-    public static final Logger s_logger = Logger.getLogger(CancelMaintenanceCmd.class.getName());
-
-    private static final String s_name = "cancelhostmaintenanceresponse";
-
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-
-    @IdentityMapper(entityTableName="host")
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the host ID")
-    private Long id;
-
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-
-    public Long getId() {
-        return id;
-    }
-
-
-    /////////////////////////////////////////////////////
-    /////////////// API Implementation///////////////////
-    /////////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    public static String getResultObjectName() {
-        return "host";
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        Account account = UserContext.current().getCaller();
-        if (account != null) {
-            return account.getId();
-        }
-
-        return Account.ACCOUNT_ID_SYSTEM;
-    }
-
-    @Override
-    public String getEventType() {
-        return EventTypes.EVENT_MAINTENANCE_CANCEL;
-    }
-
-    @Override
-    public String getEventDescription() {
-        return  "canceling maintenance for host: " + getId();
-    }
-
-    @Override
-    public AsyncJob.Type getInstanceType() {
-        return AsyncJob.Type.Host;
-    }
-
-    @Override
-    public Long getInstanceId() {
-        return getId();
-    }
-
-    @Override
-    public void execute(){
-        Host result = _resourceService.cancelMaintenance(this);
-        if (result != null) {
-            HostResponse response = _responseGenerator.createHostResponse(result);
-            response.setResponseName(getCommandName());
-            this.setResponseObject(response);
-        } else {
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to cancel host maintenance");
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2a7fa674/api/src/com/cloud/api/commands/DeleteHostCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/DeleteHostCmd.java b/api/src/com/cloud/api/commands/DeleteHostCmd.java
deleted file mode 100644
index da68a83..0000000
--- a/api/src/com/cloud/api/commands/DeleteHostCmd.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.user.Account;
-
-@Implementation(description = "Deletes a host.", responseObject = SuccessResponse.class)
-public class DeleteHostCmd extends BaseCmd {
-    public static final Logger s_logger = Logger.getLogger(DeleteHostCmd.class.getName());
-
-    private static final String s_name = "deletehostresponse";
-
-    // ///////////////////////////////////////////////////
-    // ////////////// API parameters /////////////////////
-    // ///////////////////////////////////////////////////
-
-    @IdentityMapper(entityTableName="host")
-    @Parameter(name = ApiConstants.ID, type = CommandType.LONG, required = true, description = "the host ID")
-    private Long id;
-
-    @Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, description = "Force delete the host. All HA enabled vms running on the host will be put to HA; HA disabled ones will be stopped")
-    private Boolean forced;
-
-    @Parameter(name = ApiConstants.FORCED_DESTROY_LOCAL_STORAGE, type = CommandType.BOOLEAN, description = "Force destroy local storage on this host. All VMs created on this local storage will be destroyed")
-    private Boolean forceDestroyLocalStorage;
-
-    // ///////////////////////////////////////////////////
-    // ///////////////// Accessors ///////////////////////
-    // ///////////////////////////////////////////////////
-
-    public Long getId() {
-        return id;
-    }
-
-    public boolean isForced() {
-        return (forced != null) ? forced : false;
-    }
-
-    public boolean isForceDestoryLocalStorage() {
-        return (forceDestroyLocalStorage != null) ? forceDestroyLocalStorage : true;
-    }
-
-    // ///////////////////////////////////////////////////
-    // ///////////// API Implementation///////////////////
-    // ///////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        return Account.ACCOUNT_ID_SYSTEM;
-    }
-
-    @Override
-    public void execute() {
-        boolean result = _resourceService.deleteHost(getId(), isForced(), isForceDestoryLocalStorage());
-        if (result) {
-            SuccessResponse response = new SuccessResponse(getCommandName());
-            this.setResponseObject(response);
-        } else {
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete host");
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2a7fa674/api/src/com/cloud/api/commands/ListHostsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListHostsCmd.java b/api/src/com/cloud/api/commands/ListHostsCmd.java
deleted file mode 100755
index 7e1e97c..0000000
--- a/api/src/com/cloud/api/commands/ListHostsCmd.java
+++ /dev/null
@@ -1,192 +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.EnumSet;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.ApiConstants.HostDetails;
-import org.apache.cloudstack.api.BaseListCmd;
-import org.apache.cloudstack.api.IdentityMapper;
-import org.apache.cloudstack.api.Implementation;
-import org.apache.cloudstack.api.Parameter;
-import com.cloud.api.response.HostResponse;
-import com.cloud.api.response.ListResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.host.Host;
-import com.cloud.utils.Pair;
-
-@Implementation(description="Lists hosts.", responseObject=HostResponse.class)
-public class ListHostsCmd extends BaseListCmd {
-    public static final Logger s_logger = Logger.getLogger(ListHostsCmd.class.getName());
-
-    private static final String s_name = "listhostsresponse";
-
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-
-    @IdentityMapper(entityTableName="cluster")
-    @Parameter(name=ApiConstants.CLUSTER_ID, type=CommandType.LONG, description="lists hosts existing in particular cluster")
-    private Long clusterId;
-
-    @IdentityMapper(entityTableName="host")
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the id of the host")
-    private Long id;
-
-    @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the host")
-    private String hostName;
-
-    @IdentityMapper(entityTableName="host_pod_ref")
-    @Parameter(name=ApiConstants.POD_ID, type=CommandType.LONG, description="the Pod ID for the host")
-    private Long podId;
-
-    @Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="the state of the host")
-    private String state;
-
-    @Parameter(name=ApiConstants.TYPE, type=CommandType.STRING, description="the host type")
-    private String type;
-
-    @IdentityMapper(entityTableName="data_center")
-    @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="the Zone ID for the host")
-    private Long zoneId;
-
-    @IdentityMapper(entityTableName="vm_instance")
-    @Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.LONG, required=false, description="lists hosts in the same cluster as this VM and flag hosts with enough CPU/RAm to host this VM")
-    private Long virtualMachineId;
-
-    @Parameter(name=ApiConstants.RESOURCE_STATE, type=CommandType.STRING, description="list hosts by resource state. Resource state represents current state determined by admin of host, valule can be one of [Enabled, Disabled, Unmanaged, PrepareForMaintenance, ErrorInMaintenance, Maintenance, Error]")
-    private String resourceState;
-
-    @Parameter(name=ApiConstants.DETAILS, type=CommandType.LIST, collectionType=CommandType.STRING, description="comma separated list of host details requested, value can be a list of [ min, all, capacity, events, stats]" )
-    private List<String> viewDetails;
-
-    @Parameter(name=ApiConstants.HA_HOST, type=CommandType.BOOLEAN, description="if true, list only hosts dedicated to HA")
-    private Boolean haHost;
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-
-    public Long getClusterId() {
-        return clusterId;
-    }
-
-    public Long getId() {
-        return id;
-    }
-
-    public String getHostName() {
-        return hostName;
-    }
-
-    public Long getPodId() {
-        return podId;
-    }
-
-    public String getState() {
-        return state;
-    }
-
-    public String getType() {
-        return type;
-    }
-
-    public Boolean getHaHost() {
-        return haHost;
-    }
-
-    public Long getZoneId() {
-        return zoneId;
-    }
-
-    public Long getVirtualMachineId() {
-        return virtualMachineId;
-    }
-
-    public EnumSet<HostDetails> getDetails() throws InvalidParameterValueException {
-        EnumSet<HostDetails> dv;
-        if (viewDetails==null || viewDetails.size() <=0){
-            dv = EnumSet.of(HostDetails.all);
-        }
-        else {
-            try {
-                ArrayList<HostDetails> dc = new ArrayList<HostDetails>();
-                for (String detail: viewDetails){
-                    dc.add(HostDetails.valueOf(detail));
-                }
-                dv = EnumSet.copyOf(dc);
-            }
-            catch (IllegalArgumentException e){
-                throw new InvalidParameterValueException("The details parameter contains a non permitted value. The allowed values are " + EnumSet.allOf(HostDetails.class));
-            }
-        }
-        return dv;
-    }
-
-    public String getResourceState() {
-        return resourceState;
-    }
-    /////////////////////////////////////////////////////
-    /////////////// API Implementation///////////////////
-    /////////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    public AsyncJob.Type getInstanceType() {
-        return AsyncJob.Type.Host;
-    }
-
-    @Override
-    public void execute(){
-        List<? extends Host> result = new ArrayList<Host>();
-        List<? extends Host> hostsWithCapacity = new ArrayList<Host>();
-
-        if(getVirtualMachineId() != null){
-            Pair<List<? extends Host>, List<? extends Host>> hostsForMigration = _mgr.listHostsForMigrationOfVM(getVirtualMachineId(), this.getStartIndex(), this.getPageSizeVal());
-            result = hostsForMigration.first();
-            hostsWithCapacity = hostsForMigration.second();
-        }else{
-            result = _mgr.searchForServers(this);
-        }
-
-        ListResponse<HostResponse> response = new ListResponse<HostResponse>();
-        List<HostResponse> hostResponses = new ArrayList<HostResponse>();
-        for (Host host : result) {
-            HostResponse hostResponse = _responseGenerator.createHostResponse(host, getDetails());
-            Boolean suitableForMigration = false;
-            if(hostsWithCapacity.contains(host)){
-                suitableForMigration = true;
-            }
-            hostResponse.setSuitableForMigration(suitableForMigration);
-            hostResponse.setObjectName("host");
-            hostResponses.add(hostResponse);
-        }
-
-        response.setResponses(hostResponses);
-        response.setResponseName(getCommandName());
-        this.setResponseObject(response);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2a7fa674/api/src/com/cloud/api/commands/PrepareForMaintenanceCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/PrepareForMaintenanceCmd.java b/api/src/com/cloud/api/commands/PrepareForMaintenanceCmd.java
deleted file mode 100644
index ffa56ab..0000000
--- a/api/src/com/cloud/api/commands/PrepareForMaintenanceCmd.java
+++ /dev/null
@@ -1,111 +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.BaseAsyncCmd;
-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.HostResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.host.Host;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Prepares a host for maintenance.", responseObject=HostResponse.class)
-public class PrepareForMaintenanceCmd extends BaseAsyncCmd {
-    public static final Logger s_logger = Logger.getLogger(PrepareForMaintenanceCmd.class.getName());
-
-    private static final String s_name = "preparehostformaintenanceresponse";
-
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-
-    @IdentityMapper(entityTableName="host")
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the host ID")
-    private Long id;
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-
-    public Long getId() {
-        return id;
-    }
-
-    /////////////////////////////////////////////////////
-    /////////////// API Implementation///////////////////
-    /////////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    public static String getResultObjectName() {
-        return "host";
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        Account account = UserContext.current().getCaller();
-        if (account != null) {
-            return account.getId();
-        }
-
-        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
-    }
-
-    @Override
-    public String getEventType() {
-        return EventTypes.EVENT_MAINTENANCE_PREPARE;
-    }
-
-    @Override
-    public String getEventDescription() {
-        return  "preparing host: " + getId() + " for maintenance";
-    }
-
-    @Override
-    public AsyncJob.Type getInstanceType() {
-        return AsyncJob.Type.Host;
-    }
-
-    @Override
-    public Long getInstanceId() {
-        return getId();
-    }
-
-    @Override
-    public void execute(){
-        Host result = _resourceService.maintain(this);
-        if (result != null){
-            HostResponse response = _responseGenerator.createHostResponse(result);
-            response.setResponseName("host");
-            this.setResponseObject(response);
-        } else {
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to prepare host for maintenance");
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2a7fa674/api/src/com/cloud/api/commands/ReconnectHostCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ReconnectHostCmd.java b/api/src/com/cloud/api/commands/ReconnectHostCmd.java
deleted file mode 100755
index a2079f2..0000000
--- a/api/src/com/cloud/api/commands/ReconnectHostCmd.java
+++ /dev/null
@@ -1,114 +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.BaseAsyncCmd;
-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.HostResponse;
-import com.cloud.async.AsyncJob;
-import com.cloud.event.EventTypes;
-import com.cloud.host.Host;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@Implementation(description="Reconnects a host.", responseObject=HostResponse.class)
-public class ReconnectHostCmd extends BaseAsyncCmd {
-    public static final Logger s_logger = Logger.getLogger(ReconnectHostCmd.class.getName());
-
-    private static final String s_name = "reconnecthostresponse";
-
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-
-    @IdentityMapper(entityTableName="host")
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the host ID")
-    private Long id;
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-
-    public Long getId() {
-        return id;
-    }
-
-    /////////////////////////////////////////////////////
-    /////////////// API Implementation///////////////////
-    /////////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    public static String getResultObjectName() {
-        return "host";
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        Account account = UserContext.current().getCaller();
-        if (account != null) {
-            return account.getId();
-        }
-
-        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
-    }
-
-    @Override
-    public String getEventType() {
-        return EventTypes.EVENT_HOST_RECONNECT;
-    }
-
-    @Override
-    public String getEventDescription() {
-        return  "reconnecting host: " + getId();
-    }
-
-    public AsyncJob.Type getInstanceType() {
-        return AsyncJob.Type.Host;
-    }
-
-    public Long getInstanceId() {
-        return getId();
-    }
-
-    @Override
-    public void execute(){
-        try {
-            Host result = _resourceService.reconnectHost(this);
-            if (result != null){
-                HostResponse response = _responseGenerator.createHostResponse(result);
-                response.setResponseName(getCommandName());
-                this.setResponseObject(response);
-            } else {
-                throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to reconnect host");
-            }
-        } catch (Exception ex) {
-            s_logger.warn("Exception: ", ex);
-            throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2a7fa674/api/src/com/cloud/api/commands/UpdateHostCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/UpdateHostCmd.java b/api/src/com/cloud/api/commands/UpdateHostCmd.java
deleted file mode 100755
index e09e4f0..0000000
--- a/api/src/com/cloud/api/commands/UpdateHostCmd.java
+++ /dev/null
@@ -1,114 +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.List;
-
-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.HostResponse;
-import com.cloud.host.Host;
-import com.cloud.user.Account;
-
-@Implementation(description="Updates a host.", responseObject=HostResponse.class)
-public class UpdateHostCmd extends BaseCmd {
-    public static final Logger s_logger = Logger.getLogger(UpdateHostCmd.class.getName());
-    private static final String s_name = "updatehostresponse";
-
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-
-    @IdentityMapper(entityTableName="host")
-    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the host to update")
-    private Long id;
-
-    @IdentityMapper(entityTableName="guest_os_category")
-    @Parameter(name=ApiConstants.OS_CATEGORY_ID, type=CommandType.LONG, description="the id of Os category to update the host with")
-    private Long osCategoryId;
-
-    @Parameter(name=ApiConstants.ALLOCATION_STATE, type=CommandType.STRING, description="Change resource state of host, valid values are [Enable, Disable]. Operation may failed if host in states not allowing Enable/Disable")
-    private String allocationState;
-
-    @Parameter(name=ApiConstants.HOST_TAGS, type=CommandType.LIST, collectionType=CommandType.STRING, description="list of tags to be added to the host")
-    private List<String> hostTags;
-
-    @Parameter(name=ApiConstants.URL, type=CommandType.STRING, description="the new uri for the secondary storage: nfs://host/path")
-    private String url;
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-
-    public Long getId() {
-        return id;
-    }
-
-    public Long getOsCategoryId() {
-        return osCategoryId;
-    }
-
-    public String getAllocationState() {
-        return allocationState;
-    }
-
-    public List<String> getHostTags() {
-        return hostTags;
-    }
-
-    public String getUrl() {
-        return url;
-    }
-
-    /////////////////////////////////////////////////////
-    /////////////// API Implementation///////////////////
-    /////////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    public static String getResultObjectName() {
-        return "updatehost";
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        return Account.ACCOUNT_ID_SYSTEM;
-    }
-
-    @Override
-    public void execute(){
-        Host result;
-        try {
-            result = _resourceService.updateHost(this);
-            HostResponse hostResponse = _responseGenerator.createHostResponse(result);
-            hostResponse.setResponseName(getCommandName());
-            this.setResponseObject(hostResponse);
-        } catch (Exception e) {
-            s_logger.debug("Failed to update host:" + getId(), e);
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update host:" + getId() + "," + e.getMessage());
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2a7fa674/api/src/com/cloud/api/commands/UpdateHostPasswordCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/UpdateHostPasswordCmd.java b/api/src/com/cloud/api/commands/UpdateHostPasswordCmd.java
deleted file mode 100644
index 9f8c02e..0000000
--- a/api/src/com/cloud/api/commands/UpdateHostPasswordCmd.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 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 com.cloud.api.response.SuccessResponse;
-import com.cloud.user.Account;
-
-@Implementation(description = "Update password of a host/pool on management server.", responseObject = SuccessResponse.class)
-public class UpdateHostPasswordCmd extends BaseCmd {
-    public static final Logger s_logger = Logger.getLogger(UpdateHostPasswordCmd.class.getName());
-
-    private static final String s_name = "updatehostpasswordresponse";
-
-    // ///////////////////////////////////////////////////
-    // ////////////// API parameters /////////////////////
-    // ///////////////////////////////////////////////////
-
-    // TO DO - this is of no use currently. Probably need to remove it.
-    @IdentityMapper(entityTableName="host")
-    @Parameter(name=ApiConstants.HOST_ID, type=CommandType.LONG, description="the host ID")
-    private Long hostId;
-
-    @IdentityMapper(entityTableName="cluster")
-    @Parameter(name=ApiConstants.CLUSTER_ID, type=CommandType.LONG, description="the cluster ID")
-    private Long clusterId;
-
-    @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required=true, description="the username for the host/cluster")
-    private String username;
-
-    @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required=true, description="the new password for the host/cluster")
-    private String password;
-
-    // ///////////////////////////////////////////////////
-    // ///////////////// Accessors ///////////////////////
-    // ///////////////////////////////////////////////////
-
-    public Long getHostId() {
-        return hostId;
-    }
-
-    public Long getClusterId() {
-        return clusterId;
-    }
-
-    public String getPassword() {
-        return password;
-    }
-
-    public String getUsername() {
-        return username;
-    }
-
-    // ///////////////////////////////////////////////////
-    // ///////////// API Implementation///////////////////
-    // ///////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    @Override
-    public long getEntityOwnerId() {
-        return Account.ACCOUNT_ID_SYSTEM;
-    }
-
-    @Override
-    public void execute() {
-        _mgr.updateHostPassword(this);
-        _resourceService.updateHostPassword(this);
-        this.setResponseObject(new SuccessResponse(getCommandName()));
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2a7fa674/api/src/com/cloud/resource/ResourceService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/resource/ResourceService.java b/api/src/com/cloud/resource/ResourceService.java
index d36ca35..d75ed13 100755
--- a/api/src/com/cloud/resource/ResourceService.java
+++ b/api/src/com/cloud/resource/ResourceService.java
@@ -19,16 +19,15 @@ package com.cloud.resource;
 import java.util.List;
 
 import com.cloud.api.commands.AddClusterCmd;
-import com.cloud.api.commands.AddHostCmd;
-import com.cloud.api.commands.AddSecondaryStorageCmd;
+import org.apache.cloudstack.api.admin.host.command.AddHostCmd;
+import org.apache.cloudstack.api.admin.host.command.AddSecondaryStorageCmd;
 import com.cloud.api.commands.AddSwiftCmd;
-import com.cloud.api.commands.CancelMaintenanceCmd;
+import org.apache.cloudstack.api.admin.host.command.CancelMaintenanceCmd;
 import com.cloud.api.commands.DeleteClusterCmd;
 import com.cloud.api.commands.ListSwiftsCmd;
-import com.cloud.api.commands.PrepareForMaintenanceCmd;
-import com.cloud.api.commands.ReconnectHostCmd;
-import com.cloud.api.commands.UpdateHostCmd;
-import com.cloud.api.commands.UpdateHostPasswordCmd;
+import org.apache.cloudstack.api.admin.host.command.PrepareForMaintenanceCmd;
+import org.apache.cloudstack.api.admin.host.command.*;
+import org.apache.cloudstack.api.admin.host.command.UpdateHostCmd;
 import com.cloud.exception.DiscoveryException;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.ResourceInUseException;
@@ -37,6 +36,7 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.org.Cluster;
 import com.cloud.storage.Swift;
 import com.cloud.utils.fsm.NoTransitionException;
+import org.apache.cloudstack.api.admin.host.command.ReconnectHostCmd;
 
 public interface ResourceService {
     /**

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2a7fa674/api/src/com/cloud/server/ManagementService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/server/ManagementService.java b/api/src/com/cloud/server/ManagementService.java
index 1b43662..a2ab206 100755
--- a/api/src/com/cloud/server/ManagementService.java
+++ b/api/src/com/cloud/server/ManagementService.java
@@ -24,6 +24,8 @@ import java.util.Set;
 
 import com.cloud.alert.Alert;
 import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.admin.host.command.ListHostsCmd;
+import org.apache.cloudstack.api.admin.host.command.UpdateHostPasswordCmd;
 import org.apache.cloudstack.api.admin.router.command.ListRoutersCmd;
 import org.apache.cloudstack.api.user.address.command.ListPublicIpAddressesCmd;
 import org.apache.cloudstack.api.user.resource.command.ListCapabilitiesCmd;
@@ -44,7 +46,6 @@ import com.cloud.api.commands.ListCfgsByCmd;
 import com.cloud.api.commands.ListClustersCmd;
 import org.apache.cloudstack.api.user.event.command.ListEventsCmd;
 import org.apache.cloudstack.api.user.guest.command.ListGuestOsCategoriesCmd;
-import com.cloud.api.commands.ListHostsCmd;
 import org.apache.cloudstack.api.user.iso.command.ListIsosCmd;
 import com.cloud.api.commands.ListPodsByCmd;
 import org.apache.cloudstack.api.user.ssh.command.ListSSHKeyPairsCmd;
@@ -57,7 +58,6 @@ import com.cloud.api.commands.RebootSystemVmCmd;
 import org.apache.cloudstack.api.user.ssh.command.RegisterSSHKeyPairCmd;
 import com.cloud.api.commands.StopSystemVmCmd;
 import com.cloud.api.commands.UpdateDomainCmd;
-import com.cloud.api.commands.UpdateHostPasswordCmd;
 import org.apache.cloudstack.api.user.iso.command.UpdateIsoCmd;
 import org.apache.cloudstack.api.user.vmgroup.command.UpdateVMGroupCmd;
 import com.cloud.api.commands.UpgradeSystemVMCmd;
@@ -79,7 +79,6 @@ import com.cloud.host.Host;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.hypervisor.HypervisorCapabilities;
 import com.cloud.network.IpAddress;
-import com.cloud.network.router.VirtualRouter;
 import com.cloud.offering.DiskOffering;
 import com.cloud.offering.ServiceOffering;
 import com.cloud.org.Cluster;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2a7fa674/api/src/org/apache/cloudstack/api/admin/host/command/AddHostCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/admin/host/command/AddHostCmd.java b/api/src/org/apache/cloudstack/api/admin/host/command/AddHostCmd.java
new file mode 100755
index 0000000..06a0652
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/admin/host/command/AddHostCmd.java
@@ -0,0 +1,161 @@
+// 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.host.command;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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.HostResponse;
+import com.cloud.api.response.ListResponse;
+import com.cloud.exception.DiscoveryException;
+import com.cloud.host.Host;
+import com.cloud.user.Account;
+
+@Implementation(description="Adds a new host.", responseObject=HostResponse.class)
+public class AddHostCmd extends BaseCmd {
+    public static final Logger s_logger = Logger.getLogger(AddHostCmd.class.getName());
+
+    private static final String s_name = "addhostresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="cluster")
+    @Parameter(name=ApiConstants.CLUSTER_ID, type=CommandType.LONG, description="the cluster ID for the host")
+    private Long clusterId;
+
+    @Parameter(name=ApiConstants.CLUSTER_NAME, type=CommandType.STRING, description="the cluster name for the host")
+    private String clusterName;
+
+    @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required=true, description="the password for the host")
+    private String password;
+
+    @IdentityMapper(entityTableName="host_pod_ref")
+    @Parameter(name=ApiConstants.POD_ID, required=true, type=CommandType.LONG, description="the Pod ID for the host")
+    private Long podId;
+
+    @Parameter(name=ApiConstants.URL, type=CommandType.STRING, required=true, description="the host URL")
+    private String url;
+
+    @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required=true, description="the username for the host")
+    private String username;
+
+    @IdentityMapper(entityTableName="data_center")
+    @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="the Zone ID for the host")
+    private Long zoneId;
+
+    @Parameter(name=ApiConstants.HYPERVISOR, type=CommandType.STRING, required=true, description="hypervisor type of the host")
+    private String hypervisor;
+
+    @Parameter(name=ApiConstants.ALLOCATION_STATE, type=CommandType.STRING, description="Allocation state of this Host for allocation of new resources")
+    private String allocationState;
+
+    @Parameter(name=ApiConstants.HOST_TAGS, type=CommandType.LIST, collectionType=CommandType.STRING, description="list of tags to be added to the host")
+    private List<String> hostTags;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getClusterId() {
+        return clusterId;
+    }
+
+    public String getClusterName() {
+        return clusterName;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public Long getPodId() {
+        return podId;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public Long getZoneId() {
+        return zoneId;
+    }
+
+    public String getHypervisor() {
+        return hypervisor;
+    }
+
+    public List<String> getHostTags() {
+        return hostTags;
+    }
+
+    public String getAllocationState() {
+        return allocationState;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public void execute(){
+        try {
+            List<? extends Host> result = _resourceService.discoverHosts(this);
+            ListResponse<HostResponse> response = new ListResponse<HostResponse>();
+            List<HostResponse> hostResponses = new ArrayList<HostResponse>();
+            if (result != null && result.size() > 0) {
+                for (Host host : result) {
+                    HostResponse hostResponse = _responseGenerator.createHostResponse(host);
+                    hostResponses.add(hostResponse);
+                }
+            } else {
+                throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add host");
+            }
+
+            response.setResponses(hostResponses);
+            response.setResponseName(getCommandName());
+
+            this.setResponseObject(response);
+        } catch (DiscoveryException ex) {
+            s_logger.warn("Exception: ", ex);
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2a7fa674/api/src/org/apache/cloudstack/api/admin/host/command/AddSecondaryStorageCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/admin/host/command/AddSecondaryStorageCmd.java b/api/src/org/apache/cloudstack/api/admin/host/command/AddSecondaryStorageCmd.java
new file mode 100644
index 0000000..678a73f
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/admin/host/command/AddSecondaryStorageCmd.java
@@ -0,0 +1,97 @@
+// 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.host.command;
+
+import java.util.List;
+
+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.HostResponse;
+import com.cloud.exception.DiscoveryException;
+import com.cloud.host.Host;
+import com.cloud.user.Account;
+
+@Implementation(description="Adds secondary storage.", responseObject=HostResponse.class)
+public class AddSecondaryStorageCmd extends BaseCmd {
+    public static final Logger s_logger = Logger.getLogger(AddSecondaryStorageCmd.class.getName());
+    private static final String s_name = "addsecondarystorageresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name=ApiConstants.URL, type=CommandType.STRING, required=true, description="the URL for the secondary storage")
+    private String url;
+
+    @IdentityMapper(entityTableName="data_center")
+    @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="the Zone ID for the secondary storage")
+    private Long zoneId;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public String getUrl() {
+        return url;
+    }
+
+    public Long getZoneId() {
+        return zoneId;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public void execute(){
+        try {
+            List<? extends Host> result = _resourceService.discoverHosts(this);
+            HostResponse hostResponse = null;
+            if (result != null && result.size() > 0) {
+                for (Host host : result) {
+                    // There should only be one secondary storage host per add
+                    hostResponse = _responseGenerator.createHostResponse(host);
+                    hostResponse.setResponseName(getCommandName());
+                    hostResponse.setObjectName("secondarystorage");
+                    this.setResponseObject(hostResponse);
+                }
+            } else {
+                throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add secondary storage");
+            }
+        } catch (DiscoveryException ex) {
+            s_logger.warn("Exception: ", ex);
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2a7fa674/api/src/org/apache/cloudstack/api/admin/host/command/CancelMaintenanceCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/admin/host/command/CancelMaintenanceCmd.java b/api/src/org/apache/cloudstack/api/admin/host/command/CancelMaintenanceCmd.java
new file mode 100644
index 0000000..2e84b00
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/admin/host/command/CancelMaintenanceCmd.java
@@ -0,0 +1,113 @@
+// 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.host.command;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+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.HostResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.host.Host;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@Implementation(description="Cancels host maintenance.", responseObject=HostResponse.class)
+public class CancelMaintenanceCmd extends BaseAsyncCmd  {
+    public static final Logger s_logger = Logger.getLogger(CancelMaintenanceCmd.class.getName());
+
+    private static final String s_name = "cancelhostmaintenanceresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="host")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the host ID")
+    private Long id;
+
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    public static String getResultObjectName() {
+        return "host";
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        Account account = UserContext.current().getCaller();
+        if (account != null) {
+            return account.getId();
+        }
+
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_MAINTENANCE_CANCEL;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return  "canceling maintenance for host: " + getId();
+    }
+
+    @Override
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.Host;
+    }
+
+    @Override
+    public Long getInstanceId() {
+        return getId();
+    }
+
+    @Override
+    public void execute(){
+        Host result = _resourceService.cancelMaintenance(this);
+        if (result != null) {
+            HostResponse response = _responseGenerator.createHostResponse(result);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to cancel host maintenance");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2a7fa674/api/src/org/apache/cloudstack/api/admin/host/command/DeleteHostCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/admin/host/command/DeleteHostCmd.java b/api/src/org/apache/cloudstack/api/admin/host/command/DeleteHostCmd.java
new file mode 100644
index 0000000..0f39a04
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/admin/host/command/DeleteHostCmd.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.host.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.user.Account;
+
+@Implementation(description = "Deletes a host.", responseObject = SuccessResponse.class)
+public class DeleteHostCmd extends BaseCmd {
+    public static final Logger s_logger = Logger.getLogger(DeleteHostCmd.class.getName());
+
+    private static final String s_name = "deletehostresponse";
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="host")
+    @Parameter(name = ApiConstants.ID, type = CommandType.LONG, required = true, description = "the host ID")
+    private Long id;
+
+    @Parameter(name = ApiConstants.FORCED, type = CommandType.BOOLEAN, description = "Force delete the host. All HA enabled vms running on the host will be put to HA; HA disabled ones will be stopped")
+    private Boolean forced;
+
+    @Parameter(name = ApiConstants.FORCED_DESTROY_LOCAL_STORAGE, type = CommandType.BOOLEAN, description = "Force destroy local storage on this host. All VMs created on this local storage will be destroyed")
+    private Boolean forceDestroyLocalStorage;
+
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    public boolean isForced() {
+        return (forced != null) ? forced : false;
+    }
+
+    public boolean isForceDestoryLocalStorage() {
+        return (forceDestroyLocalStorage != null) ? forceDestroyLocalStorage : true;
+    }
+
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public void execute() {
+        boolean result = _resourceService.deleteHost(getId(), isForced(), isForceDestoryLocalStorage());
+        if (result) {
+            SuccessResponse response = new SuccessResponse(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete host");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2a7fa674/api/src/org/apache/cloudstack/api/admin/host/command/ListHostsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/admin/host/command/ListHostsCmd.java b/api/src/org/apache/cloudstack/api/admin/host/command/ListHostsCmd.java
new file mode 100755
index 0000000..ec424c2
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/admin/host/command/ListHostsCmd.java
@@ -0,0 +1,192 @@
+// 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.host.command;
+
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiConstants.HostDetails;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import com.cloud.api.response.HostResponse;
+import com.cloud.api.response.ListResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.host.Host;
+import com.cloud.utils.Pair;
+
+@Implementation(description="Lists hosts.", responseObject=HostResponse.class)
+public class ListHostsCmd extends BaseListCmd {
+    public static final Logger s_logger = Logger.getLogger(ListHostsCmd.class.getName());
+
+    private static final String s_name = "listhostsresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="cluster")
+    @Parameter(name=ApiConstants.CLUSTER_ID, type=CommandType.LONG, description="lists hosts existing in particular cluster")
+    private Long clusterId;
+
+    @IdentityMapper(entityTableName="host")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the id of the host")
+    private Long id;
+
+    @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the host")
+    private String hostName;
+
+    @IdentityMapper(entityTableName="host_pod_ref")
+    @Parameter(name=ApiConstants.POD_ID, type=CommandType.LONG, description="the Pod ID for the host")
+    private Long podId;
+
+    @Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="the state of the host")
+    private String state;
+
+    @Parameter(name=ApiConstants.TYPE, type=CommandType.STRING, description="the host type")
+    private String type;
+
+    @IdentityMapper(entityTableName="data_center")
+    @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="the Zone ID for the host")
+    private Long zoneId;
+
+    @IdentityMapper(entityTableName="vm_instance")
+    @Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.LONG, required=false, description="lists hosts in the same cluster as this VM and flag hosts with enough CPU/RAm to host this VM")
+    private Long virtualMachineId;
+
+    @Parameter(name=ApiConstants.RESOURCE_STATE, type=CommandType.STRING, description="list hosts by resource state. Resource state represents current state determined by admin of host, valule can be one of [Enabled, Disabled, Unmanaged, PrepareForMaintenance, ErrorInMaintenance, Maintenance, Error]")
+    private String resourceState;
+
+    @Parameter(name=ApiConstants.DETAILS, type=CommandType.LIST, collectionType=CommandType.STRING, description="comma separated list of host details requested, value can be a list of [ min, all, capacity, events, stats]" )
+    private List<String> viewDetails;
+
+    @Parameter(name=ApiConstants.HA_HOST, type=CommandType.BOOLEAN, description="if true, list only hosts dedicated to HA")
+    private Boolean haHost;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getClusterId() {
+        return clusterId;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public String getHostName() {
+        return hostName;
+    }
+
+    public Long getPodId() {
+        return podId;
+    }
+
+    public String getState() {
+        return state;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public Boolean getHaHost() {
+        return haHost;
+    }
+
+    public Long getZoneId() {
+        return zoneId;
+    }
+
+    public Long getVirtualMachineId() {
+        return virtualMachineId;
+    }
+
+    public EnumSet<HostDetails> getDetails() throws InvalidParameterValueException {
+        EnumSet<HostDetails> dv;
+        if (viewDetails==null || viewDetails.size() <=0){
+            dv = EnumSet.of(HostDetails.all);
+        }
+        else {
+            try {
+                ArrayList<HostDetails> dc = new ArrayList<HostDetails>();
+                for (String detail: viewDetails){
+                    dc.add(HostDetails.valueOf(detail));
+                }
+                dv = EnumSet.copyOf(dc);
+            }
+            catch (IllegalArgumentException e){
+                throw new InvalidParameterValueException("The details parameter contains a non permitted value. The allowed values are " + EnumSet.allOf(HostDetails.class));
+            }
+        }
+        return dv;
+    }
+
+    public String getResourceState() {
+        return resourceState;
+    }
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.Host;
+    }
+
+    @Override
+    public void execute(){
+        List<? extends Host> result = new ArrayList<Host>();
+        List<? extends Host> hostsWithCapacity = new ArrayList<Host>();
+
+        if(getVirtualMachineId() != null){
+            Pair<List<? extends Host>, List<? extends Host>> hostsForMigration = _mgr.listHostsForMigrationOfVM(getVirtualMachineId(), this.getStartIndex(), this.getPageSizeVal());
+            result = hostsForMigration.first();
+            hostsWithCapacity = hostsForMigration.second();
+        }else{
+            result = _mgr.searchForServers(this);
+        }
+
+        ListResponse<HostResponse> response = new ListResponse<HostResponse>();
+        List<HostResponse> hostResponses = new ArrayList<HostResponse>();
+        for (Host host : result) {
+            HostResponse hostResponse = _responseGenerator.createHostResponse(host, getDetails());
+            Boolean suitableForMigration = false;
+            if(hostsWithCapacity.contains(host)){
+                suitableForMigration = true;
+            }
+            hostResponse.setSuitableForMigration(suitableForMigration);
+            hostResponse.setObjectName("host");
+            hostResponses.add(hostResponse);
+        }
+
+        response.setResponses(hostResponses);
+        response.setResponseName(getCommandName());
+        this.setResponseObject(response);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2a7fa674/api/src/org/apache/cloudstack/api/admin/host/command/PrepareForMaintenanceCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/admin/host/command/PrepareForMaintenanceCmd.java b/api/src/org/apache/cloudstack/api/admin/host/command/PrepareForMaintenanceCmd.java
new file mode 100644
index 0000000..b6d178e
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/admin/host/command/PrepareForMaintenanceCmd.java
@@ -0,0 +1,111 @@
+// 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.host.command;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+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.HostResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.host.Host;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@Implementation(description="Prepares a host for maintenance.", responseObject=HostResponse.class)
+public class PrepareForMaintenanceCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(PrepareForMaintenanceCmd.class.getName());
+
+    private static final String s_name = "preparehostformaintenanceresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="host")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the host ID")
+    private Long id;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    public static String getResultObjectName() {
+        return "host";
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        Account account = UserContext.current().getCaller();
+        if (account != null) {
+            return account.getId();
+        }
+
+        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_MAINTENANCE_PREPARE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return  "preparing host: " + getId() + " for maintenance";
+    }
+
+    @Override
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.Host;
+    }
+
+    @Override
+    public Long getInstanceId() {
+        return getId();
+    }
+
+    @Override
+    public void execute(){
+        Host result = _resourceService.maintain(this);
+        if (result != null){
+            HostResponse response = _responseGenerator.createHostResponse(result);
+            response.setResponseName("host");
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to prepare host for maintenance");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/2a7fa674/api/src/org/apache/cloudstack/api/admin/host/command/ReconnectHostCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/admin/host/command/ReconnectHostCmd.java b/api/src/org/apache/cloudstack/api/admin/host/command/ReconnectHostCmd.java
new file mode 100755
index 0000000..2c57ade
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/admin/host/command/ReconnectHostCmd.java
@@ -0,0 +1,114 @@
+// 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.host.command;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+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.HostResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.host.Host;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@Implementation(description="Reconnects a host.", responseObject=HostResponse.class)
+public class ReconnectHostCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(ReconnectHostCmd.class.getName());
+
+    private static final String s_name = "reconnecthostresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="host")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the host ID")
+    private Long id;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    public static String getResultObjectName() {
+        return "host";
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        Account account = UserContext.current().getCaller();
+        if (account != null) {
+            return account.getId();
+        }
+
+        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_HOST_RECONNECT;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return  "reconnecting host: " + getId();
+    }
+
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.Host;
+    }
+
+    public Long getInstanceId() {
+        return getId();
+    }
+
+    @Override
+    public void execute(){
+        try {
+            Host result = _resourceService.reconnectHost(this);
+            if (result != null){
+                HostResponse response = _responseGenerator.createHostResponse(result);
+                response.setResponseName(getCommandName());
+                this.setResponseObject(response);
+            } else {
+                throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to reconnect host");
+            }
+        } catch (Exception ex) {
+            s_logger.warn("Exception: ", ex);
+            throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
+        }
+    }
+}