switchs2.py: réparation de l'attribut prise
This commit is contained in:
parent
e5f7930bd9
commit
c848b1beb1
1 changed files with 24 additions and 1 deletions
|
@ -19,7 +19,6 @@ from __future__ import print_function
|
|||
|
||||
import sys, os
|
||||
import datetime
|
||||
import re
|
||||
import jinja2
|
||||
import itertools
|
||||
from socket import gethostbyname
|
||||
|
@ -346,10 +345,34 @@ def check_conf_ldap(hostname):
|
|||
if the != pra:
|
||||
print(" Machine %s sur mauvaise prise (%s,%s)" %
|
||||
(machine, the, pra))
|
||||
fix_prise(machine, pra)
|
||||
|
||||
elif isinstance(machine, ldap_classes.machineWifi):
|
||||
if not port.bornes:
|
||||
print(" Machine %s sur prise sans borne ?" % machine)
|
||||
|
||||
def fix_prise(machine, prise):
|
||||
"""Répare la base en remplaçant la prise de la machine par ce qui est
|
||||
conseillé en paramètre"""
|
||||
opt = "yN"
|
||||
old_prise = unicode(machine.get('prise', ['N/A'])[0])
|
||||
print("Remplacer prise de %s par %s (ancienne valeur: %s) ?" %
|
||||
(machine, prise, old_prise), "[%s]" % opt)
|
||||
while True:
|
||||
char = raw_input()
|
||||
if char in opt.lower():
|
||||
break
|
||||
print("[%s]" % opt)
|
||||
if char == 'y':
|
||||
if 'w' not in machine.mode:
|
||||
machine = ldap.search(u'%s' % machine.dn.split(',')[0], mode='rw')[0]
|
||||
with machine:
|
||||
machine['prise'] = unicode(prise)
|
||||
machine.history_gen()
|
||||
machine.save()
|
||||
print("Done !")
|
||||
|
||||
|
||||
def get_bat_num(hostname):
|
||||
"""Renvoie un tuple (bat, num) où bat est la lettre du bâtiment et
|
||||
num l'entier numéro du switch"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue