From tashi-commits-return-193-apmail-incubator-tashi-commits-archive=incubator.apache.org@incubator.apache.org Tue Nov 30 18:31:47 2010 Return-Path: Delivered-To: apmail-incubator-tashi-commits-archive@minotaur.apache.org Received: (qmail 53091 invoked from network); 30 Nov 2010 18:31:47 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 30 Nov 2010 18:31:47 -0000 Received: (qmail 9480 invoked by uid 500); 30 Nov 2010 18:31:47 -0000 Delivered-To: apmail-incubator-tashi-commits-archive@incubator.apache.org Received: (qmail 9453 invoked by uid 500); 30 Nov 2010 18:31:47 -0000 Mailing-List: contact tashi-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: tashi-dev@incubator.apache.org Delivered-To: mailing list tashi-commits@incubator.apache.org Received: (qmail 9445 invoked by uid 99); 30 Nov 2010 18:31:47 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Nov 2010 18:31:47 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Nov 2010 18:31:47 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 6A79D23888EA; Tue, 30 Nov 2010 18:30:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1040676 - /incubator/tashi/branches/zoni-dev/trunk/src/zoni/hardware/systemmanagement.py Date: Tue, 30 Nov 2010 18:30:15 -0000 To: tashi-commits@incubator.apache.org From: rgass@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101130183015.6A79D23888EA@eris.apache.org> Author: rgass Date: Tue Nov 30 18:30:15 2010 New Revision: 1040676 URL: http://svn.apache.org/viewvc?rev=1040676&view=rev Log: Initial revision of wrapper for hardware control. Added: incubator/tashi/branches/zoni-dev/trunk/src/zoni/hardware/systemmanagement.py (with props) Added: incubator/tashi/branches/zoni-dev/trunk/src/zoni/hardware/systemmanagement.py URL: http://svn.apache.org/viewvc/incubator/tashi/branches/zoni-dev/trunk/src/zoni/hardware/systemmanagement.py?rev=1040676&view=auto ============================================================================== --- incubator/tashi/branches/zoni-dev/trunk/src/zoni/hardware/systemmanagement.py (added) +++ incubator/tashi/branches/zoni-dev/trunk/src/zoni/hardware/systemmanagement.py Tue Nov 30 18:30:15 2010 @@ -0,0 +1,98 @@ +#!/usr/bin/env python +# 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. +# +# $Id$ +# + +import sys +import os +import logging + +from systemmanagementinterface import SystemManagementInterface +from zoni.data.resourcequerysql import * + +from tashi.util import instantiateImplementation + + +class SystemManagement(SystemManagementInterface): + + def __init__(self, config, data): + self.config = config + self.data = data + self.verbose = False + self.host = "" + self.log = logging.getLogger(__name__) + + + def getInfo(self, nodeName): + self.host = self.data.getHostInfo(node) + + + def setVerbose(self, verbose): + self.verbose = verbose + + def __getHostInfo(self, nodeName): + return self.data.getHostInfo(nodeName)#, data.getHardwareCapabilities(nodeName)) + + def getPowerStatus(self, nodeName): + return self.__iterateHardware(nodeName, "getPowerStatus") + + def __iterateHardware(self, nodeName, cmd, *args): + retries = 2 + print "cmd ", cmd, "args", args + mycmd = "%s()" % (cmd) + self.host = self.__getHostInfo(nodeName) + hw = self.data.getHardwareCapabilities(nodeName) + # getHardwareCapabilities return a list of lists with + # [0] = hw method + # [1] = hw method userid + # [2] = hw method password + for i in hw: + inst = instantiateImplementation(self.config['hardwareControl'][i[0]]['class'], self.config, nodeName, self.host) + a = "inst.%s" % mycmd + for count in range(retries): + doit = eval(a) + if doit == -1: + self.log.error("%s method failed (%s) on %s (attempt %s)", i[0], mycmd, nodeName, count) + continue + if doit > 0: + break + else: + self.log.error("%s method failed (%s) on %s (attempt %s)", i[0], mycmd, nodeName, count) + if doit > 0: + break + + return doit + + def runCmd(self, nodeName, cmd, *args): + self.__iterateHardware(nodeName, cmd, args) + + def powerOn(self, nodeName): + self.__iterateHardware(nodeName, "powerOn") + + def powerOff(self, nodeName): + self.__iterateHardware(nodeName, "powerOff") + + def powerCycle(self, nodeName): + self.__iterateHardware(nodeName, "powerCycle") + + def powerReset(self, nodeName): + self.__iterateHardware(nodeName, "powerReset") + + def activateConsole(self, nodeName): + pass Propchange: incubator/tashi/branches/zoni-dev/trunk/src/zoni/hardware/systemmanagement.py ------------------------------------------------------------------------------ svn:keywords = Id