[
https://issues.apache.org/jira/browse/CLOUDSTACK-9299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15267330#comment-15267330
]
ASF GitHub Bot commented on CLOUDSTACK-9299:
--------------------------------------------
Github user jburwell commented on a diff in the pull request:
https://github.com/apache/cloudstack/pull/1502#discussion_r61789411
--- Diff:
plugins/outofbandmanagement-drivers/ipmitool/src/org/apache/cloudstack/outofbandmanagement/driver/ipmitool/IpmitoolWrapper.java
---
@@ -0,0 +1,166 @@
+// 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.ProcessRunner;
+import org.apache.log4j.Logger;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class IpmitoolWrapper {
+ public static final Logger LOG =
Logger.getLogger(IpmitoolWrapper.class);
+
+ public static 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 static 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 static List<String> getIpmiToolCommandArgs(final String
ipmiToolPath, final String ipmiInterface, final String retries,
+ final
ImmutableMap<OutOfBandManagement.Option, String> options, String... commands) {
+
+ 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 static 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
--- End diff --
Move this documentation to Javadoc for the method.
> Out-of-band Management for CloudStack
> -------------------------------------
>
> Key: CLOUDSTACK-9299
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9299
> Project: CloudStack
> Issue Type: New Feature
> Security Level: Public(Anyone can view this level - this is the
> default.)
> Reporter: Rohit Yadav
> Assignee: Rohit Yadav
> Fix For: 4.9.0, Future
>
>
> 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.
> FS:
> https://cwiki.apache.org/confluence/display/CLOUDSTACK/Out-of-band+Management+for+CloudStack
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)