cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sw...@apache.org
Subject [4/9] git commit: updated refs/heads/master to 143265c
Date Thu, 12 May 2016 15:06:53 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/api/src/org/apache/cloudstack/outofbandmanagement/OutOfBandManagementService.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/outofbandmanagement/OutOfBandManagementService.java b/api/src/org/apache/cloudstack/outofbandmanagement/OutOfBandManagementService.java
new file mode 100644
index 0000000..699b2c6
--- /dev/null
+++ b/api/src/org/apache/cloudstack/outofbandmanagement/OutOfBandManagementService.java
@@ -0,0 +1,55 @@
+// 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.dc.DataCenter;
+import com.cloud.host.Host;
+import com.cloud.org.Cluster;
+import com.google.common.collect.ImmutableMap;
+import org.apache.cloudstack.api.response.OutOfBandManagementResponse;
+import org.apache.cloudstack.framework.config.ConfigKey;
+
+import java.util.List;
+
+public interface OutOfBandManagementService {
+
+    ConfigKey<Long> ActionTimeout = new ConfigKey<Long>("Advanced", Long.class, "outofbandmanagement.action.timeout", "60",
+                    "The out of band management action timeout in seconds, configurable by cluster", true, ConfigKey.Scope.Cluster);
+
+    ConfigKey<Long> SyncThreadInterval = new ConfigKey<Long>("Advanced", Long.class, "outofbandmanagement.sync.interval", "300000",
+            "The interval (in milliseconds) when the out-of-band management background sync are retrieved", true, ConfigKey.Scope.Global);
+
+    ConfigKey<Integer> SyncThreadPoolSize = new ConfigKey<Integer>("Advanced", Integer.class, "outofbandmanagement.sync.poolsize", "50",
+            "The out of band management background sync thread pool size", true, ConfigKey.Scope.Global);
+
+    long getId();
+    boolean isOutOfBandManagementEnabled(Host host);
+    void submitBackgroundPowerSyncTask(Host host);
+    boolean transitionPowerStateToDisabled(List<? extends Host> hosts);
+
+    OutOfBandManagementResponse enableOutOfBandManagement(DataCenter zone);
+    OutOfBandManagementResponse enableOutOfBandManagement(Cluster cluster);
+    OutOfBandManagementResponse enableOutOfBandManagement(Host host);
+
+    OutOfBandManagementResponse disableOutOfBandManagement(DataCenter zone);
+    OutOfBandManagementResponse disableOutOfBandManagement(Cluster cluster);
+    OutOfBandManagementResponse disableOutOfBandManagement(Host host);
+
+    OutOfBandManagementResponse configureOutOfBandManagement(Host host, ImmutableMap<OutOfBandManagement.Option, String> options);
+    OutOfBandManagementResponse executeOutOfBandManagementPowerOperation(Host host, OutOfBandManagement.PowerOperation operation, Long timeout);
+    OutOfBandManagementResponse changeOutOfBandManagementPassword(Host host, String password);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/api/src/org/apache/cloudstack/outofbandmanagement/driver/OutOfBandManagementDriverChangePasswordCommand.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/outofbandmanagement/driver/OutOfBandManagementDriverChangePasswordCommand.java b/api/src/org/apache/cloudstack/outofbandmanagement/driver/OutOfBandManagementDriverChangePasswordCommand.java
new file mode 100644
index 0000000..943339e
--- /dev/null
+++ b/api/src/org/apache/cloudstack/outofbandmanagement/driver/OutOfBandManagementDriverChangePasswordCommand.java
@@ -0,0 +1,34 @@
+// 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.driver;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.cloudstack.outofbandmanagement.OutOfBandManagement;
+
+public final class OutOfBandManagementDriverChangePasswordCommand extends OutOfBandManagementDriverCommand {
+    private final String newPassword;
+
+    public OutOfBandManagementDriverChangePasswordCommand(final ImmutableMap<OutOfBandManagement.Option, String> options, final Long timeout, final String newPassword) {
+        super(options, timeout);
+        this.newPassword = newPassword;
+    }
+
+    public final String getNewPassword() {
+        return newPassword;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/api/src/org/apache/cloudstack/outofbandmanagement/driver/OutOfBandManagementDriverCommand.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/outofbandmanagement/driver/OutOfBandManagementDriverCommand.java b/api/src/org/apache/cloudstack/outofbandmanagement/driver/OutOfBandManagementDriverCommand.java
new file mode 100644
index 0000000..999b10c
--- /dev/null
+++ b/api/src/org/apache/cloudstack/outofbandmanagement/driver/OutOfBandManagementDriverCommand.java
@@ -0,0 +1,43 @@
+// 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.driver;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.cloudstack.outofbandmanagement.OutOfBandManagement;
+import org.joda.time.Duration;
+
+public abstract class OutOfBandManagementDriverCommand {
+    private final ImmutableMap<OutOfBandManagement.Option, String> options;
+    private final Duration timeout;
+
+    public OutOfBandManagementDriverCommand(final ImmutableMap<OutOfBandManagement.Option, String> options, final Long timeoutSeconds) {
+        this.options = options;
+        if (timeoutSeconds != null && timeoutSeconds > 0) {
+            this.timeout = new Duration(timeoutSeconds * 1000);
+        } else {
+            this.timeout = Duration.ZERO;
+        }
+    }
+
+    public final ImmutableMap<OutOfBandManagement.Option, String> getOptions() {
+        return options;
+    }
+
+    public final Duration getTimeout() {
+        return timeout;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/api/src/org/apache/cloudstack/outofbandmanagement/driver/OutOfBandManagementDriverPowerCommand.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/outofbandmanagement/driver/OutOfBandManagementDriverPowerCommand.java b/api/src/org/apache/cloudstack/outofbandmanagement/driver/OutOfBandManagementDriverPowerCommand.java
new file mode 100644
index 0000000..406be3b
--- /dev/null
+++ b/api/src/org/apache/cloudstack/outofbandmanagement/driver/OutOfBandManagementDriverPowerCommand.java
@@ -0,0 +1,33 @@
+// 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.driver;
+
+import com.google.common.collect.ImmutableMap;
+import org.apache.cloudstack.outofbandmanagement.OutOfBandManagement;
+
+public final class OutOfBandManagementDriverPowerCommand extends OutOfBandManagementDriverCommand {
+    private final OutOfBandManagement.PowerOperation powerOperation;
+
+    public OutOfBandManagementDriverPowerCommand(final ImmutableMap<OutOfBandManagement.Option, String> options, final Long timeout, final OutOfBandManagement.PowerOperation powerOperation) {
+        super(options, timeout);
+        this.powerOperation = powerOperation;
+    }
+
+    public final OutOfBandManagement.PowerOperation getPowerOperation() {
+        return powerOperation;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/api/src/org/apache/cloudstack/outofbandmanagement/driver/OutOfBandManagementDriverResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/outofbandmanagement/driver/OutOfBandManagementDriverResponse.java b/api/src/org/apache/cloudstack/outofbandmanagement/driver/OutOfBandManagementDriverResponse.java
new file mode 100644
index 0000000..78a25da
--- /dev/null
+++ b/api/src/org/apache/cloudstack/outofbandmanagement/driver/OutOfBandManagementDriverResponse.java
@@ -0,0 +1,85 @@
+// 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.driver;
+
+import org.apache.cloudstack.outofbandmanagement.OutOfBandManagement;
+
+public class OutOfBandManagementDriverResponse {
+    private String result;
+    private String error;
+    private boolean success = false;
+    private boolean hasAuthFailure = false;
+    private OutOfBandManagement.PowerState powerState;
+
+    public OutOfBandManagementDriverResponse(String result, String error, boolean success) {
+        this.result = result;
+        this.error = error;
+        this.success = success;
+    }
+
+    public OutOfBandManagement.PowerState.Event toEvent() {
+        if (hasAuthFailure()) {
+            return OutOfBandManagement.PowerState.Event.AuthError;
+        }
+
+        if (!isSuccess() || powerState == null) {
+            return OutOfBandManagement.PowerState.Event.Unknown;
+        }
+
+        return powerState.toEvent();
+    }
+
+    public boolean isSuccess() {
+        return success;
+    }
+
+    public String getResult() {
+        return result;
+    }
+
+    public String getError() {
+        return error;
+    }
+
+    public void setSuccess(boolean success) {
+        this.success = success;
+    }
+
+    public void setResult(String result) {
+        this.result = result;
+    }
+
+    public void setError(String error) {
+        this.error = error;
+    }
+
+    public OutOfBandManagement.PowerState getPowerState() {
+        return powerState;
+    }
+
+    public void setPowerState(OutOfBandManagement.PowerState powerState) {
+        this.powerState = powerState;
+    }
+
+    public boolean hasAuthFailure() {
+        return hasAuthFailure;
+    }
+
+    public void setAuthFailure(boolean hasAuthFailure) {
+        this.hasAuthFailure = hasAuthFailure;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/client/WEB-INF/classes/resources/messages.properties
----------------------------------------------------------------------
diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties
index 5e97907..8b8ad1a 100644
--- a/client/WEB-INF/classes/resources/messages.properties
+++ b/client/WEB-INF/classes/resources/messages.properties
@@ -876,6 +876,7 @@ label.metrics.num.cpu.cores=Cores
 label.metrics.property=Property
 label.metrics.scope=Scope
 label.metrics.state=State
+label.metrics.outofbandmanagementpowerstate=Power State
 label.metrics.storagepool=Storage Pool
 label.metrics.vm.name=VM Name
 label.migrate.instance.to.host=Migrate instance to another host
@@ -1004,6 +1005,25 @@ label.pods=Pods
 label.port.forwarding.policies=Port forwarding policies
 label.port.forwarding=Port Forwarding
 label.port.range=Port Range
+label.powerstate=Power State
+label.outofbandmanagement=Out-of-band Management
+label.outofbandmanagement.action.issue=Issue Out-of-band Management Power Action
+label.outofbandmanagement.action=Action
+label.outofbandmanagement.address=Address
+label.outofbandmanagement.changepassword=Change Out-of-band Management Password
+label.outofbandmanagement.configure=Configure Out-of-band Management
+label.outofbandmanagement.driver=Driver
+label.outofbandmanagement.disable=Disable Out-of-band Management
+label.outofbandmanagement.enable=Enable Out-of-band Management
+label.outofbandmanagement.password=Password
+label.outofbandmanagement.port=Port
+label.outofbandmanagement.username=Username
+message.outofbandmanagement.changepassword=Change Out-of-band Management password
+message.outofbandmanagement.configure=Configure Out-of-band Management
+message.outofbandmanagement.disable=Disable Out-of-band Management
+message.outofbandmanagement.enable=Enable Out-of-band Management
+message.outofbandmanagement.issue=Issue Out-of-band Management Power Action
+message.outofbandmanagement.action.maintenance=Warning host is in maintenance mode
 label.PreSetup=PreSetup
 label.prev=Prev
 label.previous=Previous

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/client/pom.xml
----------------------------------------------------------------------
diff --git a/client/pom.xml b/client/pom.xml
index 9bd80b7..7310cef 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -243,6 +243,11 @@
     </dependency>
     <dependency>
       <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-plugin-outofbandmanagement-driver-ipmitool</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
       <artifactId>cloud-mom-rabbitmq</artifactId>
       <version>${project.version}</version>
     </dependency>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/core/resources/META-INF/cloudstack/api/spring-core-lifecycle-api-context-inheritable.xml
----------------------------------------------------------------------
diff --git a/core/resources/META-INF/cloudstack/api/spring-core-lifecycle-api-context-inheritable.xml b/core/resources/META-INF/cloudstack/api/spring-core-lifecycle-api-context-inheritable.xml
index f1566b1..1a33fa2 100644
--- a/core/resources/META-INF/cloudstack/api/spring-core-lifecycle-api-context-inheritable.xml
+++ b/core/resources/META-INF/cloudstack/api/spring-core-lifecycle-api-context-inheritable.xml
@@ -61,6 +61,5 @@
         <property name="registry" ref="userPasswordEncodersRegistry" />
         <property name="typeClass" value="com.cloud.server.auth.UserAuthenticator" />
     </bean>
-    
 
 </beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/core/resources/META-INF/cloudstack/core/spring-core-registry-core-context.xml
----------------------------------------------------------------------
diff --git a/core/resources/META-INF/cloudstack/core/spring-core-registry-core-context.xml b/core/resources/META-INF/cloudstack/core/spring-core-registry-core-context.xml
index 5e2dc7b..d36f98d 100644
--- a/core/resources/META-INF/cloudstack/core/spring-core-registry-core-context.xml
+++ b/core/resources/META-INF/cloudstack/core/spring-core-registry-core-context.xml
@@ -306,5 +306,10 @@
         class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
         <property name="excludeKey" value="data.motion.strategies.exclude" />
     </bean>
-    
+
+    <bean id="outOfBandManagementDriversRegistry"
+          class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
+        <property name="orderConfigDefault" value="IPMITOOL" />
+    </bean>
+
 </beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/core/resources/META-INF/cloudstack/outofbandmanagement/module.properties
----------------------------------------------------------------------
diff --git a/core/resources/META-INF/cloudstack/outofbandmanagement/module.properties b/core/resources/META-INF/cloudstack/outofbandmanagement/module.properties
new file mode 100644
index 0000000..73d4bec
--- /dev/null
+++ b/core/resources/META-INF/cloudstack/outofbandmanagement/module.properties
@@ -0,0 +1,21 @@
+#
+# 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.
+#
+
+name=outofbandmanagement
+parent=core

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/core/resources/META-INF/cloudstack/outofbandmanagement/spring-core-lifecycle-outofbandmanagement-context-inheritable.xml
----------------------------------------------------------------------
diff --git a/core/resources/META-INF/cloudstack/outofbandmanagement/spring-core-lifecycle-outofbandmanagement-context-inheritable.xml b/core/resources/META-INF/cloudstack/outofbandmanagement/spring-core-lifecycle-outofbandmanagement-context-inheritable.xml
new file mode 100644
index 0000000..6a25a2e
--- /dev/null
+++ b/core/resources/META-INF/cloudstack/outofbandmanagement/spring-core-lifecycle-outofbandmanagement-context-inheritable.xml
@@ -0,0 +1,36 @@
+<!--
+
+    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.
+
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xmlns:aop="http://www.springframework.org/schema/aop"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+                      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+                      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+                      http://www.springframework.org/schema/context
+                      http://www.springframework.org/schema/context/spring-context-3.0.xsd"
+                      >
+
+    <bean class="org.apache.cloudstack.spring.lifecycle.registry.RegistryLifecycle">
+        <property name="registry" ref="outOfBandManagementDriversRegistry" />
+        <property name="typeClass" value="org.apache.cloudstack.outofbandmanagement.OutOfBandManagementDriver" />
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/debian/control
----------------------------------------------------------------------
diff --git a/debian/control b/debian/control
index 6e7881b..6452c03 100644
--- a/debian/control
+++ b/debian/control
@@ -15,7 +15,7 @@ Description: A common package which contains files which are shared by several C
 
 Package: cloudstack-management
 Architecture: all
-Depends: ${misc:Depends}, ${python:Depends}, cloudstack-common (= ${source:Version}), tomcat6 | tomcat7, sudo, jsvc, python-mysql.connector, libmysql-java, augeas-tools, mysql-client, adduser, bzip2
+Depends: ${misc:Depends}, ${python:Depends}, cloudstack-common (= ${source:Version}), tomcat6 | tomcat7, sudo, jsvc, python-mysql.connector, libmysql-java, augeas-tools, mysql-client, adduser, bzip2, ipmitool
 Conflicts: cloud-server, cloud-client, cloud-client-ui
 Description: CloudStack server library
  The CloudStack management server

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/developer/developer-prefill.sql
----------------------------------------------------------------------
diff --git a/developer/developer-prefill.sql b/developer/developer-prefill.sql
index 0dbe180..ab3da96 100644
--- a/developer/developer-prefill.sql
+++ b/developer/developer-prefill.sql
@@ -106,6 +106,18 @@ INSERT INTO `cloud`.`configuration` (category, instance, component, name, value)
             VALUES ('Advanced', 'DEFAULT', 'management-server',
             'direct.agent.load.size', '1000');
 
+INSERT INTO `cloud`.`configuration` (category, instance, component, name, value)
+            VALUES ('Advanced', 'DEFAULT', 'management-server',
+            'ping.interval', '10');
+
+INSERT INTO `cloud`.`configuration` (category, instance, component, name, value)
+            VALUES ('Advanced', 'DEFAULT', 'management-server',
+            'ping.timeout', '1.5');
+
+INSERT INTO `cloud`.`configuration` (category, instance, component, name, value)
+            VALUES ('Advanced', 'DEFAULT', 'management-server',
+            'outofbandmanagement.sync.interval', '2000');
+
 -- Enable dynamic RBAC by default for fresh deployments
 INSERT INTO `cloud`.`configuration` (category, instance, component, name, value)
             VALUES ('Advanced', 'DEFAULT', 'RoleService',

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java b/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
index 45a7dca..e41a585 100644
--- a/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/agent/manager/AgentManagerImpl.java
@@ -43,6 +43,7 @@ import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.cloudstack.framework.jobs.AsyncJob;
 import org.apache.cloudstack.framework.jobs.AsyncJobExecutionContext;
 import org.apache.cloudstack.managed.context.ManagedContextRunnable;
+import org.apache.cloudstack.outofbandmanagement.dao.OutOfBandManagementDao;
 import org.apache.cloudstack.utils.identity.ManagementServerNode;
 import org.apache.log4j.Logger;
 import org.slf4j.MDC;
@@ -139,6 +140,8 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl
     @Inject
     protected HostDao _hostDao = null;
     @Inject
+    protected OutOfBandManagementDao outOfBandManagementDao;
+    @Inject
     protected DataCenterDao _dcDao = null;
     @Inject
     protected HostPodDao _podDao = null;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
index 91085bf..9239adc 100644
--- a/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/agent/manager/ClusteredAgentManagerImpl.java
@@ -736,6 +736,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
             s_logger.info("Marking hosts as disconnected on Management server" + vo.getMsid());
             final long lastPing = (System.currentTimeMillis() >> 10) - getTimeout();
             _hostDao.markHostsAsDisconnected(vo.getMsid(), lastPing);
+            outOfBandManagementDao.expireOutOfBandManagementOwnershipByServer(vo.getMsid());
             s_logger.info("Deleting entries from op_host_transfer table for Management server " + vo.getMsid());
             cleanupTransferMap(vo.getMsid());
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml
----------------------------------------------------------------------
diff --git a/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml b/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml
index a3d58fc..6916478 100644
--- a/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml
+++ b/engine/schema/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml
@@ -347,6 +347,6 @@
   <bean id="databaseIntegrityChecker" class="com.cloud.upgrade.DatabaseIntegrityChecker" />
   <bean id="LBStickinessPolicyDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.LBStickinessPolicyDetailsDaoImpl" />
   <bean id="LBHealthCheckPolicyDetailsDaoImpl" class="org.apache.cloudstack.resourcedetail.dao.LBHealthCheckPolicyDetailsDaoImpl" />
-
+  <bean id="outOfBandManagementDaoImpl" class="org.apache.cloudstack.outofbandmanagement.dao.OutOfBandManagementDaoImpl" />
 
 </beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/engine/schema/src/com/cloud/dc/dao/DataCenterDetailsDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/dao/DataCenterDetailsDao.java b/engine/schema/src/com/cloud/dc/dao/DataCenterDetailsDao.java
index ed7c494..1422e3f 100644
--- a/engine/schema/src/com/cloud/dc/dao/DataCenterDetailsDao.java
+++ b/engine/schema/src/com/cloud/dc/dao/DataCenterDetailsDao.java
@@ -16,10 +16,10 @@
 // under the License.
 package com.cloud.dc.dao;
 
-import org.apache.cloudstack.resourcedetail.ResourceDetailsDao;
-
 import com.cloud.dc.DataCenterDetailVO;
 import com.cloud.utils.db.GenericDao;
+import org.apache.cloudstack.resourcedetail.ResourceDetailsDao;
 
 public interface DataCenterDetailsDao extends GenericDao<DataCenterDetailVO, Long>, ResourceDetailsDao<DataCenterDetailVO> {
+    void persist(long zoneId, String name, String value);
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/engine/schema/src/com/cloud/dc/dao/DataCenterDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/dao/DataCenterDetailsDaoImpl.java b/engine/schema/src/com/cloud/dc/dao/DataCenterDetailsDaoImpl.java
index 8bc9eff..e36c8eb 100644
--- a/engine/schema/src/com/cloud/dc/dao/DataCenterDetailsDaoImpl.java
+++ b/engine/schema/src/com/cloud/dc/dao/DataCenterDetailsDaoImpl.java
@@ -16,7 +16,6 @@
 // under the License.
 package com.cloud.dc.dao;
 
-
 import org.apache.cloudstack.api.ResourceDetail;
 import org.apache.cloudstack.framework.config.ConfigKey;
 import org.apache.cloudstack.framework.config.ConfigKey.Scope;
@@ -24,9 +23,21 @@ import org.apache.cloudstack.framework.config.ScopedConfigStorage;
 import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase;
 
 import com.cloud.dc.DataCenterDetailVO;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.TransactionLegacy;
 
 public class DataCenterDetailsDaoImpl extends ResourceDetailsDaoBase<DataCenterDetailVO> implements DataCenterDetailsDao, ScopedConfigStorage {
 
+    private final SearchBuilder<DataCenterDetailVO> DetailSearch;
+
+    DataCenterDetailsDaoImpl() {
+        DetailSearch = createSearchBuilder();
+        DetailSearch.and("zoneId", DetailSearch.entity().getResourceId(), SearchCriteria.Op.EQ);
+        DetailSearch.and("name", DetailSearch.entity().getName(), SearchCriteria.Op.EQ);
+        DetailSearch.done();
+    }
+
     @Override
     public Scope getScope() {
         return ConfigKey.Scope.Zone;
@@ -43,4 +54,17 @@ public class DataCenterDetailsDaoImpl extends ResourceDetailsDaoBase<DataCenterD
         super.addDetail(new DataCenterDetailVO(resourceId, key, value, display));
     }
 
+    @Override
+    public void persist(long zoneId, String name, String value) {
+        TransactionLegacy txn = TransactionLegacy.currentTxn();
+        txn.start();
+        SearchCriteria<DataCenterDetailVO> sc = DetailSearch.create();
+        sc.setParameters("zoneId", zoneId);
+        sc.setParameters("name", name);
+        expunge(sc);
+
+        DataCenterDetailVO vo = new DataCenterDetailVO(zoneId, name, value, true);
+        persist(vo);
+        txn.commit();
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/engine/schema/src/com/cloud/host/dao/HostDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/host/dao/HostDao.java b/engine/schema/src/com/cloud/host/dao/HostDao.java
index bd48482..26e0644 100644
--- a/engine/schema/src/com/cloud/host/dao/HostDao.java
+++ b/engine/schema/src/com/cloud/host/dao/HostDao.java
@@ -81,6 +81,8 @@ public interface HostDao extends GenericDao<HostVO, Long>, StateDao<Status, Stat
      */
     List<HostVO> listAllUpAndEnabledNonHAHosts(Type type, Long clusterId, Long podId, long dcId, String haTag);
 
+    List<HostVO> findByDataCenterId(Long zoneId);
+
     List<HostVO> findByPodId(Long podId);
 
     List<HostVO> findByClusterId(Long clusterId);
@@ -89,5 +91,7 @@ public interface HostDao extends GenericDao<HostVO, Long>, StateDao<Status, Stat
 
     List<Long> listAllHosts(long zoneId);
 
+    List<HostVO> listAllHostsByType(Host.Type type);
+
     HostVO findByPublicIp(String publicIp);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/engine/schema/src/com/cloud/host/dao/HostDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/host/dao/HostDaoImpl.java b/engine/schema/src/com/cloud/host/dao/HostDaoImpl.java
index 8342f1f..09d9d40 100644
--- a/engine/schema/src/com/cloud/host/dao/HostDaoImpl.java
+++ b/engine/schema/src/com/cloud/host/dao/HostDaoImpl.java
@@ -1049,6 +1049,14 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
     }
 
     @Override
+    public List<HostVO> findByDataCenterId(Long zoneId) {
+        SearchCriteria<HostVO> sc = DcSearch.create();
+        sc.setParameters("dc", zoneId);
+        sc.setParameters("type", Type.Routing);
+        return listBy(sc);
+    }
+
+    @Override
     public List<HostVO> findByPodId(Long podId) {
         SearchCriteria<HostVO> sc = PodSearch.create();
         sc.setParameters("podId", podId);
@@ -1087,4 +1095,13 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
         sc.addAnd("dataCenterId", SearchCriteria.Op.EQ, zoneId);
         return customSearch(sc, null);
     }
+
+    @Override
+    public List<HostVO> listAllHostsByType(Host.Type type) {
+        SearchCriteria<HostVO> sc = TypeSearch.create();
+        sc.setParameters("type", type);
+        sc.setParameters("resourceState", ResourceState.Enabled);
+
+        return listBy(sc);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/engine/schema/src/org/apache/cloudstack/outofbandmanagement/OutOfBandManagementVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/outofbandmanagement/OutOfBandManagementVO.java b/engine/schema/src/org/apache/cloudstack/outofbandmanagement/OutOfBandManagementVO.java
new file mode 100644
index 0000000..b5c357c
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/outofbandmanagement/OutOfBandManagementVO.java
@@ -0,0 +1,193 @@
+// 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.db.Encrypt;
+import com.cloud.utils.db.StateMachine;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import java.util.Date;
+
+@Entity
+@Table(name = "oobm")
+public class OutOfBandManagementVO implements OutOfBandManagement {
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    private long id;
+
+    @Column(name = "host_id")
+    private Long hostId;
+
+    @Column(name = "enabled")
+    private boolean enabled = false;
+
+    // There is no setter for status because it has to be set in the dao code
+    @Enumerated(value = EnumType.STRING)
+    @StateMachine(state = PowerState.class, event = PowerState.Event.class)
+    @Column(name = "power_state", updatable = true, nullable = false, length = 32)
+    private PowerState powerState = null;
+
+    @Column(name = "driver")
+    private String driver;
+
+    @Column(name = "address")
+    private String address;
+
+    @Column(name = "port")
+    private Integer port;
+
+    @Column(name = "username")
+    private String username;
+
+    @Encrypt
+    @Column(name = "password")
+    private String password;
+
+    // This field should be updated every time the state is updated.
+    // There's no set method in the vo object because it is done with in the dao code.
+    @Column(name = "update_count", updatable = true, nullable = false)
+    protected long updateCount;
+
+    @Column(name = "update_time", updatable = true)
+    @Temporal(value = TemporalType.TIMESTAMP)
+    protected Date updateTime;
+
+    @Column(name = "mgmt_server_id")
+    private Long managementServerId;
+
+    public OutOfBandManagementVO(Long hostId) {
+        this.hostId = hostId;
+        this.powerState = PowerState.Disabled;
+    }
+
+    public OutOfBandManagementVO() {
+    }
+
+    @Override
+    public long getId() {
+        return id;
+    }
+
+    @Override
+    public PowerState getState() {
+        return powerState;
+    }
+
+    public Long getHostId() {
+        return hostId;
+    }
+
+    public boolean isEnabled() {
+        return enabled;
+    }
+
+    public PowerState getPowerState() {
+        return powerState;
+    }
+
+    @Override
+    public String getDriver() {
+        return driver;
+    }
+
+    @Override
+    public String getAddress() {
+        return address;
+    }
+
+    @Override
+    public Integer getPort() {
+        return port;
+    }
+
+    @Override
+    public String getUsername() {
+        return username;
+    }
+
+    @Override
+    public String getPassword() {
+        return password;
+    }
+
+    public long incrUpdateCount() {
+        updateCount++;
+        return updateCount;
+    }
+
+    public long getUpdateCount() {
+        return updateCount;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    @Override
+    public Long getManagementServerId() {
+        return managementServerId;
+    }
+
+    public void setHostId(Long hostId) {
+        this.hostId = hostId;
+    }
+
+    @Override
+    public void setEnabled(boolean enabled) {
+        this.enabled = enabled;
+    }
+
+    @Override
+    public void setDriver(String driver) {
+        this.driver = driver;
+    }
+
+    @Override
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    @Override
+    public void setPort(Integer port) {
+        this.port = port;
+    }
+
+    @Override
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    @Override
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public void setManagementServerId(Long managementServerId) {
+        this.managementServerId = managementServerId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/engine/schema/src/org/apache/cloudstack/outofbandmanagement/dao/OutOfBandManagementDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/outofbandmanagement/dao/OutOfBandManagementDao.java b/engine/schema/src/org/apache/cloudstack/outofbandmanagement/dao/OutOfBandManagementDao.java
new file mode 100644
index 0000000..5985b81
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/outofbandmanagement/dao/OutOfBandManagementDao.java
@@ -0,0 +1,31 @@
+// 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.dao;
+
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.fsm.StateDao;
+import org.apache.cloudstack.outofbandmanagement.OutOfBandManagement;
+import org.apache.cloudstack.outofbandmanagement.OutOfBandManagementVO;
+
+import java.util.List;
+
+public interface OutOfBandManagementDao extends GenericDao<OutOfBandManagementVO, Long>, StateDao<OutOfBandManagement.PowerState, OutOfBandManagement.PowerState.Event, OutOfBandManagement> {
+    OutOfBandManagement findByHost(long hostId);
+    List<OutOfBandManagementVO> findAllByManagementServer(long serverId);
+    void expireOutOfBandManagementOwnershipByServer(long serverId);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/engine/schema/src/org/apache/cloudstack/outofbandmanagement/dao/OutOfBandManagementDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/outofbandmanagement/dao/OutOfBandManagementDaoImpl.java b/engine/schema/src/org/apache/cloudstack/outofbandmanagement/dao/OutOfBandManagementDaoImpl.java
new file mode 100644
index 0000000..b914b6b
--- /dev/null
+++ b/engine/schema/src/org/apache/cloudstack/outofbandmanagement/dao/OutOfBandManagementDaoImpl.java
@@ -0,0 +1,158 @@
+// 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.dao;
+
+import com.cloud.utils.DateUtil;
+import com.cloud.utils.db.Attribute;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.Filter;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.Transaction;
+import com.cloud.utils.db.TransactionCallbackNoReturn;
+import com.cloud.utils.db.TransactionLegacy;
+import com.cloud.utils.db.TransactionStatus;
+import com.cloud.utils.db.UpdateBuilder;
+import org.apache.cloudstack.outofbandmanagement.OutOfBandManagement;
+import org.apache.cloudstack.outofbandmanagement.OutOfBandManagementVO;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.List;
+
+@DB
+@Component
+public class OutOfBandManagementDaoImpl extends GenericDaoBase<OutOfBandManagementVO, Long> implements OutOfBandManagementDao {
+    private static final Logger LOG = Logger.getLogger(OutOfBandManagementDaoImpl.class);
+
+    private SearchBuilder<OutOfBandManagementVO> HostSearch;
+    private SearchBuilder<OutOfBandManagementVO> ManagementServerSearch;
+    private SearchBuilder<OutOfBandManagementVO> OutOfBandManagementOwnerSearch;
+    private SearchBuilder<OutOfBandManagementVO> StateUpdateSearch;
+
+    private Attribute PowerStateAttr;
+    private Attribute MsIdAttr;
+    private Attribute UpdateTimeAttr;
+
+    public OutOfBandManagementDaoImpl() {
+        super();
+
+        HostSearch = createSearchBuilder();
+        HostSearch.and("hostId", HostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
+        HostSearch.done();
+
+        ManagementServerSearch = createSearchBuilder();
+        ManagementServerSearch.and("server", ManagementServerSearch.entity().getManagementServerId(), SearchCriteria.Op.EQ);
+        ManagementServerSearch.done();
+
+        OutOfBandManagementOwnerSearch = createSearchBuilder();
+        OutOfBandManagementOwnerSearch.and("server", OutOfBandManagementOwnerSearch.entity().getManagementServerId(), SearchCriteria.Op.EQ);
+        OutOfBandManagementOwnerSearch.or("serverNull", OutOfBandManagementOwnerSearch.entity().getManagementServerId(), SearchCriteria.Op.NULL);
+        OutOfBandManagementOwnerSearch.done();
+
+        StateUpdateSearch = createSearchBuilder();
+        StateUpdateSearch.and("status", StateUpdateSearch.entity().getPowerState(), SearchCriteria.Op.EQ);
+        StateUpdateSearch.and("id", StateUpdateSearch.entity().getId(), SearchCriteria.Op.EQ);
+        StateUpdateSearch.and("update", StateUpdateSearch.entity().getUpdateCount(), SearchCriteria.Op.EQ);
+        StateUpdateSearch.done();
+
+        PowerStateAttr = _allAttributes.get("powerState");
+        MsIdAttr = _allAttributes.get("managementServerId");
+        UpdateTimeAttr = _allAttributes.get("updateTime");
+        assert (PowerStateAttr != null && MsIdAttr != null && UpdateTimeAttr != null) : "Couldn't find one of these attributes";
+    }
+
+    @Override
+    public OutOfBandManagement findByHost(long hostId) {
+        SearchCriteria<OutOfBandManagementVO> sc = HostSearch.create("hostId", hostId);
+        return findOneBy(sc);
+    }
+
+    @Override
+    public List<OutOfBandManagementVO> findAllByManagementServer(long serverId) {
+        SearchCriteria<OutOfBandManagementVO> sc = OutOfBandManagementOwnerSearch.create();
+        sc.setParameters("server", serverId);
+        return listBy(sc, new Filter(OutOfBandManagementVO.class, "updateTime", true, null, null));
+    }
+
+    private void executeExpireOwnershipSql(final String sql, final long resource) {
+        Transaction.execute(new TransactionCallbackNoReturn() {
+            @Override
+            public void doInTransactionWithoutResult(TransactionStatus status) {
+                TransactionLegacy txn = TransactionLegacy.currentTxn();
+                try (final PreparedStatement pstmt = txn.prepareAutoCloseStatement(sql);) {
+                    pstmt.setLong(1, resource);
+                    pstmt.executeUpdate();
+                } catch (SQLException e) {
+                    txn.rollback();
+                    LOG.warn("Failed to expire ownership for out-of-band management server id: " + resource);
+                }
+            }
+        });
+    }
+
+    @Override
+    public void expireOutOfBandManagementOwnershipByServer(long serverId) {
+        final String resetOwnerSql = "UPDATE oobm set mgmt_server_id=NULL, power_state=NULL where mgmt_server_id=?";
+        executeExpireOwnershipSql(resetOwnerSql, serverId);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Expired out-of-band management ownership for hosts owned by management server id:" + serverId);
+        }
+    }
+
+    @Override
+    public boolean updateState(OutOfBandManagement.PowerState oldStatus, OutOfBandManagement.PowerState.Event event, OutOfBandManagement.PowerState newStatus, OutOfBandManagement vo, Object data) {
+        OutOfBandManagementVO oobmHost = (OutOfBandManagementVO) vo;
+        if (oobmHost == null) {
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("Invalid out-of-band management host view object provided");
+            }
+            return false;
+        }
+
+        Long newManagementServerId = event.getServerId();
+        // Avoid updates when old ownership and state are same as new
+        if (oldStatus == newStatus && (oobmHost.getManagementServerId() != null && oobmHost.getManagementServerId().equals(newManagementServerId))) {
+            return false;
+        }
+
+        if (event == OutOfBandManagement.PowerState.Event.Disabled) {
+            newManagementServerId = null;
+        }
+
+        SearchCriteria<OutOfBandManagementVO> sc = StateUpdateSearch.create();
+        sc.setParameters("status", oldStatus);
+        sc.setParameters("id", oobmHost.getId());
+        sc.setParameters("update", oobmHost.getUpdateCount());
+
+        oobmHost.incrUpdateCount();
+        UpdateBuilder ub = getUpdateBuilder(oobmHost);
+        ub.set(oobmHost, PowerStateAttr, newStatus);
+        ub.set(oobmHost, UpdateTimeAttr, DateUtil.currentGMTTime());
+        ub.set(oobmHost, MsIdAttr, newManagementServerId);
+
+        int result = update(ub, sc, null);
+        if (LOG.isDebugEnabled() && result <= 0) {
+            LOG.debug(String.format("Failed to update out-of-band management power state from:%s to:%s due to event:%s for the host id:%d", oldStatus, newStatus, event, oobmHost.getHostId()));
+        }
+        return result > 0;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/plugins/outofbandmanagement-drivers/ipmitool/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/outofbandmanagement-drivers/ipmitool/pom.xml b/plugins/outofbandmanagement-drivers/ipmitool/pom.xml
new file mode 100644
index 0000000..be4cd86
--- /dev/null
+++ b/plugins/outofbandmanagement-drivers/ipmitool/pom.xml
@@ -0,0 +1,41 @@
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>cloud-plugin-outofbandmanagement-driver-ipmitool</artifactId>
+  <name>Apache CloudStack Plugin - Power Management Driver ipmitool</name>
+  <parent>
+    <groupId>org.apache.cloudstack</groupId>
+    <artifactId>cloudstack-plugins</artifactId>
+    <version>4.9.0-SNAPSHOT</version>
+    <relativePath>../../pom.xml</relativePath>
+  </parent>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-utils</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+  </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/plugins/outofbandmanagement-drivers/ipmitool/resources/META-INF/cloudstack/ipmitool/module.properties
----------------------------------------------------------------------
diff --git a/plugins/outofbandmanagement-drivers/ipmitool/resources/META-INF/cloudstack/ipmitool/module.properties b/plugins/outofbandmanagement-drivers/ipmitool/resources/META-INF/cloudstack/ipmitool/module.properties
new file mode 100644
index 0000000..f6499d7
--- /dev/null
+++ b/plugins/outofbandmanagement-drivers/ipmitool/resources/META-INF/cloudstack/ipmitool/module.properties
@@ -0,0 +1,18 @@
+# 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.
+name=ipmitool
+parent=outofbandmanagement

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/plugins/outofbandmanagement-drivers/ipmitool/resources/META-INF/cloudstack/ipmitool/spring-ipmitool-context.xml
----------------------------------------------------------------------
diff --git a/plugins/outofbandmanagement-drivers/ipmitool/resources/META-INF/cloudstack/ipmitool/spring-ipmitool-context.xml b/plugins/outofbandmanagement-drivers/ipmitool/resources/META-INF/cloudstack/ipmitool/spring-ipmitool-context.xml
new file mode 100644
index 0000000..49baa90
--- /dev/null
+++ b/plugins/outofbandmanagement-drivers/ipmitool/resources/META-INF/cloudstack/ipmitool/spring-ipmitool-context.xml
@@ -0,0 +1,34 @@
+<!--
+  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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xmlns:aop="http://www.springframework.org/schema/aop"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+                      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+                      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+                      http://www.springframework.org/schema/context
+                      http://www.springframework.org/schema/context/spring-context-3.0.xsd"
+                      >
+
+    <bean id="ipmitoolOutOfBandManagementDriver" class="org.apache.cloudstack.outofbandmanagement.driver.ipmitool.IpmitoolOutOfBandManagementDriver">
+        <property name="name" value="IPMITOOL" />
+    </bean>
+
+</beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/plugins/outofbandmanagement-drivers/ipmitool/src/org/apache/cloudstack/outofbandmanagement/driver/ipmitool/IpmitoolOutOfBandManagementDriver.java
----------------------------------------------------------------------
diff --git a/plugins/outofbandmanagement-drivers/ipmitool/src/org/apache/cloudstack/outofbandmanagement/driver/ipmitool/IpmitoolOutOfBandManagementDriver.java b/plugins/outofbandmanagement-drivers/ipmitool/src/org/apache/cloudstack/outofbandmanagement/driver/ipmitool/IpmitoolOutOfBandManagementDriver.java
new file mode 100644
index 0000000..bad3cb6
--- /dev/null
+++ b/plugins/outofbandmanagement-drivers/ipmitool/src/org/apache/cloudstack/outofbandmanagement/driver/ipmitool/IpmitoolOutOfBandManagementDriver.java
@@ -0,0 +1,167 @@
+// 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.driver.ipmitool;
+
+import com.cloud.utils.component.AdapterBase;
+import com.cloud.utils.concurrency.NamedThreadFactory;
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableMap;
+import org.apache.cloudstack.framework.config.ConfigKey;
+import org.apache.cloudstack.framework.config.Configurable;
+import org.apache.cloudstack.outofbandmanagement.OutOfBandManagement;
+import org.apache.cloudstack.outofbandmanagement.OutOfBandManagementDriver;
+import org.apache.cloudstack.outofbandmanagement.OutOfBandManagementService;
+import org.apache.cloudstack.outofbandmanagement.driver.OutOfBandManagementDriverChangePasswordCommand;
+import org.apache.cloudstack.outofbandmanagement.driver.OutOfBandManagementDriverCommand;
+import org.apache.cloudstack.outofbandmanagement.driver.OutOfBandManagementDriverPowerCommand;
+import org.apache.cloudstack.outofbandmanagement.driver.OutOfBandManagementDriverResponse;
+import org.apache.log4j.Logger;
+import org.joda.time.Duration;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+public final class IpmitoolOutOfBandManagementDriver extends AdapterBase implements OutOfBandManagementDriver, Configurable {
+    public static final Logger LOG = Logger.getLogger(IpmitoolOutOfBandManagementDriver.class);
+
+    private static volatile boolean isDriverEnabled = false;
+    private static boolean isIpmiToolBinAvailable = false;
+
+    private final ExecutorService ipmitoolExecutor = Executors.newFixedThreadPool(OutOfBandManagementService.SyncThreadPoolSize.value(), new NamedThreadFactory("IpmiToolDriver"));
+    private final IpmitoolWrapper IPMITOOL = new IpmitoolWrapper(ipmitoolExecutor);
+
+    public final ConfigKey<String> IpmiToolPath = new ConfigKey<String>("Advanced", String.class, "outofbandmanagement.ipmitool.path", "/usr/bin/ipmitool",
+            "The out of band management ipmitool path used by the IpmiTool driver. Default: /usr/bin/ipmitool.", true, ConfigKey.Scope.Global);
+
+    public final ConfigKey<String> IpmiToolInterface = new ConfigKey<String>("Advanced", String.class, "outofbandmanagement.ipmitool.interface", "lanplus",
+            "The out of band management IpmiTool driver interface to use. Default: lanplus. Valid values are: lan, lanplus, open etc.", true, ConfigKey.Scope.Global);
+
+    public final ConfigKey<String> IpmiToolRetries = new ConfigKey<String>("Advanced", String.class, "outofbandmanagement.ipmitool.retries", "1",
+            "The out of band management IpmiTool driver retries option -R. Default 1.", true, ConfigKey.Scope.Global);
+
+    private String getIpmiUserId(ImmutableMap<OutOfBandManagement.Option, String> options, final Duration timeOut) {
+        final String username = options.get(OutOfBandManagement.Option.USERNAME);
+        if (Strings.isNullOrEmpty(username)) {
+            throw new CloudRuntimeException("Empty IPMI user configured, cannot proceed to find user's ID");
+        }
+
+        final List<String> ipmiToolCommands = IPMITOOL.getIpmiToolCommandArgs(IpmiToolPath.value(),
+                IpmiToolInterface.value(),
+                IpmiToolRetries.value(),
+                options, "user", "list");
+        final OutOfBandManagementDriverResponse output = IPMITOOL.executeCommands(ipmiToolCommands, timeOut);
+        if (!output.isSuccess()) {
+            throw new CloudRuntimeException("Failed to find IPMI user to change password, error: " + output.getError());
+        }
+
+        final String userId = IPMITOOL.findIpmiUser(output.getResult(), username);
+        if (Strings.isNullOrEmpty(userId)) {
+            throw new CloudRuntimeException("No IPMI user ID found for the username: " + username);
+        }
+        return userId;
+    }
+
+    public OutOfBandManagementDriverResponse execute(final OutOfBandManagementDriverCommand cmd) {
+        if (!isIpmiToolBinAvailable) {
+            initDriver();
+            if (!isIpmiToolBinAvailable) {
+                return new OutOfBandManagementDriverResponse(null, "Aborting operation due to ipmitool binary not available for execution", false);
+            }
+        }
+
+        OutOfBandManagementDriverResponse response = new OutOfBandManagementDriverResponse(null, "Unsupported Command", false);
+        if (!isDriverEnabled) {
+            response.setError("Driver not enabled or shutdown");
+            return response;
+        }
+        if (cmd instanceof OutOfBandManagementDriverPowerCommand) {
+            response = execute((OutOfBandManagementDriverPowerCommand) cmd);
+        } else if (cmd instanceof OutOfBandManagementDriverChangePasswordCommand) {
+            response = execute((OutOfBandManagementDriverChangePasswordCommand) cmd);
+        }
+
+        if (response != null && !response.isSuccess() && response.getError().contains("RAKP 2 HMAC is invalid")) {
+            response.setAuthFailure(true);
+        }
+        return response;
+    }
+
+    private OutOfBandManagementDriverResponse execute(final OutOfBandManagementDriverPowerCommand cmd) {
+        List<String> ipmiToolCommands = IPMITOOL.getIpmiToolCommandArgs(IpmiToolPath.value(),
+                IpmiToolInterface.value(),
+                IpmiToolRetries.value(),
+                cmd.getOptions(), "chassis", "power", IPMITOOL.parsePowerCommand(cmd.getPowerOperation()));
+
+        final OutOfBandManagementDriverResponse response = IPMITOOL.executeCommands(ipmiToolCommands, cmd.getTimeout());
+
+        if (response.isSuccess() && cmd.getPowerOperation().equals(OutOfBandManagement.PowerOperation.STATUS)) {
+            response.setPowerState(IPMITOOL.parsePowerState(response.getResult().trim()));
+        }
+        return response;
+    }
+
+    private OutOfBandManagementDriverResponse execute(final OutOfBandManagementDriverChangePasswordCommand cmd) {
+        final String outOfBandManagementUserId = getIpmiUserId(cmd.getOptions(), cmd.getTimeout());
+
+        final List<String> ipmiToolCommands = IPMITOOL.getIpmiToolCommandArgs(IpmiToolPath.value(),
+                IpmiToolInterface.value(), IpmiToolRetries.value(),
+                cmd.getOptions(), "user", "set", "password", outOfBandManagementUserId, cmd.getNewPassword());
+        return IPMITOOL.executeCommands(ipmiToolCommands, cmd.getTimeout());
+    }
+
+    private void initDriver() {
+        isDriverEnabled = true;
+        final OutOfBandManagementDriverResponse output = IPMITOOL.executeCommands(Arrays.asList(IpmiToolPath.value(), "-V"));
+        if (output.isSuccess() && output.getResult().startsWith("ipmitool version")) {
+            isIpmiToolBinAvailable = true;
+            LOG.debug("OutOfBandManagementDriver ipmitool initialized: " + output.getResult());
+        } else {
+            isIpmiToolBinAvailable = false;
+            LOG.error("OutOfBandManagementDriver ipmitool failed initialization with error: " + output.getError() + "; standard output: " + output.getResult());
+        }
+    }
+
+    private void stopDriver() {
+        isDriverEnabled = false;
+    }
+
+    @Override
+    public boolean start() {
+        initDriver();
+        return true;
+    }
+
+    @Override
+    public boolean stop() {
+        ipmitoolExecutor.shutdown();
+        stopDriver();
+        return true;
+    }
+
+    @Override
+    public String getConfigComponentName() {
+        return IpmitoolOutOfBandManagementDriver.class.getSimpleName();
+    }
+
+    @Override
+    public ConfigKey<?>[] getConfigKeys() {
+        return new ConfigKey<?>[] {IpmiToolPath, IpmiToolInterface, IpmiToolRetries};
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/plugins/outofbandmanagement-drivers/ipmitool/src/org/apache/cloudstack/outofbandmanagement/driver/ipmitool/IpmitoolWrapper.java
----------------------------------------------------------------------
diff --git a/plugins/outofbandmanagement-drivers/ipmitool/src/org/apache/cloudstack/outofbandmanagement/driver/ipmitool/IpmitoolWrapper.java b/plugins/outofbandmanagement-drivers/ipmitool/src/org/apache/cloudstack/outofbandmanagement/driver/ipmitool/IpmitoolWrapper.java
new file mode 100644
index 0000000..f5896b2
--- /dev/null
+++ b/plugins/outofbandmanagement-drivers/ipmitool/src/org/apache/cloudstack/outofbandmanagement/driver/ipmitool/IpmitoolWrapper.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.outofbandmanagement.driver.ipmitool;
+
+import com.cloud.utils.StringUtils;
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import org.apache.cloudstack.outofbandmanagement.OutOfBandManagement;
+import org.apache.cloudstack.outofbandmanagement.driver.OutOfBandManagementDriverResponse;
+import org.apache.cloudstack.utils.process.ProcessResult;
+import org.apache.cloudstack.utils.process.ProcessRunner;
+import org.apache.log4j.Logger;
+import org.joda.time.Duration;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+
+public final class IpmitoolWrapper {
+    public static final Logger LOG = Logger.getLogger(IpmitoolWrapper.class);
+
+    private final ProcessRunner RUNNER;
+
+    public IpmitoolWrapper(ExecutorService executor) {
+        this.RUNNER = new ProcessRunner(executor);
+    }
+
+    public String parsePowerCommand(OutOfBandManagement.PowerOperation operation) {
+        if (operation == null) {
+            throw new IllegalStateException("Invalid power operation requested");
+        }
+        switch (operation) {
+            case ON:
+            case OFF:
+            case CYCLE:
+            case RESET:
+            case SOFT:
+            case STATUS:
+                break;
+            default:
+                throw new IllegalStateException("Invalid power operation requested");
+        }
+        return operation.toString().toLowerCase();
+    }
+
+    public OutOfBandManagement.PowerState parsePowerState(final String standardOutput) {
+        if (Strings.isNullOrEmpty(standardOutput)) {
+            return OutOfBandManagement.PowerState.Unknown;
+        }
+        if (standardOutput.equals("Chassis Power is on")) {
+            return OutOfBandManagement.PowerState.On;
+        } else if (standardOutput.equals("Chassis Power is off")) {
+            return OutOfBandManagement.PowerState.Off;
+        }
+        return OutOfBandManagement.PowerState.Unknown;
+    }
+
+    public List<String> getIpmiToolCommandArgs(final String ipmiToolPath, final String ipmiInterface, final String retries,
+                                                      final ImmutableMap<OutOfBandManagement.Option, String> options, String... commands) {
+
+        final ImmutableList.Builder<String> ipmiToolCommands = ImmutableList.<String>builder()
+                                                            .add(ipmiToolPath)
+                                                            .add("-I")
+                                                            .add(ipmiInterface)
+                                                            .add("-R")
+                                                            .add(retries)
+                                                            .add("-v");
+
+        if (options != null) {
+            for (ImmutableMap.Entry<OutOfBandManagement.Option, String> option : options.entrySet()) {
+                switch (option.getKey()) {
+                    case ADDRESS:
+                        ipmiToolCommands.add("-H");
+                        break;
+                    case PORT:
+                        ipmiToolCommands.add("-p");
+                        break;
+                    case USERNAME:
+                        ipmiToolCommands.add("-U");
+                        break;
+                    case PASSWORD:
+                        ipmiToolCommands.add("-P");
+                        break;
+                    default:
+                        continue;
+                }
+                ipmiToolCommands.add(option.getValue());
+            }
+        }
+        for (String command : commands) {
+            ipmiToolCommands.add(command);
+        }
+        return ipmiToolCommands.build();
+    }
+
+    public String findIpmiUser(final String usersList, final String username) {
+        /**
+         * Expected usersList string contains legends on first line and users on rest
+         * ID Name  Callin Link Auth IPMI Msg Channel Priv Limit
+         * 1  admin true   true true ADMINISTRATOR
+         */
+
+        // Assuming user 'ID' index on 1st position
+        int idIndex = 0;
+
+        // Assuming  user 'Name' index on 2nd position
+        int usernameIndex = 1;
+
+        final String[] lines = usersList.split("\\r?\\n");
+        if (lines.length < 2) {
+            throw new CloudRuntimeException("Error parsing user ID from ipmi user listing");
+        }
+        // Find user and name indexes from the 1st line if not on default position
+        final String[] legends = lines[0].split(" +");
+        for (int idx = 0; idx < legends.length; idx++) {
+            if (legends[idx].equals("ID")) {
+                idIndex = idx;
+            }
+            if (legends[idx].equals("Name")) {
+                usernameIndex = idx;
+            }
+        }
+        // Find user 'ID' based on provided username and ID/Name positions
+        String userId = null;
+        for (int idx = 1; idx < lines.length; idx++) {
+            final String[] words = lines[idx].split(" +");
+            if (usernameIndex < words.length && idIndex < words.length) {
+                if (words[usernameIndex].equals(username)) {
+                    userId = words[idIndex];
+                }
+            }
+        }
+        return userId;
+    }
+
+    public OutOfBandManagementDriverResponse executeCommands(final List<String> commands) {
+        return executeCommands(commands, ProcessRunner.DEFAULT_MAX_TIMEOUT);
+    }
+
+    public OutOfBandManagementDriverResponse executeCommands(final List<String> commands, final Duration timeOut) {
+        final ProcessResult result = RUNNER.executeCommands(commands, timeOut);
+        if (LOG.isTraceEnabled()) {
+            List<String> cleanedCommands = new ArrayList<String>();
+            int maskNextCommand = 0;
+            for (String command : commands) {
+                if (maskNextCommand > 0) {
+                    cleanedCommands.add("**** ");
+                    maskNextCommand--;
+                    continue;
+                }
+                if (command.equalsIgnoreCase("-P")) {
+                    maskNextCommand = 1;
+                } else if (command.toLowerCase().endsWith("password")) {
+                    maskNextCommand = 2;
+                }
+                cleanedCommands.add(command);
+            }
+            LOG.trace("Executed ipmitool process with commands: " + StringUtils.join(cleanedCommands, ", ") +
+                      "\nIpmitool execution standard output: " + result.getStdOutput() +
+                      "\nIpmitool execution error output: " + result.getStdError());
+        }
+        return new OutOfBandManagementDriverResponse(result.getStdOutput(), result.getStdError(), result.isSuccess());
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/plugins/outofbandmanagement-drivers/ipmitool/test/org/apache/cloudstack/outofbandmanagement/driver/ipmitool/IpmitoolWrapperTest.java
----------------------------------------------------------------------
diff --git a/plugins/outofbandmanagement-drivers/ipmitool/test/org/apache/cloudstack/outofbandmanagement/driver/ipmitool/IpmitoolWrapperTest.java b/plugins/outofbandmanagement-drivers/ipmitool/test/org/apache/cloudstack/outofbandmanagement/driver/ipmitool/IpmitoolWrapperTest.java
new file mode 100644
index 0000000..86eff86
--- /dev/null
+++ b/plugins/outofbandmanagement-drivers/ipmitool/test/org/apache/cloudstack/outofbandmanagement/driver/ipmitool/IpmitoolWrapperTest.java
@@ -0,0 +1,115 @@
+//
+// 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.driver.ipmitool;
+
+import com.cloud.utils.concurrency.NamedThreadFactory;
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.google.common.collect.ImmutableMap;
+import org.apache.cloudstack.outofbandmanagement.OutOfBandManagement;
+import org.apache.cloudstack.outofbandmanagement.driver.OutOfBandManagementDriverResponse;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@RunWith(MockitoJUnitRunner.class)
+public class IpmitoolWrapperTest {
+
+    private static final ExecutorService ipmitoolExecutor = Executors.newFixedThreadPool(20, new NamedThreadFactory("IpmiToolDriverTest"));
+    private static final IpmitoolWrapper IPMITOOL = new IpmitoolWrapper(ipmitoolExecutor);
+
+    @Test
+    public void testParsePowerCommandValid() {
+        Assert.assertEquals(IPMITOOL.parsePowerCommand(OutOfBandManagement.PowerOperation.ON), "on");
+        Assert.assertEquals(IPMITOOL.parsePowerCommand(OutOfBandManagement.PowerOperation.OFF), "off");
+        Assert.assertEquals(IPMITOOL.parsePowerCommand(OutOfBandManagement.PowerOperation.CYCLE), "cycle");
+        Assert.assertEquals(IPMITOOL.parsePowerCommand(OutOfBandManagement.PowerOperation.RESET), "reset");
+        Assert.assertEquals(IPMITOOL.parsePowerCommand(OutOfBandManagement.PowerOperation.SOFT), "soft");
+        Assert.assertEquals(IPMITOOL.parsePowerCommand(OutOfBandManagement.PowerOperation.STATUS), "status");
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void testParsePowerCommandInvalid() {
+        IPMITOOL.parsePowerCommand(null);
+        Assert.fail("IpmitoolWrapper.parsePowerCommand failed to throw exception on invalid power state");
+    }
+
+    @Test
+    public void testParsePowerState() {
+        Assert.assertEquals(IPMITOOL.parsePowerState(null), OutOfBandManagement.PowerState.Unknown);
+        Assert.assertEquals(IPMITOOL.parsePowerState(""), OutOfBandManagement.PowerState.Unknown);
+        Assert.assertEquals(IPMITOOL.parsePowerState(" "), OutOfBandManagement.PowerState.Unknown);
+        Assert.assertEquals(IPMITOOL.parsePowerState("invalid data"), OutOfBandManagement.PowerState.Unknown);
+        Assert.assertEquals(IPMITOOL.parsePowerState("Chassis Power is on"), OutOfBandManagement.PowerState.On);
+        Assert.assertEquals(IPMITOOL.parsePowerState("Chassis Power is off"), OutOfBandManagement.PowerState.Off);
+    }
+
+    @Test
+    public void testGetIpmiToolCommandArgs() {
+        List<String> args = IPMITOOL.getIpmiToolCommandArgs("binpath", "intf", "1", null);
+        assert args != null;
+        Assert.assertEquals(args.size(), 6);
+        Assert.assertArrayEquals(args.toArray(), new String[]{"binpath", "-I", "intf", "-R", "1", "-v"});
+
+        ImmutableMap.Builder<OutOfBandManagement.Option, String> argMap = new ImmutableMap.Builder<>();
+        argMap.put(OutOfBandManagement.Option.DRIVER, "ipmitool");
+        argMap.put(OutOfBandManagement.Option.ADDRESS, "127.0.0.1");
+        List<String> argsWithOpts = IPMITOOL.getIpmiToolCommandArgs("binpath", "intf", "1", argMap.build(), "user", "list");
+        assert argsWithOpts != null;
+        Assert.assertEquals(argsWithOpts.size(), 10);
+        Assert.assertArrayEquals(argsWithOpts.toArray(), new String[]{"binpath", "-I", "intf", "-R", "1", "-v", "-H", "127.0.0.1", "user", "list"});
+    }
+
+    @Test(expected = CloudRuntimeException.class)
+    public void testFindIpmiUserInvalid() {
+        IPMITOOL.findIpmiUser("some invalid string\n", "admin");
+        Assert.fail("IpmitoolWrapper.findIpmiUser failed to throw exception on invalid data");
+
+        Assert.assertEquals(IPMITOOL.findIpmiUser("some\ninvalid\ndata\n", "admin"), null);
+    }
+
+    @Test
+    public void testFindIpmiUserNull() {
+        Assert.assertEquals(IPMITOOL.findIpmiUser("some\ninvalid\ndata\n", "admin"), null);
+    }
+
+    @Test
+    public void testFindIpmiUserValid() {
+        String usersList = "ID  Name\t     Callin  Link Auth\tIPMI Msg   Channel Priv Limit\n" +
+                           "1   admin            true    true       true       ADMINISTRATOR\n" +
+                           "2   operator         true    false      false      OPERATOR\n" +
+                           "3   user             true    true       true       USER\n";
+        Assert.assertEquals(IPMITOOL.findIpmiUser(usersList, "admin"), "1");
+        Assert.assertEquals(IPMITOOL.findIpmiUser(usersList, "operator"), "2");
+        Assert.assertEquals(IPMITOOL.findIpmiUser(usersList, "user"), "3");
+    }
+
+    @Test
+    public void testExecuteCommands() {
+        OutOfBandManagementDriverResponse r = IPMITOOL.executeCommands(Arrays.asList("ls", "/tmp"));
+        Assert.assertTrue(r.isSuccess());
+        Assert.assertTrue(r.getResult().length() > 0);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/plugins/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/pom.xml b/plugins/pom.xml
index 1a25819..25f0687 100755
--- a/plugins/pom.xml
+++ b/plugins/pom.xml
@@ -80,6 +80,7 @@
     <module>network-elements/midonet</module>
     <module>network-elements/stratosphere-ssp</module>
     <module>network-elements/opendaylight</module>
+    <module>outofbandmanagement-drivers/ipmitool</module>
     <module>storage-allocators/random</module>
     <module>user-authenticators/ldap</module>
     <module>user-authenticators/md5</module>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
----------------------------------------------------------------------
diff --git a/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml b/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
index 6618e3e..b25c1c3 100644
--- a/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
+++ b/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
@@ -142,6 +142,10 @@
 
     <bean id="oCFS2ManagerImpl" class="com.cloud.storage.OCFS2ManagerImpl" />
 
+    <bean id="outOfBandManagementServiceImpl" class="org.apache.cloudstack.outofbandmanagement.OutOfBandManagementServiceImpl">
+        <property name="outOfBandManagementDrivers" value="#{outOfBandManagementDriversRegistry.registered}" />
+    </bean>
+
     <bean id="projectManagerImpl" class="com.cloud.projects.ProjectManagerImpl" />
 
     <bean id="queryManagerImpl" class="com.cloud.api.query.QueryManagerImpl" />

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/server/src/com/cloud/alert/AlertManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/alert/AlertManagerImpl.java b/server/src/com/cloud/alert/AlertManagerImpl.java
index 9b9802a..e18d231 100644
--- a/server/src/com/cloud/alert/AlertManagerImpl.java
+++ b/server/src/com/cloud/alert/AlertManagerImpl.java
@@ -758,7 +758,8 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
                 (alertType != AlertManager.AlertType.ALERT_TYPE_STORAGE_MISC) &&
                 (alertType != AlertManager.AlertType.ALERT_TYPE_MANAGMENT_NODE) &&
                 (alertType != AlertManager.AlertType.ALERT_TYPE_RESOURCE_LIMIT_EXCEEDED) &&
-                (alertType != AlertManager.AlertType.ALERT_TYPE_UPLOAD_FAILED)) {
+                (alertType != AlertManager.AlertType.ALERT_TYPE_UPLOAD_FAILED) &&
+                (alertType != AlertManager.AlertType.ALERT_TYPE_OOBM_AUTH_ERROR)) {
                 alert = _alertDao.getLastAlert(alertType.getType(), dataCenterId, podId, clusterId);
             }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index 1c25644..39ac5c4 100644
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -191,6 +191,7 @@ import com.cloud.configuration.Resource.ResourceOwnerType;
 import com.cloud.configuration.Resource.ResourceType;
 import com.cloud.configuration.ResourceCount;
 import com.cloud.configuration.ResourceLimit;
+import com.cloud.dc.ClusterDetailsDao;
 import com.cloud.dc.ClusterVO;
 import com.cloud.dc.DataCenter;
 import com.cloud.dc.HostPodVO;
@@ -342,6 +343,8 @@ public class ApiResponseHelper implements ResponseGenerator {
     private SnapshotDataStoreDao _snapshotStoreDao;
     @Inject
     private PrimaryDataStoreDao _storagePoolDao;
+    @Inject
+    private ClusterDetailsDao _clusterDetailsDao;
 
     @Override
     public UserResponse createUserResponse(User user) {
@@ -1053,6 +1056,7 @@ public class ApiResponseHelper implements ResponseGenerator {
         String memoryOvercommitRatio = ApiDBUtils.findClusterDetails(cluster.getId(), "memoryOvercommitRatio");
         clusterResponse.setCpuOvercommitRatio(cpuOvercommitRatio);
         clusterResponse.setMemoryOvercommitRatio(memoryOvercommitRatio);
+        clusterResponse.setResourceDetails(_clusterDetailsDao.findDetails(cluster.getId()));
 
         if (showCapacities != null && showCapacities) {
             List<SummedCapacity> capacities = ApiDBUtils.getCapacityByClusterPodZone(null, null, cluster.getId());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07564469/server/src/com/cloud/api/query/QueryManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/QueryManagerImpl.java b/server/src/com/cloud/api/query/QueryManagerImpl.java
index 781b195..3cdd4bb 100644
--- a/server/src/com/cloud/api/query/QueryManagerImpl.java
+++ b/server/src/com/cloud/api/query/QueryManagerImpl.java
@@ -1577,6 +1577,8 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
         Object cluster = cmd.getClusterId();
         Object id = cmd.getId();
         Object keyword = cmd.getKeyword();
+        Object outOfBandManagementEnabled = cmd.isOutOfBandManagementEnabled();
+        Object powerState = cmd.getHostOutOfBandManagementPowerState();
         Object resourceState = cmd.getResourceState();
         Object haHosts = cmd.getHaHost();
         Long startIndex = cmd.getStartIndex();
@@ -1595,6 +1597,8 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
         sb.and("dataCenterId", sb.entity().getZoneId(), SearchCriteria.Op.EQ);
         sb.and("podId", sb.entity().getPodId(), SearchCriteria.Op.EQ);
         sb.and("clusterId", sb.entity().getClusterId(), SearchCriteria.Op.EQ);
+        sb.and("oobmEnabled", sb.entity().isOutOfBandManagementEnabled(), SearchCriteria.Op.EQ);
+        sb.and("powerState", sb.entity().getOutOfBandManagementPowerState(), SearchCriteria.Op.EQ);
         sb.and("resourceState", sb.entity().getResourceState(), SearchCriteria.Op.EQ);
         sb.and("hypervisor_type", sb.entity().getHypervisorType(), SearchCriteria.Op.EQ);
 
@@ -1644,6 +1648,14 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
             sc.setParameters("clusterId", cluster);
         }
 
+        if (outOfBandManagementEnabled != null) {
+            sc.setParameters("oobmEnabled", outOfBandManagementEnabled);
+        }
+
+        if (powerState != null) {
+            sc.setParameters("powerState", powerState);
+        }
+
         if (resourceState != null) {
             sc.setParameters("resourceState", resourceState);
         }


Mime
View raw message