cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sw...@apache.org
Subject [5/9] git commit: updated refs/heads/master to 143265c
Date Thu, 12 May 2016 15:06:54 GMT
CLOUDSTACK-9299: Out-of-band Management for CloudStack

Support access to a host’s out-of-band management interface (e.g. IPMI, iLO,
DRAC, etc.) to manage host power operations (on/off etc.) and querying current
power state in CloudStack.

Given the wide range of out-of-band management interfaces such as iLO and iDRA,
the service implementation allows for development of separate drivers as plugins.
This feature comes with a ipmitool based driver that uses the
ipmitool (http://linux.die.net/man/1/ipmitool) to communicate with any
out-of-band management interface that support IPMI 2.0.

This feature allows following common use-cases:
- Restarting stalled/failed hosts
- Powering off under-utilised hosts
- Powering on hosts for provisioning or to increase capacity
- Allowing system administrators to see the current power state of the host

For testing this feature `ipmisim` can be used:
https://pypi.python.org/pypi/ipmisim

FS:
https://cwiki.apache.org/confluence/display/CLOUDSTACK/Out-of-band+Management+for+CloudStack

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>


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

Branch: refs/heads/master
Commit: 07564469e9a2ddd0334e8bdd30deed3ed53c3f09
Parents: bee2bdc
Author: Rohit Yadav <rohit.yadav@shapeblue.com>
Authored: Mon Dec 28 16:37:03 2015 +0530
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Thu May 12 11:05:40 2016 +0530

----------------------------------------------------------------------
 .travis.yml                                     |   2 +-
 api/src/com/cloud/event/EventTypes.java         |  16 +
 api/src/com/cloud/resource/ResourceService.java |   3 +
 .../apache/cloudstack/alert/AlertService.java   |   1 +
 .../org/apache/cloudstack/api/ApiConstants.java |   6 +-
 .../org/apache/cloudstack/api/BaseResponse.java |  31 +-
 .../api/command/admin/host/ListHostsCmd.java    |  21 +-
 .../ChangeOutOfBandManagementPasswordCmd.java   | 112 ++++
 .../ConfigureOutOfBandManagementCmd.java        | 125 ++++
 ...DisableOutOfBandManagementForClusterCmd.java | 103 ++++
 .../DisableOutOfBandManagementForHostCmd.java   | 104 ++++
 .../DisableOutOfBandManagementForZoneCmd.java   | 103 ++++
 .../EnableOutOfBandManagementForClusterCmd.java | 103 ++++
 .../EnableOutOfBandManagementForHostCmd.java    | 104 ++++
 .../EnableOutOfBandManagementForZoneCmd.java    | 103 ++++
 .../IssueOutOfBandManagementPowerActionCmd.java | 124 ++++
 .../api/response/ClusterResponse.java           |  13 +
 .../cloudstack/api/response/HostResponse.java   |  13 +
 .../response/OutOfBandManagementResponse.java   | 189 ++++++
 .../cloudstack/api/response/ZoneResponse.java   |   6 +-
 .../OutOfBandManagement.java                    | 150 +++++
 .../OutOfBandManagementDriver.java              |  25 +
 .../OutOfBandManagementService.java             |  55 ++
 ...ndManagementDriverChangePasswordCommand.java |  34 ++
 .../OutOfBandManagementDriverCommand.java       |  43 ++
 .../OutOfBandManagementDriverPowerCommand.java  |  33 ++
 .../OutOfBandManagementDriverResponse.java      |  85 +++
 .../classes/resources/messages.properties       |  20 +
 client/pom.xml                                  |   5 +
 ...g-core-lifecycle-api-context-inheritable.xml |   1 -
 .../core/spring-core-registry-core-context.xml  |   7 +-
 .../outofbandmanagement/module.properties       |  21 +
 ...-outofbandmanagement-context-inheritable.xml |  36 ++
 debian/control                                  |   2 +-
 developer/developer-prefill.sql                 |  12 +
 .../cloud/agent/manager/AgentManagerImpl.java   |   3 +
 .../manager/ClusteredAgentManagerImpl.java      |   1 +
 .../spring-engine-schema-core-daos-context.xml  |   2 +-
 .../com/cloud/dc/dao/DataCenterDetailsDao.java  |   4 +-
 .../cloud/dc/dao/DataCenterDetailsDaoImpl.java  |  26 +-
 .../schema/src/com/cloud/host/dao/HostDao.java  |   4 +
 .../src/com/cloud/host/dao/HostDaoImpl.java     |  17 +
 .../OutOfBandManagementVO.java                  | 193 +++++++
 .../dao/OutOfBandManagementDao.java             |  31 +
 .../dao/OutOfBandManagementDaoImpl.java         | 158 +++++
 .../ipmitool/pom.xml                            |  41 ++
 .../cloudstack/ipmitool/module.properties       |  18 +
 .../ipmitool/spring-ipmitool-context.xml        |  34 ++
 .../IpmitoolOutOfBandManagementDriver.java      | 167 ++++++
 .../driver/ipmitool/IpmitoolWrapper.java        | 181 ++++++
 .../driver/ipmitool/IpmitoolWrapperTest.java    | 115 ++++
 plugins/pom.xml                                 |   1 +
 .../spring-server-core-managers-context.xml     |   4 +
 .../src/com/cloud/alert/AlertManagerImpl.java   |   3 +-
 server/src/com/cloud/api/ApiResponseHelper.java |   4 +
 .../com/cloud/api/query/QueryManagerImpl.java   |  12 +
 .../cloud/api/query/dao/HostJoinDaoImpl.java    |  16 +-
 .../src/com/cloud/api/query/vo/HostJoinVO.java  |  16 +
 .../com/cloud/resource/ResourceManagerImpl.java |   6 +
 .../com/cloud/server/ManagementServerImpl.java  |  20 +
 server/src/com/cloud/server/StatsCollector.java |  48 +-
 .../OutOfBandManagementBackgroundTask.java      |  50 ++
 .../OutOfBandManagementServiceImpl.java         | 555 ++++++++++++++++++
 .../cloud/resource/MockResourceManagerImpl.java |   7 +
 .../OutOfBandManagementServiceTest.java         | 116 ++++
 setup/db/db/schema-481to490-cleanup.sql         |  77 +++
 setup/db/db/schema-481to490.sql                 |  23 +
 setup/dev/advanced.cfg                          |  16 +-
 .../smoke/test_outofbandmanagement.py           | 575 +++++++++++++++++++
 tools/apidoc/gen_toc.py                         |   1 +
 tools/marvin/setup.py                           |   3 +-
 tools/travis/before_install.sh                  |  13 +-
 ui/css/cloudstack3.css                          |  48 ++
 ui/dictionary.jsp                               |  21 +
 ui/scripts/metrics.js                           |  16 +
 ui/scripts/system.js                            | 573 +++++++++++++++++-
 .../java/com/cloud/utils/fsm/StateMachine2.java |  10 +
 .../cloudstack/utils/process/ProcessResult.java |  46 ++
 .../cloudstack/utils/process/ProcessRunner.java | 115 ++++
 .../cloudstack/utils/process/ProcessTest.java   |  69 +++
 80 files changed, 5227 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 9d9822c..9ff6f18 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -38,7 +38,7 @@ env:
   matrix:
     - TESTS="smoke/test_affinity_groups smoke/test_affinity_groups_projects smoke/test_dynamicroles smoke/test_deploy_vgpu_enabled_vm smoke/test_deploy_vm_iso smoke/test_deploy_vm_root_resize smoke/test_deploy_vm_with_userdata smoke/test_deploy_vms_with_varied_deploymentplanners smoke/test_disk_offerings smoke/test_global_settings smoke/test_guest_vlan_range"
     - TESTS="smoke/test_hosts smoke/test_internal_lb smoke/test_iso smoke/test_list_ids_parameter smoke/test_loadbalance smoke/test_multipleips_per_nic smoke/test_network smoke/test_network_acl smoke/test_nic smoke/test_nic_adapter_type smoke/test_non_contigiousvlan"
-    - TESTS="smoke/test_over_provisioning smoke/test_password_server smoke/test_portable_publicip smoke/test_primary_storage smoke/test_privategw_acl smoke/test_public_ip_range smoke/test_pvlan smoke/test_regions smoke/test_reset_vm_on_reboot smoke/test_resource_detail"
+    - TESTS="smoke/test_outofbandmanagement smoke/test_over_provisioning smoke/test_password_server smoke/test_portable_publicip smoke/test_primary_storage smoke/test_privategw_acl smoke/test_public_ip_range smoke/test_pvlan smoke/test_regions smoke/test_reset_vm_on_reboot smoke/test_resource_detail"
     - TESTS="smoke/test_router_dhcphosts smoke/test_routers smoke/test_routers_iptables_default_policy smoke/test_routers_network_ops smoke/test_staticroles smoke/test_scale_vm smoke/test_secondary_storage smoke/test_service_offerings smoke/test_snapshots smoke/test_ssvm smoke/test_templates"
     - TESTS="smoke/test_usage_events smoke/test_vm_life_cycle smoke/test_vm_snapshots smoke/test_volumes smoke/test_vpc_redundant smoke/test_vpc_router_nics smoke/test_vpc_vpn smoke/misc/test_deploy_vm smoke/misc/test_vm_ha smoke/misc/test_escalations_templates smoke/misc/test_vm_sync"
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/api/src/com/cloud/event/EventTypes.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/event/EventTypes.java b/api/src/com/cloud/event/EventTypes.java
index 23de152..3cc4eac 100644
--- a/api/src/com/cloud/event/EventTypes.java
+++ b/api/src/com/cloud/event/EventTypes.java
@@ -309,6 +309,14 @@ public class EventTypes {
     // Host
     public static final String EVENT_HOST_RECONNECT = "HOST.RECONNECT";
 
+    // Host Out-of-band management
+    public static final String EVENT_HOST_OUTOFBAND_MANAGEMENT_ENABLE = "HOST.OOBM.ENABLE";
+    public static final String EVENT_HOST_OUTOFBAND_MANAGEMENT_DISABLE = "HOST.OOBM.DISABLE";
+    public static final String EVENT_HOST_OUTOFBAND_MANAGEMENT_CONFIGURE = "HOST.OOBM.CONFIGURE";
+    public static final String EVENT_HOST_OUTOFBAND_MANAGEMENT_ACTION = "HOST.OOBM.ACTION";
+    public static final String EVENT_HOST_OUTOFBAND_MANAGEMENT_CHANGE_PASSWORD = "HOST.OOBM.CHANGEPASSWORD";
+    public static final String EVENT_HOST_OUTOFBAND_MANAGEMENT_POWERSTATE_TRANSITION = "HOST.OOBM.POWERSTATE.TRANSITION";
+
     // Maintenance
     public static final String EVENT_MAINTENANCE_CANCEL = "MAINT.CANCEL";
     public static final String EVENT_MAINTENANCE_CANCEL_PRIMARY_STORAGE = "MAINT.CANCEL.PS";
@@ -745,6 +753,14 @@ public class EventTypes {
         // Host
         entityEventDetails.put(EVENT_HOST_RECONNECT, Host.class);
 
+        // Host Out-of-band management
+        entityEventDetails.put(EVENT_HOST_OUTOFBAND_MANAGEMENT_ENABLE, Host.class);
+        entityEventDetails.put(EVENT_HOST_OUTOFBAND_MANAGEMENT_DISABLE, Host.class);
+        entityEventDetails.put(EVENT_HOST_OUTOFBAND_MANAGEMENT_CONFIGURE, Host.class);
+        entityEventDetails.put(EVENT_HOST_OUTOFBAND_MANAGEMENT_ACTION, Host.class);
+        entityEventDetails.put(EVENT_HOST_OUTOFBAND_MANAGEMENT_CHANGE_PASSWORD, Host.class);
+        entityEventDetails.put(EVENT_HOST_OUTOFBAND_MANAGEMENT_POWERSTATE_TRANSITION, Host.class);
+
         // Maintenance
         entityEventDetails.put(EVENT_MAINTENANCE_CANCEL, Host.class);
         entityEventDetails.put(EVENT_MAINTENANCE_CANCEL_PRIMARY_STORAGE, Host.class);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/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 7461455..7050b97 100644
--- a/api/src/com/cloud/resource/ResourceService.java
+++ b/api/src/com/cloud/resource/ResourceService.java
@@ -18,6 +18,7 @@ package com.cloud.resource;
 
 import java.util.List;
 
+import com.cloud.dc.DataCenter;
 import org.apache.cloudstack.api.command.admin.cluster.AddClusterCmd;
 import org.apache.cloudstack.api.command.admin.cluster.DeleteClusterCmd;
 import org.apache.cloudstack.api.command.admin.host.AddHostCmd;
@@ -92,6 +93,8 @@ public interface ResourceService {
 
     Cluster getCluster(Long clusterId);
 
+    DataCenter getZone(Long zoneId);
+
     List<HypervisorType> getSupportedHypervisorTypes(long zoneId, boolean forVirtualRouter, Long podId);
 
     boolean releaseHostReservation(Long hostId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/api/src/org/apache/cloudstack/alert/AlertService.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/alert/AlertService.java b/api/src/org/apache/cloudstack/alert/AlertService.java
index 2b827eb..ad711ec 100644
--- a/api/src/org/apache/cloudstack/alert/AlertService.java
+++ b/api/src/org/apache/cloudstack/alert/AlertService.java
@@ -66,6 +66,7 @@ public interface AlertService {
         public static final AlertType ALERT_TYPE_RESOURCE_LIMIT_EXCEEDED = new AlertType((short)26, "ALERT.RESOURCE.EXCEED", true);
         public static final AlertType ALERT_TYPE_SYNC = new AlertType((short)27, "ALERT.TYPE.SYNC", true);
         public static final AlertType ALERT_TYPE_UPLOAD_FAILED = new AlertType((short)28, "ALERT.UPLOAD.FAILED", true);
+        public static final AlertType ALERT_TYPE_OOBM_AUTH_ERROR = new AlertType((short)29, "ALERT.OOBM.AUTHERROR", true);
 
         public short getType() {
             return type;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/api/src/org/apache/cloudstack/api/ApiConstants.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java
index 4904925..1d0b4a3 100644
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -21,6 +21,7 @@ public class ApiConstants {
     public static final String ACCOUNTS = "accounts";
     public static final String ACCOUNT_TYPE = "accounttype";
     public static final String ACCOUNT_ID = "accountid";
+    public static final String ADDRESS = "address";
     public static final String ALGORITHM = "algorithm";
     public static final String ALLOCATED_ONLY = "allocatedonly";
     public static final String API_KEY = "apikey";
@@ -76,6 +77,7 @@ public class ApiConstants {
     public static final String DEVICE_ID = "deviceid";
     public static final String DISK_OFFERING_ID = "diskofferingid";
     public static final String DISK_SIZE = "disksize";
+    public static final String DRIVER = "driver";
     public static final String ROOT_DISK_SIZE = "rootdisksize";
     public static final String DISPLAY_NAME = "displayname";
     public static final String DISPLAY_NETWORK = "displaynetwork";
@@ -177,6 +179,8 @@ public class ApiConstants {
     public static final String OS_TYPE_ID = "ostypeid";
     public static final String OS_DISPLAY_NAME = "osdisplayname";
     public static final String OS_NAME_FOR_HYPERVISOR = "osnameforhypervisor";
+    public static final String OUTOFBANDMANAGEMENT_POWERSTATE = "outofbandmanagementpowerstate";
+    public static final String OUTOFBANDMANAGEMENT_ENABLED = "outofbandmanagementenabled";
     public static final String PARAMS = "params";
     public static final String PARENT_DOMAIN_ID = "parentdomainid";
     public static final String PASSWORD = "password";
@@ -193,7 +197,7 @@ public class ApiConstants {
     public static final String PORTABLE_IP_ADDRESS = "portableipaddress";
     public static final String PORT_FORWARDING_SERVICE_ID = "portforwardingserviceid";
     public static final String POST_URL = "postURL";
-    public static final String PARENT = "parent";
+    public static final String POWER_STATE = "powerstate";
     public static final String PRIVATE_INTERFACE = "privateinterface";
     public static final String PRIVATE_IP = "privateip";
     public static final String PRIVATE_PORT = "privateport";

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/api/src/org/apache/cloudstack/api/BaseResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseResponse.java b/api/src/org/apache/cloudstack/api/BaseResponse.java
index 05de218..45016c1 100644
--- a/api/src/org/apache/cloudstack/api/BaseResponse.java
+++ b/api/src/org/apache/cloudstack/api/BaseResponse.java
@@ -24,23 +24,38 @@ public abstract class BaseResponse implements ResponseObject {
     private transient String responseName;
     private transient String objectName;
 
+    @SerializedName(ApiConstants.JOB_ID)
+    @Param(description = "the UUID of the latest async job acting on this object")
+    protected String jobId;
+
+    @SerializedName(ApiConstants.JOB_STATUS)
+    @Param(description = "the current status of the latest async job acting on this object")
+    private Integer jobStatus;
+
+    public BaseResponse() {
+    }
+
+    public BaseResponse(final String objectName) {
+        this.objectName = objectName;
+    }
+
     @Override
-    public String getResponseName() {
+    public final String getResponseName() {
         return responseName;
     }
 
     @Override
-    public void setResponseName(String responseName) {
+    public final void setResponseName(String responseName) {
         this.responseName = responseName;
     }
 
     @Override
-    public String getObjectName() {
+    public final String getObjectName() {
         return objectName;
     }
 
     @Override
-    public void setObjectName(String objectName) {
+    public final void setObjectName(String objectName) {
         this.objectName = objectName;
     }
 
@@ -49,14 +64,6 @@ public abstract class BaseResponse implements ResponseObject {
         return null;
     }
 
-    @SerializedName(ApiConstants.JOB_ID)
-    @Param(description = "the UUID of the latest async job acting on this object")
-    protected String jobId;
-
-    @SerializedName(ApiConstants.JOB_STATUS)
-    @Param(description = "the current status of the latest async job acting on this object")
-    private Integer jobStatus;
-
     @Override
     public String getJobId() {
         return jobId;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/api/src/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java b/api/src/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java
index d7aa18b..424fc05 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java
@@ -81,9 +81,19 @@ public class ListHostsCmd extends BaseListCmd {
                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.OUTOFBANDMANAGEMENT_ENABLED,
+            type = CommandType.BOOLEAN,
+            description = "list hosts for which out-of-band management is enabled")
+    private Boolean outOfBandManagementEnabled;
+
+    @Parameter(name = ApiConstants.OUTOFBANDMANAGEMENT_POWERSTATE,
+            type = CommandType.STRING,
+            description = "list hosts by its out-of-band management interface's power state. Its value can be one of [On, Off, Unknown]")
+    private String outOfBandManagementPowerState;
+
     @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]")
+               description = "list hosts by resource state. Resource state represents current state determined by admin of host, value can be one of [Enabled, Disabled, Unmanaged, PrepareForMaintenance, ErrorInMaintenance, Maintenance, Error]")
     private String resourceState;
 
     @Parameter(name = ApiConstants.DETAILS,
@@ -165,6 +175,15 @@ public class ListHostsCmd extends BaseListCmd {
         return resourceState;
     }
 
+
+    public Boolean isOutOfBandManagementEnabled() {
+        return outOfBandManagementEnabled;
+    }
+
+    public String getHostOutOfBandManagementPowerState() {
+        return outOfBandManagementPowerState;
+    }
+
     /////////////////////////////////////////////////////
     /////////////// API Implementation///////////////////
     /////////////////////////////////////////////////////

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/ChangeOutOfBandManagementPasswordCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/ChangeOutOfBandManagementPasswordCmd.java b/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/ChangeOutOfBandManagementPasswordCmd.java
new file mode 100644
index 0000000..ea2e3cd
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/ChangeOutOfBandManagementPasswordCmd.java
@@ -0,0 +1,112 @@
+// 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.outofbandmanagement;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.host.Host;
+import com.google.common.base.Strings;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiArgValidator;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.HostResponse;
+import org.apache.cloudstack.api.response.OutOfBandManagementResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.outofbandmanagement.OutOfBandManagementService;
+
+import javax.inject.Inject;
+
+@APICommand(name = ChangeOutOfBandManagementPasswordCmd.APINAME, description = "Changes out-of-band management interface password on the host and updates the interface configuration in CloudStack if the operation succeeds, else reverts the old password",
+        responseObject = OutOfBandManagementResponse.class, requestHasSensitiveInfo = true, responseHasSensitiveInfo = false,
+        since = "4.9.0", authorized = {RoleType.Admin})
+public class ChangeOutOfBandManagementPasswordCmd extends BaseAsyncCmd {
+    public static final String APINAME = "changeOutOfBandManagementPassword";
+
+    @Inject
+    private OutOfBandManagementService outOfBandManagementService;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.HOST_ID, type = CommandType.UUID, entityType = HostResponse.class, required = true,
+            validations = {ApiArgValidator.PositiveNumber}, description = "the ID of the host")
+    private Long hostId;
+
+    @Parameter(name = ApiConstants.PASSWORD, type = CommandType.STRING, description = "the new host management interface password of maximum length 16, if none is provided a random password would be used")
+    private String password;
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
+        final Host host = _resourceService.getHost(getHostId());
+        if (host == null) {
+            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find host by ID: " + getHostId());
+        }
+
+        CallContext.current().setEventDetails("Host Id: " + host.getId() + " Password: " + getPassword().charAt(0) + "****");
+        CallContext.current().putContextParameter(Host.class, host.getUuid());
+
+        final OutOfBandManagementResponse response = outOfBandManagementService.changeOutOfBandManagementPassword(host, getPassword());
+        response.setResponseName(getCommandName());
+        setResponseObject(response);
+    }
+
+    @Override
+    public String getCommandName() {
+        return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return CallContext.current().getCallingAccountId();
+    }
+
+    public Long getHostId() {
+        return hostId;
+    }
+
+    public String getPassword() {
+        if (Strings.isNullOrEmpty(password)) {
+            password = _mgr.generateRandomPassword();
+        }
+        return password;
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_CHANGE_PASSWORD;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "change out-of-band management password for host: " + getHostId();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/ConfigureOutOfBandManagementCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/ConfigureOutOfBandManagementCmd.java b/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/ConfigureOutOfBandManagementCmd.java
new file mode 100644
index 0000000..db22410
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/ConfigureOutOfBandManagementCmd.java
@@ -0,0 +1,125 @@
+// 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.outofbandmanagement;
+
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.host.Host;
+import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableMap;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiArgValidator;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.HostResponse;
+import org.apache.cloudstack.api.response.OutOfBandManagementResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.outofbandmanagement.OutOfBandManagement;
+import org.apache.cloudstack.outofbandmanagement.OutOfBandManagementService;
+
+import javax.inject.Inject;
+
+@APICommand(name = ConfigureOutOfBandManagementCmd.APINAME, description = "Configures a host's out-of-band management interface",
+        responseObject = OutOfBandManagementResponse.class, requestHasSensitiveInfo = true, responseHasSensitiveInfo = false,
+        since = "4.9.0", authorized = {RoleType.Admin})
+public class ConfigureOutOfBandManagementCmd extends BaseCmd {
+    public static final String APINAME = "configureOutOfBandManagement";
+
+    @Inject
+    private OutOfBandManagementService outOfBandManagementService;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.HOST_ID, type = CommandType.UUID, entityType = HostResponse.class, required = true,
+            validations = {ApiArgValidator.PositiveNumber}, description = "the ID of the host")
+    private Long hostId;
+
+    @Parameter(name = ApiConstants.DRIVER, type = CommandType.STRING, required = true, description = "the host management interface driver, for example: ipmitool")
+    private String driver;
+
+    @Parameter(name = ApiConstants.ADDRESS, type = CommandType.STRING, required = true, description = "the host management interface IP address")
+    private String address;
+
+    @Parameter(name = ApiConstants.PORT, type = CommandType.STRING, required = true, description = "the host management interface port")
+    private String port;
+
+    @Parameter(name = ApiConstants.USERNAME, type = CommandType.STRING, required = true, description = "the host management interface user")
+    private String username;
+
+    @Parameter(name = ApiConstants.PASSWORD, type = CommandType.STRING, required = true, description = "the host management interface password")
+    private String password;
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
+        final Host host = _resourceService.getHost(getHostId());
+        if (host == null) {
+            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find host by ID: " + getHostId());
+        }
+        CallContext.current().putContextParameter(Host.class, host.getUuid());
+        final OutOfBandManagementResponse response = outOfBandManagementService.configureOutOfBandManagement(host, getHostPMOptions());
+        response.setId(host.getUuid());
+        response.setResponseName(getCommandName());
+        setResponseObject(response);
+    }
+
+    @Override
+    public String getCommandName() {
+        return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return CallContext.current().getCallingAccountId();
+    }
+
+    public Long getHostId() {
+        return hostId;
+    }
+
+    public final ImmutableMap<OutOfBandManagement.Option, String> getHostPMOptions() {
+        final ImmutableMap.Builder<OutOfBandManagement.Option, String> builder = ImmutableMap.builder();
+        if (!Strings.isNullOrEmpty(driver)) {
+            builder.put(OutOfBandManagement.Option.DRIVER, driver);
+        }
+        if (!Strings.isNullOrEmpty(address)) {
+            builder.put(OutOfBandManagement.Option.ADDRESS, address);
+        }
+        if (!Strings.isNullOrEmpty(port)) {
+            builder.put(OutOfBandManagement.Option.PORT, port);
+        }
+        if (!Strings.isNullOrEmpty(username)) {
+            builder.put(OutOfBandManagement.Option.USERNAME, username);
+        }
+        if (!Strings.isNullOrEmpty(password)) {
+            builder.put(OutOfBandManagement.Option.PASSWORD, password);
+        }
+        return builder.build();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/DisableOutOfBandManagementForClusterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/DisableOutOfBandManagementForClusterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/DisableOutOfBandManagementForClusterCmd.java
new file mode 100644
index 0000000..67d84d5
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/DisableOutOfBandManagementForClusterCmd.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.outofbandmanagement;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.org.Cluster;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiArgValidator;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.ClusterResponse;
+import org.apache.cloudstack.api.response.OutOfBandManagementResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.outofbandmanagement.OutOfBandManagementService;
+
+import javax.inject.Inject;
+
+@APICommand(name = DisableOutOfBandManagementForClusterCmd.APINAME, description = "Disables out-of-band management for a cluster",
+        responseObject = OutOfBandManagementResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
+        since = "4.9.0", authorized = {RoleType.Admin})
+public class DisableOutOfBandManagementForClusterCmd extends BaseAsyncCmd {
+    public static final String APINAME = "disableOutOfBandManagementForCluster";
+
+    @Inject
+    private OutOfBandManagementService outOfBandManagementService;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.CLUSTER_ID, type = BaseCmd.CommandType.UUID, required = true, entityType = ClusterResponse.class,
+            validations = {ApiArgValidator.PositiveNumber}, description = "the ID of the cluster")
+    private Long clusterId;
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    final public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
+        final Cluster cluster = _resourceService.getCluster(getClusterId());
+        if (cluster == null) {
+            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find cluster by ID: " + getClusterId());
+        }
+
+        OutOfBandManagementResponse response = outOfBandManagementService.disableOutOfBandManagement(cluster);
+
+        CallContext.current().setEventDetails("Cluster Id:" + cluster.getId() + " out-of-band management enabled: false");
+        CallContext.current().putContextParameter(Cluster.class, cluster.getUuid());
+
+        response.setResponseName(getCommandName());
+        setResponseObject(response);
+    }
+
+    @Override
+    public String getCommandName() {
+        return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX;
+    }
+
+    final public Long getClusterId() {
+        return clusterId;
+    }
+
+    @Override
+    final public long getEntityOwnerId() {
+        return CallContext.current().getCallingAccountId();
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_DISABLE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "disable out-of-band management password for cluster: " + getClusterId();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/DisableOutOfBandManagementForHostCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/DisableOutOfBandManagementForHostCmd.java b/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/DisableOutOfBandManagementForHostCmd.java
new file mode 100644
index 0000000..009d0d3
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/DisableOutOfBandManagementForHostCmd.java
@@ -0,0 +1,104 @@
+// 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.outofbandmanagement;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.host.Host;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiArgValidator;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.HostResponse;
+import org.apache.cloudstack.api.response.OutOfBandManagementResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.outofbandmanagement.OutOfBandManagementService;
+
+import javax.inject.Inject;
+
+@APICommand(name = DisableOutOfBandManagementForHostCmd.APINAME, description = "Disables out-of-band management for a host",
+        responseObject = OutOfBandManagementResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
+        since = "4.9.0", authorized = {RoleType.Admin})
+public class DisableOutOfBandManagementForHostCmd extends BaseAsyncCmd {
+    public static final String APINAME = "disableOutOfBandManagementForHost";
+
+    @Inject
+    private OutOfBandManagementService outOfBandManagementService;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.HOST_ID, type = BaseCmd.CommandType.UUID, required = true, entityType = HostResponse.class,
+            validations = {ApiArgValidator.PositiveNumber}, description = "the ID of the host")
+    private Long hostId;
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    final public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
+        final Host host = _resourceService.getHost(getHostId());
+        if (host == null) {
+            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find host by ID: " + getHostId());
+        }
+
+        OutOfBandManagementResponse response = outOfBandManagementService.disableOutOfBandManagement(host);
+
+        CallContext.current().setEventDetails("Host Id:" + host.getId() + " out-of-band management enabled: false");
+        CallContext.current().putContextParameter(Host.class, host.getUuid());
+
+        response.setId(host.getUuid());
+        response.setResponseName(getCommandName());
+        setResponseObject(response);
+    }
+
+    @Override
+    public String getCommandName() {
+        return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX;
+    }
+
+    final public Long getHostId() {
+        return hostId;
+    }
+
+    @Override
+    final public long getEntityOwnerId() {
+        return CallContext.current().getCallingAccountId();
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_DISABLE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "disable out-of-band management password for host: " + getHostId();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/DisableOutOfBandManagementForZoneCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/DisableOutOfBandManagementForZoneCmd.java b/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/DisableOutOfBandManagementForZoneCmd.java
new file mode 100644
index 0000000..82e92a7
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/DisableOutOfBandManagementForZoneCmd.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.outofbandmanagement;
+
+import com.cloud.dc.DataCenter;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiArgValidator;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.OutOfBandManagementResponse;
+import org.apache.cloudstack.api.response.ZoneResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.outofbandmanagement.OutOfBandManagementService;
+
+import javax.inject.Inject;
+
+@APICommand(name = DisableOutOfBandManagementForZoneCmd.APINAME, description = "Disables out-of-band management for a zone",
+        responseObject = OutOfBandManagementResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
+        since = "4.9.0", authorized = {RoleType.Admin})
+public class DisableOutOfBandManagementForZoneCmd extends BaseAsyncCmd {
+    public static final String APINAME = "disableOutOfBandManagementForZone";
+
+    @Inject
+    private OutOfBandManagementService outOfBandManagementService;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.ZONE_ID, type = BaseCmd.CommandType.UUID, required = true, entityType = ZoneResponse.class,
+            validations = {ApiArgValidator.PositiveNumber}, description = "the ID of the zone")
+    private Long zoneId;
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    final public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
+        final DataCenter zone = _resourceService.getZone(getZoneId());
+        if (zone == null) {
+            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find zone by ID: " + getZoneId());
+        }
+
+        OutOfBandManagementResponse response = outOfBandManagementService.disableOutOfBandManagement(zone);
+
+        CallContext.current().setEventDetails("Zone Id:" + zone.getId() + " out-of-band management enabled: false");
+        CallContext.current().putContextParameter(DataCenter.class, zone.getUuid());
+
+        response.setResponseName(getCommandName());
+        setResponseObject(response);
+    }
+
+    @Override
+    public String getCommandName() {
+        return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX;
+    }
+
+    final public Long getZoneId() {
+        return zoneId;
+    }
+
+    @Override
+    final public long getEntityOwnerId() {
+        return CallContext.current().getCallingAccountId();
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_DISABLE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "disable out-of-band management password for zone: " + getZoneId();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/EnableOutOfBandManagementForClusterCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/EnableOutOfBandManagementForClusterCmd.java b/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/EnableOutOfBandManagementForClusterCmd.java
new file mode 100644
index 0000000..64279c3
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/EnableOutOfBandManagementForClusterCmd.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.outofbandmanagement;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.org.Cluster;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiArgValidator;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.ClusterResponse;
+import org.apache.cloudstack.api.response.OutOfBandManagementResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.outofbandmanagement.OutOfBandManagementService;
+
+import javax.inject.Inject;
+
+@APICommand(name = EnableOutOfBandManagementForClusterCmd.APINAME, description = "Enables out-of-band management for a cluster",
+        responseObject = OutOfBandManagementResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
+        since = "4.9.0", authorized = {RoleType.Admin})
+public class EnableOutOfBandManagementForClusterCmd extends BaseAsyncCmd {
+    public static final String APINAME = "enableOutOfBandManagementForCluster";
+
+    @Inject
+    private OutOfBandManagementService outOfBandManagementService;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.CLUSTER_ID, type = BaseCmd.CommandType.UUID, required = true, entityType = ClusterResponse.class,
+            validations = {ApiArgValidator.PositiveNumber}, description = "the ID of the cluster")
+    private Long clusterId;
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    final public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
+        final Cluster cluster = _resourceService.getCluster(getClusterId());
+        if (cluster == null) {
+            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find cluster by ID: " + getClusterId());
+        }
+
+        OutOfBandManagementResponse response = outOfBandManagementService.enableOutOfBandManagement(cluster);
+
+        CallContext.current().setEventDetails("Cluster Id:" + cluster.getId() + " out-of-band management enabled: true");
+        CallContext.current().putContextParameter(Cluster.class, cluster.getUuid());
+
+        response.setResponseName(getCommandName());
+        setResponseObject(response);
+    }
+
+    @Override
+    public String getCommandName() {
+        return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX;
+    }
+
+    final public Long getClusterId() {
+        return clusterId;
+    }
+
+    @Override
+    final public long getEntityOwnerId() {
+        return CallContext.current().getCallingAccountId();
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_ENABLE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "enable out-of-band management password for cluster: " + getClusterId();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/EnableOutOfBandManagementForHostCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/EnableOutOfBandManagementForHostCmd.java b/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/EnableOutOfBandManagementForHostCmd.java
new file mode 100644
index 0000000..7467256
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/EnableOutOfBandManagementForHostCmd.java
@@ -0,0 +1,104 @@
+// 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.outofbandmanagement;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.host.Host;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiArgValidator;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.HostResponse;
+import org.apache.cloudstack.api.response.OutOfBandManagementResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.outofbandmanagement.OutOfBandManagementService;
+
+import javax.inject.Inject;
+
+@APICommand(name = EnableOutOfBandManagementForHostCmd.APINAME, description = "Enables out-of-band management for a host",
+        responseObject = OutOfBandManagementResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
+        since = "4.9.0", authorized = {RoleType.Admin})
+public class EnableOutOfBandManagementForHostCmd extends BaseAsyncCmd {
+    public static final String APINAME = "enableOutOfBandManagementForHost";
+
+    @Inject
+    private OutOfBandManagementService outOfBandManagementService;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.HOST_ID, type = BaseCmd.CommandType.UUID, required = true, entityType = HostResponse.class,
+            validations = {ApiArgValidator.PositiveNumber}, description = "the ID of the host")
+    private Long hostId;
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    final public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
+        final Host host = _resourceService.getHost(getHostId());
+        if (host == null) {
+            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find host by ID: " + getHostId());
+        }
+
+        OutOfBandManagementResponse response = outOfBandManagementService.enableOutOfBandManagement(host);
+
+        CallContext.current().setEventDetails("Host Id:" + host.getId() + " out-of-band management enabled: true");
+        CallContext.current().putContextParameter(Host.class, host.getUuid());
+
+        response.setId(host.getUuid());
+        response.setResponseName(getCommandName());
+        setResponseObject(response);
+    }
+
+    @Override
+    public String getCommandName() {
+        return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX;
+    }
+
+    final public Long getHostId() {
+        return hostId;
+    }
+
+    @Override
+    final public long getEntityOwnerId() {
+        return CallContext.current().getCallingAccountId();
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_ENABLE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "enable out-of-band management password for host: " + getHostId();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/EnableOutOfBandManagementForZoneCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/EnableOutOfBandManagementForZoneCmd.java b/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/EnableOutOfBandManagementForZoneCmd.java
new file mode 100644
index 0000000..cae2181
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/EnableOutOfBandManagementForZoneCmd.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.outofbandmanagement;
+
+import com.cloud.dc.DataCenter;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiArgValidator;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.OutOfBandManagementResponse;
+import org.apache.cloudstack.api.response.ZoneResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.outofbandmanagement.OutOfBandManagementService;
+
+import javax.inject.Inject;
+
+@APICommand(name = EnableOutOfBandManagementForZoneCmd.APINAME, description = "Enables out-of-band management for a zone",
+        responseObject = OutOfBandManagementResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
+        since = "4.9.0", authorized = {RoleType.Admin})
+public class EnableOutOfBandManagementForZoneCmd extends BaseAsyncCmd {
+    public static final String APINAME = "enableOutOfBandManagementForZone";
+
+    @Inject
+    private OutOfBandManagementService outOfBandManagementService;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.ZONE_ID, type = BaseCmd.CommandType.UUID, required = true, entityType = ZoneResponse.class,
+            validations = {ApiArgValidator.PositiveNumber}, description = "the ID of the zone")
+    private Long zoneId;
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    final public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
+        final DataCenter zone = _resourceService.getZone(getZoneId());
+        if (zone == null) {
+            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find zone by ID: " + getZoneId());
+        }
+
+        OutOfBandManagementResponse response = outOfBandManagementService.enableOutOfBandManagement(zone);
+
+        CallContext.current().setEventDetails("Zone Id:" + zone.getId() + " out-of-band management enabled: true");
+        CallContext.current().putContextParameter(DataCenter.class, zone.getUuid());
+
+        response.setResponseName(getCommandName());
+        setResponseObject(response);
+    }
+
+    @Override
+    public String getCommandName() {
+        return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX;
+    }
+
+    final public Long getZoneId() {
+        return zoneId;
+    }
+
+    @Override
+    final public long getEntityOwnerId() {
+        return CallContext.current().getCallingAccountId();
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_ENABLE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "enable out-of-band management password for zone: " + getZoneId();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/IssueOutOfBandManagementPowerActionCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/IssueOutOfBandManagementPowerActionCmd.java b/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/IssueOutOfBandManagementPowerActionCmd.java
new file mode 100644
index 0000000..8d6bdd3
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/outofbandmanagement/IssueOutOfBandManagementPowerActionCmd.java
@@ -0,0 +1,124 @@
+// 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.outofbandmanagement;
+
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.host.Host;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiArgValidator;
+import org.apache.cloudstack.api.ApiCommandJobType;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseAsyncCmd;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.HostResponse;
+import org.apache.cloudstack.api.response.OutOfBandManagementResponse;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.outofbandmanagement.OutOfBandManagement.PowerOperation;
+import org.apache.cloudstack.outofbandmanagement.OutOfBandManagementService;
+
+import javax.inject.Inject;
+
+@APICommand(name = IssueOutOfBandManagementPowerActionCmd.APINAME, description = "Initiates the specified power action to the host's out-of-band management interface",
+        responseObject = OutOfBandManagementResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
+        since = "4.9.0", authorized = {RoleType.Admin})
+public class IssueOutOfBandManagementPowerActionCmd extends BaseAsyncCmd {
+    public static final String APINAME = "issueOutOfBandManagementPowerAction";
+
+    @Inject
+    private OutOfBandManagementService outOfBandManagementService;
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.HOST_ID, type = CommandType.UUID, entityType = HostResponse.class, required = true,
+            validations = {ApiArgValidator.PositiveNumber}, description = "the ID of the host")
+    private Long hostId;
+
+    @Parameter(name = ApiConstants.TIMEOUT, type = CommandType.LONG, description = "optional operation timeout in seconds that overrides the global or cluster-level out-of-band management timeout setting")
+    private Long actionTimeout;
+
+    @Parameter(name = ApiConstants.ACTION, type = CommandType.STRING, required = true,
+            validations = {ApiArgValidator.NotNullOrEmpty}, description = "out-of-band management power actions, valid actions are: ON, OFF, CYCLE, RESET, SOFT, STATUS")
+    private String powerAction;
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+
+    @Override
+    public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
+        final Host host = _resourceService.getHost(getHostId());
+        if (host == null) {
+            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find host by ID: " + getHostId());
+        }
+        final PowerOperation powerOperation = PowerOperation.valueOf(getPowerAction());
+
+        CallContext.current().setEventDetails("Host Id: " + host.getId() + " Action: " + powerOperation.toString());
+        CallContext.current().putContextParameter(Host.class, host.getUuid());
+
+        final OutOfBandManagementResponse response = outOfBandManagementService.executeOutOfBandManagementPowerOperation(host, powerOperation, getActionTimeout());
+        response.setResponseName(getCommandName());
+        setResponseObject(response);
+    }
+
+    @Override
+    public String getCommandName() {
+        return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return CallContext.current().getCallingAccountId();
+    }
+
+    public Long getHostId() {
+        return hostId;
+    }
+
+    public Long getActionTimeout() {
+        return actionTimeout;
+    }
+
+    public String getPowerAction() {
+        return powerAction;
+    }
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_ACTION;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "issue out-out-band management power action: " + getPowerAction() + " on host: " + getHostId();
+    }
+
+    @Override
+    public ApiCommandJobType getInstanceType() {
+        return ApiCommandJobType.Host;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/api/src/org/apache/cloudstack/api/response/ClusterResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/ClusterResponse.java b/api/src/org/apache/cloudstack/api/response/ClusterResponse.java
index df01e09..754baa2 100644
--- a/api/src/org/apache/cloudstack/api/response/ClusterResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/ClusterResponse.java
@@ -17,7 +17,9 @@
 package org.apache.cloudstack.api.response;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import com.google.gson.annotations.SerializedName;
 
@@ -86,6 +88,10 @@ public class ClusterResponse extends BaseResponse {
     @Param(description = "Ovm3 VIP to use for pooling and/or clustering")
     private String ovm3vip;
 
+    @SerializedName(ApiConstants.RESOURCE_DETAILS)
+    @Param(description = "Meta data associated with the zone (key/value pairs)")
+    private Map<String, String> resourceDetails;
+
     public String getId() {
         return id;
     }
@@ -197,4 +203,11 @@ public class ClusterResponse extends BaseResponse {
     public String getOvm3Vip() {
         return ovm3vip;
     }
+
+    public void setResourceDetails(Map<String, String> details) {
+        if (details == null) {
+            return;
+        }
+        this.resourceDetails = new HashMap<>(details);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/api/src/org/apache/cloudstack/api/response/HostResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/HostResponse.java b/api/src/org/apache/cloudstack/api/response/HostResponse.java
index c6697fb..ab9c8c3 100644
--- a/api/src/org/apache/cloudstack/api/response/HostResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/HostResponse.java
@@ -24,6 +24,7 @@ import com.google.gson.annotations.SerializedName;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseResponse;
 import org.apache.cloudstack.api.EntityReference;
+import org.apache.cloudstack.outofbandmanagement.OutOfBandManagement;
 
 import java.util.Date;
 import java.util.HashMap;
@@ -200,6 +201,10 @@ public class HostResponse extends BaseResponse {
     @Param(description = "true if this host is suitable(has enough capacity and satisfies all conditions like hosttags, max guests vm limit etc) to migrate a VM to it , false otherwise")
     private Boolean suitableForMigration;
 
+    @SerializedName("outofbandmanagement")
+    @Param(description = "the host out-of-band management information")
+    private OutOfBandManagementResponse outOfBandManagementResponse;
+
     @SerializedName("resourcestate")
     @Param(description = "the resource state of the host")
     private String resourceState;
@@ -403,6 +408,14 @@ public class HostResponse extends BaseResponse {
         this.suitableForMigration = suitableForMigration;
     }
 
+    public OutOfBandManagementResponse getOutOfBandManagementResponse() {
+        return outOfBandManagementResponse;
+    }
+
+    public void setOutOfBandManagementResponse(final OutOfBandManagement outOfBandManagementConfig) {
+        this.outOfBandManagementResponse =  new OutOfBandManagementResponse(outOfBandManagementConfig);
+    }
+
     public String getResourceState() {
         return resourceState;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/api/src/org/apache/cloudstack/api/response/OutOfBandManagementResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/OutOfBandManagementResponse.java b/api/src/org/apache/cloudstack/api/response/OutOfBandManagementResponse.java
new file mode 100644
index 0000000..19594d2
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/response/OutOfBandManagementResponse.java
@@ -0,0 +1,189 @@
+// 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.response;
+
+import com.cloud.host.Host;
+import com.cloud.serializer.Param;
+import com.google.common.base.Strings;
+import com.google.gson.annotations.SerializedName;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseResponse;
+import org.apache.cloudstack.api.EntityReference;
+import org.apache.cloudstack.outofbandmanagement.OutOfBandManagement;
+
+@EntityReference(value = Host.class)
+public class OutOfBandManagementResponse extends BaseResponse {
+    @SerializedName(ApiConstants.HOST_ID)
+    @Param(description = "the ID of the host")
+    private String id;
+
+    @SerializedName(ApiConstants.POWER_STATE)
+    @Param(description = "the out-of-band management interface powerState of the host")
+    private OutOfBandManagement.PowerState powerState;
+
+    @SerializedName(ApiConstants.ENABLED)
+    @Param(description = "true if out-of-band management is enabled for the host")
+    private Boolean enabled;
+
+    @SerializedName(ApiConstants.DRIVER)
+    @Param(description = "the out-of-band management driver for the host")
+    private String driver;
+
+    @SerializedName(ApiConstants.ADDRESS)
+    @Param(description = "the out-of-band management interface address")
+    private String ipAddress;
+
+    @SerializedName(ApiConstants.PORT)
+    @Param(description = "the out-of-band management interface port")
+    private String port;
+
+    @SerializedName(ApiConstants.USERNAME)
+    @Param(description = "the out-of-band management interface username")
+    private String username;
+
+    @SerializedName(ApiConstants.PASSWORD)
+    @Param(description = "the out-of-band management interface password")
+    private String password;
+
+    @SerializedName(ApiConstants.ACTION)
+    @Param(description = "the out-of-band management action (if issued)")
+    private String outOfBandManagementAction;
+
+    @SerializedName(ApiConstants.DESCRIPTION)
+    @Param(description = "the operation result description")
+    private String resultDescription;
+
+    @SerializedName(ApiConstants.STATUS)
+    @Param(description = "the operation result")
+    private Boolean success;
+
+    public OutOfBandManagementResponse() {
+        super("outofbandmanagement");
+    }
+
+    public OutOfBandManagementResponse(final OutOfBandManagement outOfBandManagementConfig) {
+        this();
+        if (outOfBandManagementConfig == null) {
+            this.setEnabled(false);
+            this.setPowerState(OutOfBandManagement.PowerState.Disabled);
+            return;
+        }
+        this.setEnabled(outOfBandManagementConfig.isEnabled());
+        if (outOfBandManagementConfig.getPowerState() != null) {
+            this.setPowerState(outOfBandManagementConfig.getPowerState());
+        } else {
+            this.setPowerState(OutOfBandManagement.PowerState.Unknown);
+        }
+        this.setDriver(outOfBandManagementConfig.getDriver());
+        this.setIpAddress(outOfBandManagementConfig.getAddress());
+        if (outOfBandManagementConfig.getPort() != null) {
+            this.setPort(String.valueOf(outOfBandManagementConfig.getPort()));
+        }
+        this.setUsername(outOfBandManagementConfig.getUsername());
+        if (!Strings.isNullOrEmpty(outOfBandManagementConfig.getPassword())) {
+            this.setPassword(outOfBandManagementConfig.getPassword().substring(0, 1) + "****");
+        }
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public OutOfBandManagement.PowerState getPowerState() {
+        return powerState;
+    }
+
+    public void setPowerState(OutOfBandManagement.PowerState powerState) {
+        this.powerState = powerState;
+    }
+
+    public Boolean getEnabled() {
+        return enabled;
+    }
+
+    public void setEnabled(Boolean enabled) {
+        this.enabled = enabled;
+    }
+
+    public String getDriver() {
+        return driver;
+    }
+
+    public void setDriver(String driver) {
+        this.driver = driver;
+    }
+
+    public String getIpAddress() {
+        return ipAddress;
+    }
+
+    public void setIpAddress(String ipAddress) {
+        this.ipAddress = ipAddress;
+    }
+
+    public String getPort() {
+        return port;
+    }
+
+    public void setPort(String port) {
+        this.port = port;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public String getOutOfBandManagementAction() {
+        return outOfBandManagementAction;
+    }
+
+    public void setOutOfBandManagementAction(String outOfBandManagementAction) {
+        this.outOfBandManagementAction = outOfBandManagementAction;
+    }
+
+    public String getResultDescription() {
+        return resultDescription;
+    }
+
+    public void setResultDescription(String resultDescription) {
+        this.resultDescription = resultDescription;
+    }
+
+    public Boolean getSuccess() {
+        return success;
+    }
+
+    public void setSuccess(Boolean success) {
+        this.success = success;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/api/src/org/apache/cloudstack/api/response/ZoneResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/ZoneResponse.java b/api/src/org/apache/cloudstack/api/response/ZoneResponse.java
index 7aee448..4266077 100644
--- a/api/src/org/apache/cloudstack/api/response/ZoneResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/ZoneResponse.java
@@ -16,6 +16,7 @@
 // under the License.
 package org.apache.cloudstack.api.response;
 
+import java.util.HashMap;
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
@@ -233,6 +234,9 @@ public class ZoneResponse extends BaseResponse {
     }
 
     public void setResourceDetails(Map<String, String> details) {
-        this.resourceDetails = details;
+        if (details == null) {
+            return;
+        }
+        this.resourceDetails = new HashMap<>(details);
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/api/src/org/apache/cloudstack/outofbandmanagement/OutOfBandManagement.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/outofbandmanagement/OutOfBandManagement.java b/api/src/org/apache/cloudstack/outofbandmanagement/OutOfBandManagement.java
new file mode 100644
index 0000000..1a22328
--- /dev/null
+++ b/api/src/org/apache/cloudstack/outofbandmanagement/OutOfBandManagement.java
@@ -0,0 +1,150 @@
+// 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.outofbandmanagement;
+
+import com.cloud.utils.fsm.NoTransitionException;
+import com.cloud.utils.fsm.StateMachine2;
+import com.cloud.utils.fsm.StateObject;
+import org.apache.cloudstack.api.InternalIdentity;
+import org.apache.cloudstack.utils.identity.ManagementServerNode;
+
+import java.util.Set;
+
+public interface OutOfBandManagement extends StateObject<OutOfBandManagement.PowerState>, InternalIdentity {
+
+    PowerState getState();
+
+    Long getHostId();
+
+    boolean isEnabled();
+
+    PowerState getPowerState();
+
+    String getDriver();
+
+    String getAddress();
+
+    Integer getPort();
+
+    String getUsername();
+
+    String getPassword();
+
+    Long getManagementServerId();
+
+    void setEnabled(boolean enabled);
+
+    void setDriver(String driver);
+
+    void setAddress(String address);
+
+    void setPort(Integer port);
+
+    void setUsername(String username);
+
+    void setPassword(String password);
+
+    enum Option {
+        DRIVER,
+        ADDRESS,
+        PORT,
+        USERNAME,
+        PASSWORD
+    }
+
+    enum PowerOperation {
+        ON,
+        OFF,
+        CYCLE,
+        RESET,
+        SOFT,
+        STATUS,
+    }
+
+    enum PowerState {
+        On,
+        Off,
+        Unknown,
+        Disabled;
+
+        public enum Event {
+            On("Chassis Power is On"),
+            Off("Chassis Power is Off"),
+            AuthError("Authentication error happened"),
+            Unknown("An unknown error happened"),
+            Enabled("Out-of-band management enabled"),
+            Disabled("Out-of-band management disabled");
+
+            private String description;
+            Event(String description) {
+                this.description = description;
+            }
+            public String toString() {
+                return String.format("%s(%s)", super.toString(), this.getDescription());
+            }
+            public String getDescription() {
+                return description;
+            }
+            public Long getServerId() {
+                // TODO: change in future if we've better claim & ownership
+                // Right now the first one to update the db wins
+                // and mgmt server id would eventually become consistent
+                return ManagementServerNode.getManagementServerId();
+            }
+        }
+
+        public Event toEvent() {
+            if (this.equals(On)) {
+                return Event.On;
+            } else if (this.equals(Off)) {
+                return Event.Off;
+            } else if (this.equals(Disabled)) {
+                return Event.Disabled;
+            }
+            return Event.Unknown;
+        }
+
+        private static final StateMachine2<PowerState, Event, OutOfBandManagement> FSM = new StateMachine2<PowerState, Event, OutOfBandManagement>();
+        static {
+            FSM.addInitialTransition(Event.On, On);
+            FSM.addInitialTransition(Event.Off, Off);
+            FSM.addInitialTransition(Event.Unknown, Unknown);
+            FSM.addInitialTransition(Event.AuthError, Unknown);
+            FSM.addInitialTransition(Event.Disabled, Disabled);
+
+            FSM.addTransitionFromStates(Event.On, On, On, Off, Unknown, Disabled);
+            FSM.addTransitionFromStates(Event.Off, Off, On, Off, Unknown, Disabled);
+            FSM.addTransitionFromStates(Event.Unknown, Unknown, On, Off, Unknown, Disabled);
+            FSM.addTransitionFromStates(Event.AuthError, Unknown, On, Off, Disabled);
+            FSM.addTransitionFromStates(Event.Disabled, Disabled, On, Off, Unknown);
+        }
+
+        public static StateMachine2<PowerState, Event, OutOfBandManagement> getStateMachine() {
+            return FSM;
+        }
+
+        public PowerState getNextPowerState(Event e) throws NoTransitionException {
+            return FSM.getNextState(this, e);
+        }
+
+        public Set<Event> getPossibleEvents() {
+            return FSM.getPossibleEvents(this);
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/api/src/org/apache/cloudstack/outofbandmanagement/OutOfBandManagementDriver.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/outofbandmanagement/OutOfBandManagementDriver.java b/api/src/org/apache/cloudstack/outofbandmanagement/OutOfBandManagementDriver.java
new file mode 100644
index 0000000..3848963
--- /dev/null
+++ b/api/src/org/apache/cloudstack/outofbandmanagement/OutOfBandManagementDriver.java
@@ -0,0 +1,25 @@
+// 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.outofbandmanagement;
+
+import com.cloud.utils.component.Adapter;
+import org.apache.cloudstack.outofbandmanagement.driver.OutOfBandManagementDriverCommand;
+import org.apache.cloudstack.outofbandmanagement.driver.OutOfBandManagementDriverResponse;
+
+public interface OutOfBandManagementDriver extends Adapter {
+    OutOfBandManagementDriverResponse execute(OutOfBandManagementDriverCommand cmd);
+}


Mime
View raw message