scripts/utils/chambre-on-off.py
Vincent Thomas a1df248e34 Script pour deconnecter les agregatifs sur leur demande
darcs-hash:20080925100752-3821b-5156010b43478a516c062feb34d4dee52a3d2ec9.gz
2008-09-25 12:07:52 +02:00

43 lines
1,004 B
Python
Executable file

#! /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"