From a1df248e34f1c3a566df558ca300cee1bf9ff3da Mon Sep 17 00:00:00 2001 From: Vincent Thomas Date: Thu, 25 Sep 2008 12:07:52 +0200 Subject: [PATCH] Script pour deconnecter les agregatifs sur leur demande darcs-hash:20080925100752-3821b-5156010b43478a516c062feb34d4dee52a3d2ec9.gz --- utils/chambre-on-off.py | 43 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 utils/chambre-on-off.py diff --git a/utils/chambre-on-off.py b/utils/chambre-on-off.py new file mode 100755 index 00000000..e9307bae --- /dev/null +++ b/utils/chambre-on-off.py @@ -0,0 +1,43 @@ +#! /usr/bin/env python +# -*- coding: iso-8859-15 -*- + +# syntaxe : chambre-on-off.py A101d on +# chambre-on-off.py A101d off + +import sys +sys.path.append("/usr/scripts/gestion/") + +# recherche des coordonnées de la chambre +from annuaires import chbre_prises +chbre = sys.argv[1].lower() +bat = chbre[0] +prise = int(chbre_prises[bat][chbre[1:]][1:]) +switch = "bat" + bat + "-" + chbre_prises[bat][chbre[1:]][0] +cmd = sys.argv[2].lower() + +# connecion au switch +from hptools import hpswitch +sw = hpswitch(switch) + +# affichage des infos +print "chbre : " + chbre +print "switch : " + switch +print "prise : " + str(prise) +if sw.is_enable(prise): + print "old statut : on" +else: + print "old statut : off" + +# modification du statut +if cmd == "off": + print "action : disable" + sw.disable(prise) +else: + print "action : enable" + sw.enable(prise) + +# affichage du nouveau statut +if sw.is_enable(prise): + print "new statut : on" +else: + print "new statut : off"