Changeset 25d22ddddfca26a57fa98bf4ffd224765ddc118f

Show
Ignore:
Timestamp:
02/02/09 19:48:46 (3 years ago)
Author:
Frederic Lepied <frederic.lepied@…>
Children:
1f8d77d22e8dcb5f151e7d1e74900047caf545f8
Parents:
4eb29337239a94a6d28647644c80d1728804f0f9
git-committer:
Frederic Lepied <frederic.lepied@…> (02/02/09 19:48:46)
Message:

display the list of systems when called with -l

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pxe/dpysystem

    r2c8d924 r25d22dd  
    33# Project         : pxemngr 
    44# File            : dpysystem 
    5 # Version         : $Id$ 
     5# Copyright       : 2009 Splitted-Desktop Systems 
    66# Author          : Frederic Lepied 
    77# Created On      : Sun Feb  1 13:54:41 2009 
    8 # Purpose         :  
     8# Purpose         : report the list of systems or informations 
     9#                 about one system. 
    910#--------------------------------------------------------------- 
    1011 
     
    1516 
    1617if len(sys.argv) != 2: 
    17     error('Usage: %s <system name>' % sys.argv[0]) 
     18    error('Usage: %s <system name>|-l' % sys.argv[0]) 
     19 
     20if sys.argv[1] == '-l': 
     21    for s in System.objects.all(): 
     22        print s.name 
     23else: 
     24    try: 
     25        system = System.objects.get(name=sys.argv[1]) 
     26    except System.DoesNotExist: 
     27        error('System %s not defined' % sys.argv[1]) 
    1828     
    19 try: 
    20     system = System.objects.get(name=sys.argv[1]) 
    21 except System.DoesNotExist: 
    22     error('System %s not defined' % sys.argv[1]) 
    23  
    24 print 'Name:', system.name 
    25  
    26 for mac in MacAddress.objects.filter(system=system): 
    27     print 'Mac:', 
    28     for i in range(0, 10, 2): 
    29         sys.stdout.write('%s:' % mac.mac[i:i+2]) 
    30     sys.stdout.write('%s\n' % mac.mac[10:12]) 
    31  
    32 logs = Log.objects.filter(system=system).order_by('-date') 
    33 if len(logs) >= 1: 
    34     print 'Next boot:', logs[0].boot_name.name 
    35  
    36 print 'History:' 
    37 for l in logs[1:]: 
    38     print l.date, l.boot_name.name 
     29    print 'Name:', system.name 
     30     
     31    for mac in MacAddress.objects.filter(system=system): 
     32        print 'Mac:', 
     33        for i in range(0, 10, 2): 
     34            sys.stdout.write('%s:' % mac.mac[i:i+2]) 
     35        sys.stdout.write('%s\n' % mac.mac[10:12]) 
     36     
     37    logs = Log.objects.filter(system=system).order_by('-date') 
     38    if len(logs) >= 1: 
     39        print 'Next boot:', logs[0].boot_name.name 
     40     
     41    print 'History:' 
     42    for l in logs[1:]: 
     43        print l.date, l.boot_name.name 
    3944     
    4045# addsystem ends here