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 4346D2009D9 for ; Tue, 3 May 2016 00:29:16 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 41C981602C5; Tue, 3 May 2016 00:29:16 +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 3BDE71609B2 for ; Tue, 3 May 2016 00:29:15 +0200 (CEST) Received: (qmail 45728 invoked by uid 500); 2 May 2016 22:29: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 45581 invoked by uid 500); 2 May 2016 22:29:13 -0000 Delivered-To: apmail-incubator-cloudstack-issues@incubator.apache.org Received: (qmail 45526 invoked by uid 99); 2 May 2016 22:29:13 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 May 2016 22:29:13 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 57CBB2C1F61 for ; Mon, 2 May 2016 22:29:13 +0000 (UTC) Date: Mon, 2 May 2016 22:29:13 +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: Mon, 02 May 2016 22:29:16 -0000 [ https://issues.apache.org/jira/browse/CLOUDSTACK-9299?page=3Dcom.atla= ssian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId= =3D15267631#comment-15267631 ]=20 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_r61816081 =20 --- Diff: test/integration/smoke/test_outofbandmanagement.py --- @@ -0,0 +1,561 @@ +# 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. + + +import marvin +from marvin.cloudstackTestCase import * +from marvin.cloudstackAPI import * +from marvin.lib.utils import * +from marvin.lib.base import * +from marvin.lib.common import * +from marvin.lib.utils import (random_gen) +from nose.plugins.attrib import attr + +from ipmisim.ipmisim import IpmiServerContext, IpmiServer, ThreadedIpm= iServer + +import socket +import sys +import thread +import time + + +class TestOutOfBandManagement(cloudstackTestCase): + """ Test cases for out of band management + """ + + def setUp(self): + self.apiclient =3D self.testClient.getApiClient() + self.hypervisor =3D self.testClient.getHypervisorInfo() + self.dbclient =3D self.testClient.getDbConnection() + self.services =3D self.testClient.getParsedTestDataConfig() + self.mgtSvrDetails =3D self.config.__dict__["mgtSvr"][0].__dic= t__ + + self.zone =3D get_zone(self.apiclient, self.testClient.getZone= ForTests()) + self.host =3D None + self.server =3D None + + # use random port for ipmisim + s =3D socket.socket() + s.bind(('', 0)) + self.serverPort =3D s.getsockname()[1] + s.close() + + self.cleanup =3D [] + + + def tearDown(self): + try: + self.dbclient.execute("delete from oobm where port=3D%d" %= self.getIpmiServerPort()) + self.dbclient.execute("delete from mshost_peer where peer_= runid=3D%s" % self.getFakeMsRunId()) + self.dbclient.execute("delete from mshost where runid=3D%s= " % self.getFakeMsRunId()) + self.dbclient.execute("delete from cluster_details where n= ame=3D'outOfBandManagementEnabled'") + self.dbclient.execute("delete from data_center_details whe= re name=3D'outOfBandManagementEnabled'") + cleanup_resources(self.apiclient, self.cleanup) + if self.server: + self.server.shutdown() + self.server.server_close() + except Exception as e: + raise Exception("Warning: Exception during cleanup : %s" %= e) + + + def getFakeMsId(self): + return 1234567890 + + + def getFakeMsRunId(self): + return 123456 + + + def getHost(self, hostId=3DNone): + if self.host and hostId is None: + return self.host + + response =3D list_hosts( + self.apiclient, + zoneid=3Dself.zone.id, + type=3D'Routing', + id=3DhostId + ) + if len(response) > 0: + self.host =3D response[0] + return self.host + raise self.skipTest("No hosts found, skipping out-of-band mana= gement test") + + + def getIpmiServerIp(self): + s =3D socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + s.connect((self.mgtSvrDetails["mgtSvrIp"], self.mgtSvrDetails[= "port"])) + return s.getsockname()[0] + + + def getIpmiServerPort(self): + return self.serverPort + + + def getOobmConfigCmd(self): + cmd =3D configureOutOfBandManagement.configureOutOfBandManagem= entCmd() + cmd.driver =3D 'ipmitool' # The default available driver + cmd.address =3D self.getIpmiServerIp() + cmd.port =3D self.getIpmiServerPort() + cmd.username =3D 'admin' + cmd.password =3D 'password' + cmd.hostid =3D self.getHost().id + return cmd + + + def getOobmEnableCmd(self): + cmd =3D enableOutOfBandManagementForHost.enableOutOfBandManage= mentForHostCmd() + cmd.hostid =3D self.getHost().id + return cmd + + + def getOobmDisableCmd(self): + cmd =3D disableOutOfBandManagementForHost.disableOutOfBandMana= gementForHostCmd() + cmd.hostid =3D self.getHost().id + return cmd + + + def getOobmIssueActionCmd(self): + cmd =3D issueOutOfBandManagementPowerAction.issueOutOfBandMana= gementPowerActionCmd() + cmd.hostid =3D self.getHost().id + cmd.action =3D 'STATUS' + return cmd + + + def issuePowerActionCmd(self, action, timeout=3DNone): + cmd =3D self.getOobmIssueActionCmd() + cmd.action =3D action + if timeout: + cmd.timeout =3D timeout + return self.apiclient.issueOutOfBandManagementPowerAction(cmd) + + + def configureAndEnableOobm(self): + self.apiclient.configureOutOfBandManagement(self.getOobmConfig= Cmd()) + response =3D self.apiclient.enableOutOfBandManagementForHost(s= elf.getOobmEnableCmd()) + self.assertEqual(response.enabled, True) + + + def startIpmiServer(self): + def startIpmiServer(tname, server): + self.debug("Starting ipmisim server") + try: + server.serve_forever() + except Exception: pass + IpmiServerContext('reset') + ThreadedIpmiServer.allow_reuse_address =3D False + server =3D ThreadedIpmiServer(('0.0.0.0', self.getIpmiServerPo= rt()), IpmiServer) + thread.start_new_thread(startIpmiServer, ("ipmi-server", serve= r,)) + self.server =3D server + + + def checkSyncToState(self, state, interval): + self.debug("Waiting for background thread to update powerstate= to " + state) + time.sleep(1 + int(interval)*2/1000) # interval is in ms + response =3D self.getHost(hostId=3Dself.getHost().id).outofban= dmanagement + self.assertEqual(response.powerstate, state) + + + @attr(tags=3D["smoke", "advanced"]) + def test_oobm_configure_invalid_driver(self): + """ + Tests out-of-band management configuration with invalid dr= iver + """ + cmd =3D self.getOobmConfigCmd() + cmd.driver =3D 'randomDriverThatDoesNotExist' + try: + response =3D self.apiclient.configureOutOfBandManagement(c= md) + self.fail("Expected an exception to be thrown, failing") + except Exception: pass + + + @attr(tags=3D["smoke", "advanced"]) + def test_oobm_configure_default_driver(self): + """ + Tests out-of-band management configuration with valid data + """ + cmd =3D self.getOobmConfigCmd() + response =3D self.apiclient.configureOutOfBandManagement(cmd) + self.assertEqual(response.hostid, cmd.hostid) + self.assertEqual(response.driver, cmd.driver) + self.assertEqual(response.address, cmd.address) + self.assertEqual(response.port, str(cmd.port)) + self.assertEqual(response.username, cmd.username) + + + @attr(tags=3D["smoke", "advanced"]) + def test_oobm_enable_feature_invalid(self): + """ + Tests out-of-band management host enable feature with + invalid options + """ + cmd =3D self.getOobmEnableCmd() + cmd.hostid =3D -1 + try: + response =3D self.apiclient.enableOutOfBandManagementForHo= st(cmd) + self.fail("Expected an exception to be thrown, failing") + except Exception: pass + + try: + cmd =3D enableOutOfBandManagementForCluster.enableOutOfBan= dManagementForClusterCmd() + response =3D self.apiclient.enableOutOfBandManagementForCl= uster(cmd) + self.fail("Expected an exception to be thrown, failing") + except Exception: pass + + try: + cmd =3D enableOutOfBandManagementForZone.enableOutOfBandMa= nagementForZoneCmd() + response =3D self.apiclient.enableOutOfBandManagementForZo= ne(cmd) + self.fail("Expected an exception to be thrown, failing") + except Exception: pass + + + @attr(tags=3D["smoke", "advanced"]) + def test_oobm_disable_feature_invalid(self): + """ + Tests out-of-band management host disable feature with + invalid options + """ + cmd =3D self.getOobmDisableCmd() + cmd.hostid =3D -1 + try: + response =3D self.apiclient.disableOutOfBandManagementForH= ost(cmd) + self.fail("Expected an exception to be thrown, failing") + except Exception: pass + + try: + cmd =3D disableOutOfBandManagementForCluster.disableOutOfB= andManagementForClusterCmd() + response =3D self.apiclient.disableOutOfBandManagementForC= luster(cmd) + self.fail("Expected an exception to be thrown, failing") + except Exception: pass + + try: + cmd =3D disableOutOfBandManagementForZone.disableOutOfBand= ManagementForZoneCmd() + response =3D self.apiclient.disableOutOfBandManagementForZ= one(cmd) + self.fail("Expected an exception to be thrown, failing") + except Exception: pass + + + @attr(tags=3D["smoke", "advanced"]) + def test_oobm_enable_feature_valid(self): + """ + Tests out-of-band management host enable feature with + valid options + """ + self.apiclient.configureOutOfBandManagement(self.getOobmConfig= Cmd()) + cmd =3D self.getOobmEnableCmd() + response =3D self.apiclient.enableOutOfBandManagementForHost(c= md) + self.assertEqual(response.hostid, cmd.hostid) + self.assertEqual(response.enabled, True) + + + @attr(tags=3D["smoke", "advanced"]) + def test_oobm_disable_feature_valid(self): + """ + Tests out-of-band management host disable feature with + valid options + """ + + self.apiclient.configureOutOfBandManagement(self.getOobmConfig= Cmd()) + cmd =3D self.getOobmDisableCmd() + response =3D self.apiclient.disableOutOfBandManagementForHost(= cmd) + self.assertEqual(response.hostid, cmd.hostid) + self.assertEqual(response.enabled, False) + + response =3D self.getHost(hostId=3Dcmd.hostid).outofbandmanage= ment + self.assertEqual(response.powerstate, 'Disabled') + + + @attr(tags=3D["smoke", "advanced"]) + def test_oobm_enabledisable_across_clusterzones(self): --- End diff -- =20 Could this method be separated for zone, cluster, and host? It seems l= ike it would make the test case more readable. > 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)