ia64/xen-unstable

changeset 13603:f000f963bbfd

[XENAPI] Add vif-list to xapi.py script

Signed-off-by: Alastair Tse <atse@xensource.com>
author Alastair Tse <atse@xensource.com>
date Wed Jan 24 15:50:02 2007 +0000 (2007-01-24)
parents 85250ca1df56
children e4d415692ba5
files tools/python/scripts/xapi.py
line diff
     1.1 --- a/tools/python/scripts/xapi.py	Wed Jan 24 15:49:32 2007 +0000
     1.2 +++ b/tools/python/scripts/xapi.py	Wed Jan 24 15:50:02 2007 +0000
     1.3 @@ -76,7 +76,11 @@ OPTIONS = {
     1.4      'vdi-list': [(('-l', '--long'),
     1.5                    {'action':'store_true',
     1.6                     'help':'List all properties of VDI'})
     1.7 -               ],        
     1.8 +                 ],
     1.9 +    'vif-list': [(('-l', '--long'),
    1.10 +                  {'action':'store_true',
    1.11 +                   'help':'List all properties of VIF'})
    1.12 +                 ],            
    1.13      'vm-list': [(('-l', '--long'),
    1.14                   {'action':'store_true',
    1.15                    'help':'List all properties of VMs'})
    1.16 @@ -475,19 +479,28 @@ def xapi_vbd_list(args, async = False):
    1.17   
    1.18  def xapi_vif_list(args, async = False):
    1.19      server, session = connect()
    1.20 +    opts, args = parse_args('vdi-list', args, set_defaults = True)
    1.21 +    is_long = opts and opts.long
    1.22 +    
    1.23      domname = args[0]
    1.24      
    1.25      dom_uuid = resolve_vm(server, session, domname)
    1.26      vifs = execute(server, 'VM.get_VIFs', (session, dom_uuid))
    1.27 -    
    1.28 -    print VIF_LIST_FORMAT % {'name': 'Name',
    1.29 -                             'device': 'Device',
    1.30 -                             'uuid' : 'UUID',
    1.31 -                             'MAC': 'MAC'}
    1.32 -    
    1.33 -    for vif in vifs:
    1.34 -        vif_struct = execute(server, 'VIF.get_record', (session, vif))
    1.35 -        print VIF_LIST_FORMAT % vif_struct       
    1.36 +
    1.37 +    if not is_long:
    1.38 +        print VIF_LIST_FORMAT % {'name': 'Name',
    1.39 +                                 'device': 'Device',
    1.40 +                                 'uuid' : 'UUID',
    1.41 +                                 'MAC': 'MAC'}
    1.42 +        
    1.43 +        for vif in vifs:
    1.44 +            vif_struct = execute(server, 'VIF.get_record', (session, vif))
    1.45 +            print VIF_LIST_FORMAT % vif_struct
    1.46 +    else:
    1.47 +        for vif in vifs:
    1.48 +            vif_struct = execute(server, 'VIF.get_record', (session, vif))
    1.49 +            pprint(vif_struct)
    1.50 +
    1.51  
    1.52  def xapi_vdi_list(args, async = False):
    1.53      opts, args = parse_args('vdi-list', args, set_defaults = True)