Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 96B8A200ABF for ; Tue, 3 May 2016 09:25:14 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 953AE1609F3; Tue, 3 May 2016 09:25:14 +0200 (CEST) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id BA11F1609F2 for ; Tue, 3 May 2016 09:25:13 +0200 (CEST) Received: (qmail 59235 invoked by uid 500); 3 May 2016 07:25:13 -0000 Mailing-List: contact issues-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list issues@cloudstack.apache.org Received: (qmail 59226 invoked by uid 500); 3 May 2016 07:25:12 -0000 Delivered-To: apmail-incubator-cloudstack-issues@incubator.apache.org Received: (qmail 59221 invoked by uid 99); 3 May 2016 07:25:12 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 May 2016 07:25:12 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id CE1762C14F9 for ; Tue, 3 May 2016 07:25:12 +0000 (UTC) Date: Tue, 3 May 2016 07:25:12 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: cloudstack-issues@incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CLOUDSTACK-9299) Out-of-band Management for CloudStack MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 03 May 2016 07:25:14 -0000 [ https://issues.apache.org/jira/browse/CLOUDSTACK-9299?page=3Dcom.atla= ssian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId= =3D15268272#comment-15268272 ]=20 ASF GitHub Bot commented on CLOUDSTACK-9299: -------------------------------------------- Github user rhtyd commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1502#discussion_r61845867 =20 --- Diff: plugins/outofbandmanagement-drivers/ipmitool/src/org/apache/c= loudstack/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.OutOfBandManag= ementDriverResponse; +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 =3D Logger.getLogger(IpmitoolWrappe= r.class); + + public static String parsePowerCommand(OutOfBandManagement.PowerOp= eration operation) { + if (operation =3D=3D null) { + throw new IllegalStateException("Invalid power operation r= equested"); + } + switch (operation) { + case ON: + case OFF: + case CYCLE: + case RESET: + case SOFT: + case STATUS: + break; + default: + throw new IllegalStateException("Invalid power operati= on 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 getIpmiToolCommandArgs(final String ipm= iToolPath, final String ipmiInterface, final String retries, + final ImmutableM= ap options, String... commands) { + + ImmutableList.Builder ipmiToolCommands =3D ImmutableLi= st.builder() + .add(ipmiT= oolPath) + .add("-I") + .add(ipmiI= nterface) + .add("-R") + .add(retri= es) + .add("-v")= ; + + if (options !=3D null) { + for (ImmutableMap.Entry 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 St= ring username) { + // Expected usersList string contains legends on first line an= d users on rest + // ID Name Callin Link Auth IPMI Msg Channel Priv Limit + // 1 admin true true true ADMINISTRATOR --- End diff -- =20 Fixed > Out-of-band Management for CloudStack > ------------------------------------- > > Key: CLOUDSTACK-9299 > URL: https://issues.apache.org/jira/browse/CLOUDSTACK-929= 9 > Project: CloudStack > Issue Type: New Feature > Security Level: Public(Anyone can view this level - this is the defa= ult.)=20 > Reporter: Rohit Yadav > Assignee: Rohit Yadav > Fix For: 4.9.0, Future > > > Support access to a host=E2=80=99s out-of-band management interface (e.g.= IPMI, iLO, DRAC, etc.) to manage host power operations (on/off etc.) and q= uerying current power state. > FS: https://cwiki.apache.org/confluence/display/CLOUDSTACK/Out-of-band+Ma= nagement+for+CloudStack -- This message was sent by Atlassian JIRA (v6.3.4#6332)