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/08 04:29:52 UTC

[34/57] api: move and group all under command, org.apache.cloudstack.command.*

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/account/UpdateAccountCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/account/UpdateAccountCmd.java b/api/src/org/apache/cloudstack/api/command/admin/account/UpdateAccountCmd.java
new file mode 100755
index 0000000..6463265
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/account/UpdateAccountCmd.java
@@ -0,0 +1,130 @@
+// 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.command.admin.account;
+
+import java.util.Collection;
+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.IdentityMapper;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import com.cloud.api.response.AccountResponse;
+import com.cloud.user.Account;
+
+@Implementation(description="Updates account information for the authenticated user", responseObject=AccountResponse.class)
+public class UpdateAccountCmd extends BaseCmd{
+    public static final Logger s_logger = Logger.getLogger(UpdateAccountCmd.class.getName());
+    private static final String s_name = "updateaccountresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="account")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="Account id")
+    private Long id;
+
+    @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="the current account name")
+    private String accountName;
+
+    @IdentityMapper(entityTableName="domain")
+    @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the ID of the domain where the account exists")
+    private Long domainId;
+
+    @Parameter(name=ApiConstants.NEW_NAME, type=CommandType.STRING, required=true, description="new name for the account")
+    private String newName;
+
+    @Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="Network domain for the account's networks; empty string will update domainName with NULL value")
+    private String networkDomain;
+
+    @Parameter(name = ApiConstants.ACCOUNT_DETAILS, type = CommandType.MAP, description = "details for account used to store specific parameters")
+    private Map details;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    public String getAccountName() {
+        return accountName;
+    }
+
+    public Long getDomainId() {
+        return domainId;
+    }
+
+    public String getNewName() {
+        return newName;
+    }
+
+    public String getNetworkDomain() {
+        return networkDomain;
+    }
+
+    public Map getDetails() {
+        if (details == null || details.isEmpty()) {
+            return null;
+        }
+
+        Collection paramsCollection = details.values();
+        Map params = (Map) (paramsCollection.toArray())[0];
+        return params;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        Account account = _entityMgr.findById(Account.class, getId());
+        if (account != null) {
+            return account.getAccountId();
+        }
+        account = _accountService.getActiveAccountByName(getAccountName(), getDomainId());
+        if (account != null) {
+            return account.getAccountId();
+        }
+
+        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+    }
+
+    @Override
+    public void execute(){
+        Account result = _accountService.updateAccount(this);
+        if (result != null){
+            AccountResponse response = _responseGenerator.createAccountResponse(result);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update account");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/autoscale/CreateCounterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/autoscale/CreateCounterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/autoscale/CreateCounterCmd.java
new file mode 100644
index 0000000..c97ddca
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/autoscale/CreateCounterCmd.java
@@ -0,0 +1,120 @@
+// 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.command.admin.autoscale;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseAsyncCreateCmd;
+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.api.response.CounterResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.network.as.Counter;
+import com.cloud.user.Account;
+
+@Implementation(description = "Adds metric counter", responseObject = CounterResponse.class)
+public class CreateCounterCmd extends BaseAsyncCreateCmd {
+    public static final Logger s_logger = Logger.getLogger(CreateCounterCmd.class.getName());
+    private static final String s_name = "counterresponse";
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "Name of the counter.")
+    private String name;
+
+    @Parameter(name = ApiConstants.SOURCE, type = CommandType.STRING, required = true, description = "Source of the counter.")
+    private String source;
+
+    @Parameter(name = ApiConstants.VALUE, type = CommandType.STRING, required = true, description = "Value of the counter e.g. oid in case of snmp.")
+    private String value;
+
+    // /////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    public String getName() {
+        return name;
+    }
+
+    public String getSource() {
+        return source;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public void create() {
+        Counter ctr = null;
+        ctr = _autoScaleService.createCounter(this);
+
+        if (ctr != null) {
+            this.setEntityId(ctr.getId());
+            CounterResponse response = _responseGenerator.createCounterResponse(ctr);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create Counter with name " + getName());
+        }
+    }
+
+    @Override
+    public void execute() {
+    }
+
+    @Override
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.Counter;
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_COUNTER_CREATE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "creating a new Counter";
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public String getEntityTable() {
+        return "counter";
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/autoscale/DeleteCounterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/autoscale/DeleteCounterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/autoscale/DeleteCounterCmd.java
new file mode 100644
index 0000000..750d2ab
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/autoscale/DeleteCounterCmd.java
@@ -0,0 +1,103 @@
+// 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.command.admin.autoscale;
+
+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.SuccessResponse;
+import com.cloud.async.AsyncJob;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ResourceInUseException;
+import com.cloud.user.Account;
+
+@Implementation(description = "Deletes a counter", responseObject = SuccessResponse.class)
+public class DeleteCounterCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(DeleteCounterCmd.class.getName());
+    private static final String s_name = "deletecounterresponse";
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName = "counter")
+    @Parameter(name = ApiConstants.ID, type = CommandType.LONG, required = true, description = "the ID of the counter")
+    private Long id;
+
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public void execute() {
+        boolean result = false;
+        try {
+            result = _autoScaleService.deleteCounter(getId());
+        } catch (ResourceInUseException ex) {
+            s_logger.warn("Exception: ", ex);
+            throw new ServerApiException(BaseCmd.RESOURCE_IN_USE_ERROR, ex.getMessage());
+        }
+
+        if (result) {
+            SuccessResponse response = new SuccessResponse(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            s_logger.warn("Failed to delete counter with Id: " + getId());
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete counter.");
+        }
+    }
+
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    @Override
+    public AsyncJob.Type getInstanceType() {
+        return AsyncJob.Type.Counter;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_COUNTER_DELETE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "Deleting a counter.";
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/cluster/AddClusterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/cluster/AddClusterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/cluster/AddClusterCmd.java
new file mode 100755
index 0000000..d5e6aee
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/cluster/AddClusterCmd.java
@@ -0,0 +1,181 @@
+// 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.command.admin.cluster;
+
+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.ClusterResponse;
+import com.cloud.api.response.ListResponse;
+import com.cloud.exception.DiscoveryException;
+import com.cloud.exception.ResourceInUseException;
+import com.cloud.org.Cluster;
+import com.cloud.user.Account;
+import com.cloud.utils.IdentityProxy;
+
+@Implementation(description="Adds a new cluster", responseObject=ClusterResponse.class)
+public class AddClusterCmd extends BaseCmd {
+    public static final Logger s_logger = Logger.getLogger(AddClusterCmd.class.getName());
+
+    private static final String s_name = "addclusterresponse";
+
+    @Parameter(name=ApiConstants.CLUSTER_NAME, type=CommandType.STRING, required=true, description="the cluster name")
+    private String clusterName;
+
+    @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required=false, description="the password for the host")
+    private String password;
+
+    @IdentityMapper(entityTableName="host_pod_ref")
+    @Parameter(name=ApiConstants.POD_ID, type=CommandType.LONG, required=true, description="the Pod ID for the host")
+    private Long podId;
+
+    @Parameter(name=ApiConstants.URL, type=CommandType.STRING, required=false, description="the URL")
+    private String url;
+
+    @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required=false, description="the username for the cluster")
+    private String username;
+
+    @IdentityMapper(entityTableName="data_center")
+
+    @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, required=true, description="the Zone ID for the cluster")
+    private Long zoneId;
+
+    @Parameter(name=ApiConstants.HYPERVISOR, type=CommandType.STRING, required=true, description="hypervisor type of the cluster: XenServer,KVM,VMware,Hyperv,BareMetal,Simulator")
+    private String hypervisor;
+
+    @Parameter(name=ApiConstants.CLUSTER_TYPE, type=CommandType.STRING, required=true, description="type of the cluster: CloudManaged, ExternalManaged")
+    private String clusterType;
+
+    @Parameter(name=ApiConstants.ALLOCATION_STATE, type=CommandType.STRING, description="Allocation state of this cluster for allocation of new resources")
+    private String allocationState;
+
+    @Parameter(name = ApiConstants.VSM_USERNAME, type = CommandType.STRING, required = false, description = "the username for the VSM associated with this cluster")
+    private String vsmusername;
+
+    @Parameter(name = ApiConstants.VSM_PASSWORD, type = CommandType.STRING, required = false, description = "the password for the VSM associated with this cluster")
+    private String vsmpassword;
+
+    @Parameter(name = ApiConstants.VSM_IPADDRESS, type = CommandType.STRING, required = false, description = "the ipaddress of the VSM associated with this cluster")
+    private String vsmipaddress;
+
+    public String getVSMIpaddress() {
+        return vsmipaddress;
+    }
+
+    public String getVSMPassword() {
+        return vsmpassword;
+    }
+
+    public String getVSMUsername() {
+        return vsmusername;
+    }
+
+    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;
+    }
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    public String getClusterType() {
+        return clusterType;
+    }
+
+    public void setClusterType(String type) {
+        this.clusterType = type;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    public String getAllocationState() {
+        return allocationState;
+    }
+
+    public void setAllocationState(String allocationState) {
+        this.allocationState = allocationState;
+    }
+
+    @Override
+    public void execute(){
+        try {
+            List<? extends Cluster> result = _resourceService.discoverCluster(this);
+            ListResponse<ClusterResponse> response = new ListResponse<ClusterResponse>();
+            List<ClusterResponse> clusterResponses = new ArrayList<ClusterResponse>();
+            if (result != null && result.size() > 0) {
+                for (Cluster cluster : result) {
+                    ClusterResponse clusterResponse = _responseGenerator.createClusterResponse(cluster, false);
+                    clusterResponses.add(clusterResponse);
+                }
+            } else {
+                throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add cluster");
+            }
+
+            response.setResponses(clusterResponses);
+            response.setResponseName(getCommandName());
+
+            this.setResponseObject(response);
+        } catch (DiscoveryException ex) {
+            s_logger.warn("Exception: ", ex);
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
+        } catch (ResourceInUseException ex) {
+            s_logger.warn("Exception: ", ex);
+            ServerApiException e = new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
+            for (IdentityProxy proxyObj : ex.getIdProxyList()) {
+                e.addProxyObject(proxyObj.getTableName(), proxyObj.getValue(), proxyObj.getidFieldName());
+            }
+            throw e;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/cluster/DeleteClusterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/cluster/DeleteClusterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/cluster/DeleteClusterCmd.java
new file mode 100755
index 0000000..70eeb9a
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/cluster/DeleteClusterCmd.java
@@ -0,0 +1,79 @@
+// 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.command.admin.cluster;
+
+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 cluster.", responseObject=SuccessResponse.class)
+public class DeleteClusterCmd extends BaseCmd {
+    public static final Logger s_logger = Logger.getLogger(DeleteClusterCmd.class.getName());
+
+    private static final String s_name = "deleteclusterresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="cluster")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the cluster ID")
+    private Long id;
+
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+
+    /////////////////////////////////////////////////////
+    /////////////// 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.deleteCluster(this);
+        if (result) {
+            SuccessResponse response = new SuccessResponse(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete cluster");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/cluster/ListClustersCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/cluster/ListClustersCmd.java b/api/src/org/apache/cloudstack/api/command/admin/cluster/ListClustersCmd.java
new file mode 100755
index 0000000..7a01ba6
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/cluster/ListClustersCmd.java
@@ -0,0 +1,145 @@
+// 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.command.admin.cluster;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.cloudstack.api.command.user.offering.ListServiceOfferingsCmd;
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+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.ClusterResponse;
+import com.cloud.api.response.ListResponse;
+import com.cloud.org.Cluster;
+import com.cloud.utils.Pair;
+
+@Implementation(description="Lists clusters.", responseObject=ClusterResponse.class)
+public class ListClustersCmd extends BaseListCmd {
+    public static final Logger s_logger = Logger.getLogger(ListServiceOfferingsCmd.class.getName());
+
+    private static final String s_name = "listclustersresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="cluster")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="lists clusters by the cluster ID")
+    private Long id;
+
+    @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="lists clusters by the cluster name")
+    private String clusterName;
+
+    @IdentityMapper(entityTableName="host_pod_ref")
+    @Parameter(name=ApiConstants.POD_ID, type=CommandType.LONG, description="lists clusters by Pod ID")
+    private Long podId;
+
+    @IdentityMapper(entityTableName="data_center")
+    @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="lists clusters by Zone ID")
+    private Long zoneId;
+
+    @Parameter(name=ApiConstants.HYPERVISOR, type=CommandType.STRING, description="lists clusters by hypervisor type")
+    private String hypervisorType;
+
+    @Parameter(name=ApiConstants.CLUSTER_TYPE, type=CommandType.STRING, description="lists clusters by cluster type")
+    private String clusterType;
+
+    @Parameter(name=ApiConstants.ALLOCATION_STATE, type=CommandType.STRING, description="lists clusters by allocation state")
+    private String allocationState;
+
+    @Parameter(name=ApiConstants.MANAGED_STATE, type=CommandType.STRING, description="whether this cluster is managed by cloudstack")
+    private String managedState;
+
+    @Parameter(name=ApiConstants.SHOW_CAPACITIES, type=CommandType.BOOLEAN, description="flag to display the capacity of the clusters")
+    private Boolean showCapacities;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    public String getClusterName() {
+        return clusterName;
+    }
+
+    public Long getPodId() {
+        return podId;
+    }
+
+    public Long getZoneId() {
+        return zoneId;
+    }
+
+    public String getHypervisorType() {
+        return hypervisorType;
+    }
+
+    public String getClusterType() {
+        return clusterType;
+    }
+
+    public String getAllocationState() {
+        return allocationState;
+    }
+
+
+    public String getManagedstate() {
+        return managedState;
+    }
+
+    public void setManagedstate(String managedstate) {
+        this.managedState = managedstate;
+    }
+
+
+    public Boolean getShowCapacities() {
+        return showCapacities;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public void execute(){
+        Pair<List<? extends Cluster>, Integer> result = _mgr.searchForClusters(this);
+        ListResponse<ClusterResponse> response = new ListResponse<ClusterResponse>();
+        List<ClusterResponse> clusterResponses = new ArrayList<ClusterResponse>();
+        for (Cluster cluster : result.first()) {
+            ClusterResponse clusterResponse = _responseGenerator.createClusterResponse(cluster,showCapacities);
+            clusterResponse.setObjectName("cluster");
+            clusterResponses.add(clusterResponse);
+        }
+
+        response.setResponses(clusterResponses, result.second());
+        response.setResponseName(getCommandName());
+        this.setResponseObject(response);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/cluster/UpdateClusterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/cluster/UpdateClusterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/cluster/UpdateClusterCmd.java
new file mode 100755
index 0000000..81c3114
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/cluster/UpdateClusterCmd.java
@@ -0,0 +1,119 @@
+// 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.command.admin.cluster;
+
+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.ClusterResponse;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.org.Cluster;
+import com.cloud.user.Account;
+
+@Implementation(description="Updates an existing cluster", responseObject=ClusterResponse.class)
+public class UpdateClusterCmd extends BaseCmd {
+    public static final Logger s_logger = Logger.getLogger(AddClusterCmd.class.getName());
+
+    private static final String s_name = "updateclusterresponse";
+
+    @IdentityMapper(entityTableName="cluster")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the ID of the Cluster")
+    private Long id;
+
+    @Parameter(name=ApiConstants.CLUSTER_NAME, type=CommandType.STRING, description="the cluster name")
+    private String clusterName;
+
+    @Parameter(name=ApiConstants.HYPERVISOR, type=CommandType.STRING, description="hypervisor type of the cluster")
+    private String hypervisor;
+
+    @Parameter(name=ApiConstants.CLUSTER_TYPE, type=CommandType.STRING, description="hypervisor type of the cluster")
+    private String clusterType;
+
+    @Parameter(name=ApiConstants.ALLOCATION_STATE, type=CommandType.STRING, description="Allocation state of this cluster for allocation of new resources")
+    private String allocationState;
+
+    @Parameter(name=ApiConstants.MANAGED_STATE, type=CommandType.STRING, description="whether this cluster is managed by cloudstack")
+    private String managedState;
+
+    public String getClusterName() {
+        return clusterName;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public String getHypervisor() {
+        return hypervisor;
+    }
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    public String getClusterType() {
+        return clusterType;
+    }
+
+    public void setClusterType(String type) {
+        this.clusterType = type;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    public String getAllocationState() {
+        return allocationState;
+    }
+
+    public void setAllocationState(String allocationState) {
+        this.allocationState = allocationState;
+    }
+
+    public String getManagedstate() {
+        return managedState;
+    }
+
+    public void setManagedstate(String managedstate) {
+        this.managedState = managedstate;
+    }
+
+    @Override
+    public void execute(){
+        Cluster cluster = _resourceService.getCluster(getId());
+        if (cluster == null) {
+            throw new InvalidParameterValueException("Unable to find the cluster by id=" + getId());
+        }
+
+        Cluster result = _resourceService.updateCluster(cluster, getClusterType(), getHypervisor(), getAllocationState(), getManagedstate());
+        if (result != null) {
+                ClusterResponse clusterResponse = _responseGenerator.createClusterResponse(cluster, false);
+                clusterResponse.setResponseName(getCommandName());
+                this.setResponseObject(clusterResponse);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update cluster");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/config/ListCfgsByCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/config/ListCfgsByCmd.java b/api/src/org/apache/cloudstack/api/command/admin/config/ListCfgsByCmd.java
new file mode 100644
index 0000000..ba583e8
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/config/ListCfgsByCmd.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.command.admin.config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.Implementation;
+import org.apache.cloudstack.api.Parameter;
+import com.cloud.api.response.ConfigurationResponse;
+import com.cloud.api.response.ListResponse;
+import com.cloud.configuration.Configuration;
+import com.cloud.utils.Pair;
+
+@Implementation(description = "Lists all configurations.", responseObject = ConfigurationResponse.class)
+public class ListCfgsByCmd extends BaseListCmd {
+    public static final Logger s_logger = Logger.getLogger(ListCfgsByCmd.class.getName());
+
+    private static final String s_name = "listconfigurationsresponse";
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.CATEGORY, type = CommandType.STRING, description = "lists configurations by category")
+    private String category;
+
+    @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "lists configuration by name")
+    private String configName;
+
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    public String getCategory() {
+        return category;
+    }
+
+    public String getConfigName() {
+        return configName;
+    }
+
+    @Override
+    public Long getPageSizeVal() {
+        Long pageSizeVal = 500L;
+        Integer pageSize = getPageSize();
+        if (pageSize != null) {
+            pageSizeVal = pageSize.longValue();
+        }
+        return pageSizeVal;
+    }
+
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public void execute() {
+        Pair<List<? extends Configuration>, Integer> result = _mgr.searchForConfigurations(this);
+        ListResponse<ConfigurationResponse> response = new ListResponse<ConfigurationResponse>();
+        List<ConfigurationResponse> configResponses = new ArrayList<ConfigurationResponse>();
+        for (Configuration cfg : result.first()) {
+            ConfigurationResponse cfgResponse = _responseGenerator.createConfigurationResponse(cfg);
+            cfgResponse.setObjectName("configuration");
+            configResponses.add(cfgResponse);
+        }
+
+        response.setResponses(configResponses, result.second());
+        response.setResponseName(getCommandName());
+        this.setResponseObject(response);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/config/ListHypervisorCapabilitiesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/config/ListHypervisorCapabilitiesCmd.java b/api/src/org/apache/cloudstack/api/command/admin/config/ListHypervisorCapabilitiesCmd.java
new file mode 100644
index 0000000..d8e2ac5
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/config/ListHypervisorCapabilitiesCmd.java
@@ -0,0 +1,94 @@
+// 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.command.admin.config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+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.HypervisorCapabilitiesResponse;
+import com.cloud.api.response.ListResponse;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.hypervisor.HypervisorCapabilities;
+import com.cloud.utils.Pair;
+
+@Implementation(description="Lists all hypervisor capabilities.", responseObject=HypervisorCapabilitiesResponse.class, since="3.0.0")
+public class ListHypervisorCapabilitiesCmd extends BaseListCmd {
+    public static final Logger s_logger = Logger.getLogger(ListHypervisorCapabilitiesCmd.class.getName());
+
+    private static final String s_name = "listhypervisorcapabilitiesresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="hypervisor_capabilities")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="ID of the hypervisor capability")
+    private Long id;
+
+    @Parameter(name=ApiConstants.HYPERVISOR, type=CommandType.STRING, description="the hypervisor for which to restrict the search")
+    private String hypervisor;
+
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    public HypervisorType getHypervisor() {
+        if(hypervisor != null){
+            return HypervisorType.getType(hypervisor);
+        }else{
+            return null;
+        }
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public void execute(){
+        Pair<List<? extends HypervisorCapabilities>, Integer> hpvCapabilities = _mgr.listHypervisorCapabilities(getId(),
+                getHypervisor(), getKeyword(), this.getStartIndex(), this.getPageSizeVal());
+        ListResponse<HypervisorCapabilitiesResponse> response = new ListResponse<HypervisorCapabilitiesResponse>();
+        List<HypervisorCapabilitiesResponse> hpvCapabilitiesResponses = new ArrayList<HypervisorCapabilitiesResponse>();
+        for (HypervisorCapabilities capability : hpvCapabilities.first()) {
+            HypervisorCapabilitiesResponse hpvCapabilityResponse = _responseGenerator.createHypervisorCapabilitiesResponse(capability);
+            hpvCapabilityResponse.setObjectName("hypervisorCapabilities");
+            hpvCapabilitiesResponses.add(hpvCapabilityResponse);
+        }
+
+        response.setResponses(hpvCapabilitiesResponses, hpvCapabilities.second());
+        response.setResponseName(getCommandName());
+        this.setResponseObject(response);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/config/UpdateCfgCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/config/UpdateCfgCmd.java b/api/src/org/apache/cloudstack/api/command/admin/config/UpdateCfgCmd.java
new file mode 100644
index 0000000..dc25e4d
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/config/UpdateCfgCmd.java
@@ -0,0 +1,82 @@
+// 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.command.admin.config;
+
+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.api.response.ConfigurationResponse;
+import com.cloud.configuration.Configuration;
+import com.cloud.user.Account;
+
+@Implementation(description="Updates a configuration.", responseObject=ConfigurationResponse.class)
+public class UpdateCfgCmd extends BaseCmd {
+    public static final Logger s_logger = Logger.getLogger(UpdateCfgCmd.class.getName());
+    private static final String s_name = "updateconfigurationresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the configuration")
+    private String cfgName;
+
+    @Parameter(name=ApiConstants.VALUE, type=CommandType.STRING, description="the value of the configuration", length=4095)
+    private String value;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public String getCfgName() {
+        return cfgName;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public void execute(){
+        Configuration cfg = _configService.updateConfiguration(this);
+        if (cfg != null) {
+            ConfigurationResponse response = _responseGenerator.createConfigurationResponse(cfg);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update config");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/config/UpdateHypervisorCapabilitiesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/config/UpdateHypervisorCapabilitiesCmd.java b/api/src/org/apache/cloudstack/api/command/admin/config/UpdateHypervisorCapabilitiesCmd.java
new file mode 100644
index 0000000..3f4f234
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/config/UpdateHypervisorCapabilitiesCmd.java
@@ -0,0 +1,96 @@
+// 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.command.admin.config;
+
+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.HypervisorCapabilitiesResponse;
+import com.cloud.api.response.ServiceOfferingResponse;
+import com.cloud.hypervisor.HypervisorCapabilities;
+import com.cloud.user.Account;
+
+
+@Implementation(description="Updates a hypervisor capabilities.", responseObject=ServiceOfferingResponse.class, since="3.0.0")
+public class UpdateHypervisorCapabilitiesCmd extends BaseCmd {
+    public static final Logger s_logger = Logger.getLogger(UpdateHypervisorCapabilitiesCmd.class.getName());
+    private static final String s_name = "updatehypervisorcapabilitiesresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="hypervisor_capabilities")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="ID of the hypervisor capability")
+    private Long id;
+
+    @Parameter(name=ApiConstants.SECURITY_GROUP_EANBLED, type=CommandType.BOOLEAN, description="set true to enable security group for this hypervisor.")
+    private Boolean securityGroupEnabled;
+
+    @Parameter(name=ApiConstants.MAX_GUESTS_LIMIT, type=CommandType.LONG, description="the max number of Guest VMs per host for this hypervisor.")
+    private Long maxGuestsLimit;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Boolean getSecurityGroupEnabled() {
+        return securityGroupEnabled;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public Long getMaxGuestsLimit() {
+        return maxGuestsLimit;
+    }
+
+
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public void execute(){
+        HypervisorCapabilities result = _mgr.updateHypervisorCapabilities(getId(), getMaxGuestsLimit(), getSecurityGroupEnabled());
+        if (result != null){
+            HypervisorCapabilitiesResponse response = _responseGenerator.createHypervisorCapabilitiesResponse(result);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update hypervisor capabilities");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/domain/CreateDomainCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/domain/CreateDomainCmd.java b/api/src/org/apache/cloudstack/api/command/admin/domain/CreateDomainCmd.java
new file mode 100644
index 0000000..c8a653d
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/domain/CreateDomainCmd.java
@@ -0,0 +1,94 @@
+// 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.command.admin.domain;
+
+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.DomainResponse;
+import com.cloud.domain.Domain;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@Implementation(description="Creates a domain", responseObject=DomainResponse.class)
+public class CreateDomainCmd extends BaseCmd {
+    public static final Logger s_logger = Logger.getLogger(CreateDomainCmd.class.getName());
+
+    private static final String s_name = "createdomainresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="creates domain with this name")
+    private String domainName;
+
+    @IdentityMapper(entityTableName="domain")
+    @Parameter(name=ApiConstants.PARENT_DOMAIN_ID, type=CommandType.LONG, description="assigns new domain a parent domain by domain ID of the parent.  If no parent domain is specied, the ROOT domain is assumed.")
+    private Long parentDomainId;
+
+    @Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="Network domain for networks in the domain")
+    private String networkDomain;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public String getDomainName() {
+        return domainName;
+    }
+
+    public Long getParentDomainId() {
+        return parentDomainId;
+    }
+
+    public String getNetworkDomain() {
+        return networkDomain;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public void execute(){
+        UserContext.current().setEventDetails("Domain Name: "+getDomainName()+((getParentDomainId()!=null)?", Parent DomainId :"+getParentDomainId():""));
+        Domain domain = _domainService.createDomain(getDomainName(), getParentDomainId(), getNetworkDomain());
+        if (domain != null) {
+            DomainResponse response = _responseGenerator.createDomainResponse(domain);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create domain");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/domain/DeleteDomainCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/domain/DeleteDomainCmd.java b/api/src/org/apache/cloudstack/api/command/admin/domain/DeleteDomainCmd.java
new file mode 100644
index 0000000..6b9831b
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/domain/DeleteDomainCmd.java
@@ -0,0 +1,103 @@
+// 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.command.admin.domain;
+
+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.SuccessResponse;
+import com.cloud.domain.Domain;
+import com.cloud.event.EventTypes;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@Implementation(description="Deletes a specified domain", responseObject=SuccessResponse.class)
+public class DeleteDomainCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(DeleteDomainCmd.class.getName());
+    private static final String s_name = "deletedomainresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="domain")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="ID of domain to delete")
+    private Long id;
+
+    @Parameter(name=ApiConstants.CLEANUP, type=CommandType.BOOLEAN, description="true if all domain resources (child domains, accounts) have to be cleaned up, false otherwise")
+    private Boolean cleanup;
+
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    public Boolean getCleanup() {
+        return cleanup;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        Domain domain = _entityMgr.findById(Domain.class, getId());
+        if (domain != null) {
+            return domain.getAccountId();
+        }
+
+        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_DOMAIN_DELETE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return  "deleting domain: " + getId();
+    }
+
+    @Override
+    public void execute(){
+        UserContext.current().setEventDetails("Domain Id: "+getId());
+        boolean result = _domainService.deleteDomain(id, cleanup);
+        if (result) {
+            SuccessResponse response = new SuccessResponse(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete domain");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/domain/ListDomainChildrenCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/domain/ListDomainChildrenCmd.java b/api/src/org/apache/cloudstack/api/command/admin/domain/ListDomainChildrenCmd.java
new file mode 100644
index 0000000..5532478
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/domain/ListDomainChildrenCmd.java
@@ -0,0 +1,101 @@
+// 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.command.admin.domain;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+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.DomainResponse;
+import com.cloud.api.response.ListResponse;
+import com.cloud.domain.Domain;
+import com.cloud.utils.Pair;
+
+@Implementation(description="Lists all children domains belonging to a specified domain", responseObject=DomainResponse.class)
+public class ListDomainChildrenCmd extends BaseListCmd {
+    public static final Logger s_logger = Logger.getLogger(ListDomainChildrenCmd.class.getName());
+
+    private static final String s_name = "listdomainchildrenresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="domain")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="list children domain by parent domain ID.")
+    private Long id;
+
+    @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="list children domains by name")
+    private String domainName;
+
+    @Parameter(name=ApiConstants.IS_RECURSIVE, type=CommandType.BOOLEAN, description="to return the entire tree, use the value \"true\". To return the first level children, use the value \"false\".")
+    private Boolean recursive;
+
+    @Parameter(name=ApiConstants.LIST_ALL, type=CommandType.BOOLEAN, description="If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false")
+    private Boolean listAll;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    public String getDomainName() {
+        return domainName;
+    }
+
+    public boolean listAll() {
+        return listAll == null ? false : listAll;
+    }
+
+    public boolean isRecursive() {
+        return recursive == null ? false : recursive;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public void execute(){
+        Pair<List<? extends Domain>, Integer> result = _domainService.searchForDomainChildren(this);
+        ListResponse<DomainResponse> response = new ListResponse<DomainResponse>();
+        List<DomainResponse> domainResponses = new ArrayList<DomainResponse>();
+        for (Domain domain : result.first()) {
+            DomainResponse domainResponse = _responseGenerator.createDomainResponse(domain);
+            domainResponse.setObjectName("domain");
+            domainResponses.add(domainResponse);
+        }
+
+        response.setResponses(domainResponses, result.second());
+        response.setResponseName(getCommandName());
+        this.setResponseObject(response);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/domain/ListDomainsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/domain/ListDomainsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/domain/ListDomainsCmd.java
new file mode 100644
index 0000000..cb7d65a
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/domain/ListDomainsCmd.java
@@ -0,0 +1,101 @@
+// 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.command.admin.domain;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+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.DomainResponse;
+import com.cloud.api.response.ListResponse;
+import com.cloud.domain.Domain;
+import com.cloud.utils.Pair;
+
+@Implementation(description="Lists domains and provides detailed information for listed domains", responseObject=DomainResponse.class)
+public class ListDomainsCmd extends BaseListCmd {
+    public static final Logger s_logger = Logger.getLogger(ListDomainsCmd.class.getName());
+
+    private static final String s_name = "listdomainsresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="domain")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="List domain by domain ID.")
+    private Long id;
+
+    @Parameter(name=ApiConstants.LEVEL, type=CommandType.INTEGER, description="List domains by domain level.")
+    private Integer level;
+
+    @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="List domain by domain name.")
+    private String domainName;
+
+    @Parameter(name=ApiConstants.LIST_ALL, type=CommandType.BOOLEAN, description="If set to false, list only resources belonging to the command's caller; if set to true - list resources that the caller is authorized to see. Default value is false")
+    private Boolean listAll;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    public Integer getLevel() {
+        return level;
+    }
+
+    public String getDomainName() {
+        return domainName;
+    }
+
+    public boolean listAll() {
+        return listAll == null ? false : listAll;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public void execute(){
+        Pair<List<? extends Domain>, Integer> result = _domainService.searchForDomains(this);
+        ListResponse<DomainResponse> response = new ListResponse<DomainResponse>();
+        List<DomainResponse> domainResponses = new ArrayList<DomainResponse>();
+        for (Domain domain : result.first()) {
+            DomainResponse domainResponse = _responseGenerator.createDomainResponse(domain);
+            domainResponse.setObjectName("domain");
+            domainResponses.add(domainResponse);
+        }
+
+        response.setResponses(domainResponses, result.second());
+        response.setResponseName(getCommandName());
+        this.setResponseObject(response);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/domain/UpdateDomainCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/domain/UpdateDomainCmd.java b/api/src/org/apache/cloudstack/api/command/admin/domain/UpdateDomainCmd.java
new file mode 100644
index 0000000..4107097
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/domain/UpdateDomainCmd.java
@@ -0,0 +1,93 @@
+// 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.command.admin.domain;
+
+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.DomainResponse;
+import com.cloud.domain.Domain;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+@Implementation(description="Updates a domain with a new name", responseObject=DomainResponse.class)
+public class UpdateDomainCmd extends BaseCmd {
+    public static final Logger s_logger = Logger.getLogger(UpdateDomainCmd.class.getName());
+    private static final String s_name = "updatedomainresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @IdentityMapper(entityTableName="domain")
+    @Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="ID of domain to update")
+    private Long id;
+
+    @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="updates domain with this name")
+    private String domainName;
+
+    @Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="Network domain for the domain's networks; empty string will update domainName with NULL value")
+    private String networkDomain;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    public String getDomainName() {
+        return domainName;
+    }
+
+    public String getNetworkDomain() {
+        return networkDomain;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return Account.ACCOUNT_ID_SYSTEM;
+    }
+
+    @Override
+    public void execute(){
+        UserContext.current().setEventDetails("Domain Id: "+getId());
+        Domain domain = _mgr.updateDomain(this);
+        if (domain != null) {
+            DomainResponse response = _responseGenerator.createDomainResponse(domain);
+            response.setResponseName(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update domain");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af28c069/api/src/org/apache/cloudstack/api/command/admin/host/AddHostCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/AddHostCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/AddHostCmd.java
new file mode 100755
index 0000000..e3ac4aa
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/host/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.command.admin.host;
+
+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/af28c069/api/src/org/apache/cloudstack/api/command/admin/host/AddSecondaryStorageCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/AddSecondaryStorageCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/AddSecondaryStorageCmd.java
new file mode 100644
index 0000000..31ab929
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/host/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.command.admin.host;
+
+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());
+        }
+    }
+}