scripts/adm/chambre
Antoine Durand-Gasselin 4a68475e34 [wiki-lenny] suppression de static/
darcs-hash:20090314092631-bd074-b01256aeaf71e935851b3ecdbd623eaae8c9e8a1.gz
2009-03-14 10:26:31 +01:00

43 lines
878 B
Python

#! /usr/bin/env python
# -*- coding: iso8859-15 -*-
"""
Activation et désactivation d'une chambre
prise [chambre] [on|off]
"""
import sys, os
sys.path.append('/usr/scripts/gestion')
from annuaires import chbre_prises
from hptools import hpswitch
if len(sys.argv)!=3 or not sys.argv[2] in ['on','off']:
print "Syntaxe : chambre X### on|off"
sys.exit(1)
# détermination de la chambre
bat = sys.argv[1][0].lower()
chbre = sys.argv[1][1:].lower()
# determination de la prise sur le switch
prise = chbre_prises[bat][chbre]
switch = prise[0]
prise = prise[1:]
# connection au switch
sw = hpswitch( 'bat%s-%s.adm.crans.org'%(bat,switch) )
etat = sys.argv[2].lower()
# action
if etat == 'on':
sw.enable(prise)
elif etat == 'off':
sw.disable(prise)
else:
print 'Erreur : Commande inconnue'
sys.exit(0)
os.system("whos chbre=%s"%sys.argv[1])