[switchs.py] Choix du header à partir de ldap
En réalité, il y a un soucis: il faudrait rajouter la lettre de révision dans les données enregistrées... darcs-hash:20120426223425-28565-8b1951cd8b91ff374045b20f42f54445b125bc25.gz
This commit is contained in:
parent
a9ce208ca7
commit
d31dc13990
1 changed files with 23 additions and 5 deletions
|
@ -24,6 +24,16 @@ from random import shuffle
|
||||||
from gen_confs import *
|
from gen_confs import *
|
||||||
from time import localtime
|
from time import localtime
|
||||||
import config
|
import config
|
||||||
|
import re
|
||||||
|
|
||||||
|
capture_model = re.compile(r'\((.*)\)')
|
||||||
|
headers_by_model = {
|
||||||
|
'HP 2626': '; J4900C Configuration Editor; Created on release #H.10.83',
|
||||||
|
'HP 2650': '; J4899B Configuration Editor; Created on release #H.10.83',
|
||||||
|
'HP 2810-24G':'; J9021A Configuration Editor; Created on release #N.11.25',
|
||||||
|
'HP 2610-24':'; J9085A Configuration Editor; Created on release #R.11.54',
|
||||||
|
'HP 2610-48':'; J9088A Configuration Editor; Created on release #R.11.54',
|
||||||
|
'HP 2910al-24G':'; J9145A Configuration Editor; Created on release #W.14.38'}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
any
|
any
|
||||||
|
@ -288,6 +298,11 @@ exit
|
||||||
self.aff.cycle()
|
self.aff.cycle()
|
||||||
|
|
||||||
options = [ opt for opt,arg in opts]
|
options = [ opt for opt,arg in opts]
|
||||||
|
|
||||||
|
# IP
|
||||||
|
machine = self.db.search(switch)['machine'][0]
|
||||||
|
params['ip'] = str(machine.ip())
|
||||||
|
|
||||||
if '-g' in options or '--get-conf' in options:
|
if '-g' in options or '--get-conf' in options:
|
||||||
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))
|
||||||
|
@ -305,7 +320,14 @@ exit
|
||||||
params['switch_config_header'] = arg
|
params['switch_config_header'] = arg
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
params['switch_config_header']= '; J4899A Configuration Editor; Created on release #H.10.50'
|
try:
|
||||||
|
match = capture_model.search(machine.info()[0])
|
||||||
|
model = match.group(1)
|
||||||
|
sys.stderr.write(model)
|
||||||
|
params['switch_config_header']=headers_by_model[model]
|
||||||
|
except:
|
||||||
|
sys.stderr.write('Impossible de déterminer le header à utiliser (switch %s)' % switch)
|
||||||
|
params['switch_config_header']= '; J4899A Configuration Editor; Created on release #H.10.50'
|
||||||
|
|
||||||
model = params['switch_config_header'].split(' ', 2)[1]
|
model = params['switch_config_header'].split(' ', 2)[1]
|
||||||
if model == "J9145A":
|
if model == "J9145A":
|
||||||
|
@ -313,10 +335,6 @@ exit
|
||||||
else:
|
else:
|
||||||
params['module-type'] = ''
|
params['module-type'] = ''
|
||||||
|
|
||||||
# IP
|
|
||||||
machine = self.db.search(switch)['machine'][0]
|
|
||||||
params['ip'] = str(machine.ip())
|
|
||||||
|
|
||||||
self.aff.cycle()
|
self.aff.cycle()
|
||||||
|
|
||||||
# Nombre de prises et modèle
|
# Nombre de prises et modèle
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue