[gen_confs/switchs.py] récupère la première ligne de la conf sur le switch
Ignore-this: d7af1b8e7e7ae6c903dfe38336dd3f01 darcs-hash:20090302144819-bd074-fef8f13a7b94c0f88e5fbb96c77ffb7078295c5d.gz
This commit is contained in:
parent
8905c9ca16
commit
cfb77c932a
1 changed files with 24 additions and 11 deletions
|
@ -14,7 +14,7 @@
|
||||||
Dans tous les cas FAIRE LE SNMP A LA MAIN (script hpttols)
|
Dans tous les cas FAIRE LE SNMP A LA MAIN (script hpttols)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import string, sys, os, commands, smtplib, tempfile
|
import string, sys, os, commands, smtplib, tempfile, getopt
|
||||||
|
|
||||||
sys.path.append('/usr/scripts/gestion')
|
sys.path.append('/usr/scripts/gestion')
|
||||||
from hptools import hpswitch, sw_chbre
|
from hptools import hpswitch, sw_chbre
|
||||||
|
@ -253,6 +253,21 @@ exit
|
||||||
# Batiment et numéro du switch
|
# Batiment et numéro du switch
|
||||||
bat = switch[3].lower()
|
bat = switch[3].lower()
|
||||||
sw_num = int(switch[5])
|
sw_num = int(switch[5])
|
||||||
|
# Conf radius
|
||||||
|
sys.path.append('/usr/scripts/gestion/secrets')
|
||||||
|
from secrets import radius_key
|
||||||
|
|
||||||
|
self.aff.cycle()
|
||||||
|
|
||||||
|
shuffle(self.rad_servs)
|
||||||
|
rad = self.rad_template * len(self.rad_servs)
|
||||||
|
params = { 'switch' : switch, 'bat' : bat.upper() ,
|
||||||
|
'radius_key' : radius_key ,
|
||||||
|
'radius-serveurs' : rad[:-1] % tuple(self.rad_servs)}
|
||||||
|
|
||||||
|
self.aff.cycle()
|
||||||
|
|
||||||
|
if '-g' in opts or '--get-conf' in opts:
|
||||||
old_config = NamedTemporaryFile()
|
old_config = NamedTemporaryFile()
|
||||||
res, msg = commands.getstatusoutput("scp bat%s-%i:cfg/startup-config %s" % (bat, sw_num, old_config.name))
|
res, msg = commands.getstatusoutput("scp bat%s-%i:cfg/startup-config %s" % (bat, sw_num, old_config.name))
|
||||||
|
|
||||||
|
@ -262,19 +277,16 @@ exit
|
||||||
params['switch_config_header'] = old_config.readline()
|
params['switch_config_header'] = old_config.readline()
|
||||||
old_config.close()
|
old_config.close()
|
||||||
|
|
||||||
# Conf radius
|
self.aff.cycle()
|
||||||
sys.path.append('/usr/scripts/gestion/secrets')
|
else:
|
||||||
from secrets import radius_key
|
params['switch_config_header']= '; J4899A Configuration Editor; Created on release #H.10.50'
|
||||||
shuffle(self.rad_servs)
|
|
||||||
rad = self.rad_template * len(self.rad_servs)
|
|
||||||
params = { 'switch' : switch, 'bat' : bat.upper() ,
|
|
||||||
'radius_key' : radius_key ,
|
|
||||||
'radius-serveurs' : rad[:-1] % tuple(self.rad_servs)}
|
|
||||||
|
|
||||||
# IP
|
# IP
|
||||||
machine = self.db.search(switch)['machine'][0]
|
machine = self.db.search(switch)['machine'][0]
|
||||||
params['ip'] = str(machine.ip())
|
params['ip'] = str(machine.ip())
|
||||||
|
|
||||||
|
self.aff.cycle()
|
||||||
|
|
||||||
# Nombre de prises et modèle
|
# Nombre de prises et modèle
|
||||||
nb_prises = machine.nombrePrises()
|
nb_prises = machine.nombrePrises()
|
||||||
if nb_prises < 0 :
|
if nb_prises < 0 :
|
||||||
|
@ -474,8 +486,9 @@ aaa port-access mac-based %(prise)s unauth-vid 1
|
||||||
fd.close()
|
fd.close()
|
||||||
|
|
||||||
if __name__ == '__main__' :
|
if __name__ == '__main__' :
|
||||||
|
opts, args = getopt.getopt(sys.argv[1:], 'hga', ['get-conf', 'help'])
|
||||||
if '-h' in sys.argv or '--help' in sys.argv or len(sys.argv) == 1 :
|
if '-h' in sys.argv or '--help' in sys.argv or len(sys.argv) == 1 :
|
||||||
print "%s <switch>" % sys.argv[0].split('/')[-1].split('.')[0]
|
print "%s [-g|--get-conf] <switch>" % sys.argv[0].split('/')[-1].split('.')[0]
|
||||||
print "Génération du fichier de configuration des switchs donnés."
|
print "Génération du fichier de configuration des switchs donnés."
|
||||||
sys.exit(255)
|
sys.exit(255)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue