Commit ad1dbfbb authored by Daniel Stan's avatar Daniel Stan

unused_machines: add --batch mode (pour cron)

parent 739236f3
......@@ -15,6 +15,7 @@ from lc_ldap.crans_utils import format_mac
MAC = re.compile('[\-:]'.join('[a-f0-9]{2}' for _ in xrange(6)), re.IGNORECASE)
FILTER = u'(&(objectClass=%s)(ipHostNumber=*))'
BATCH = False
def get_creation_date(machine):
"""Plus vieille ligne d'histo = date de création, en datetime"""
......@@ -51,15 +52,16 @@ def do_cleanup(older, machines, logs):
macs.difference_update(mac_seen)
print "Will reset %d macs" % len(macs)
if True:
if not BATCH:
print "List incomming"
raw_input()
for machine in machines:
if machine['macAddress'][0].value in macs:
print machine
print "Continue ? (^C to stop)"
raw_input()
if not BATCH:
print "Continue ? (^C to stop)"
raw_input()
for machine in machines:
if machine['macAddress'][0].value in macs:
reset_ip(machine)
......@@ -113,6 +115,7 @@ def filter_filaire(machine):
if __name__ == '__main__':
folder = (sys.argv + [''])[1]
BATCH = "--batch" in sys.argv
if folder not in ['wifi', 'filaire']:
print "Not supported"
exit(1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment