ia64/xen-unstable

changeset 12689:96621d417bd4

[XENAPI] Update debugging scripts to support vbd_list

Add function to list all vbds attached to a VM.
Update VM config builder to specify the default as 'linux'

Signed-off-by: Alastair Tse <atse@xensource.com>
author Alastair Tse <atse@xensource.com>
date Thu Nov 30 14:50:27 2006 +0000 (2006-11-30)
parents 09c29e91e3cd
children d9b5e34c4e5c
files tools/python/scripts/xapi.domcfg.py tools/python/scripts/xapi.py
line diff
     1.1 --- a/tools/python/scripts/xapi.domcfg.py	Thu Nov 30 14:48:42 2006 +0000
     1.2 +++ b/tools/python/scripts/xapi.domcfg.py	Thu Nov 30 14:50:27 2006 +0000
     1.3 @@ -26,7 +26,7 @@ platform_serial =  ''
     1.4  platform_localtime =  False
     1.5  platform_clock_offset =  False
     1.6  platform_enable_audio =  False
     1.7 -builder =  ''
     1.8 +builder =  'linux'
     1.9  boot_method =  '' # this will remove the kernel/initrd ??
    1.10  kernel_kernel =  '/boot/vmlinuz-2.6.16.29-xen'
    1.11  kernel_initrd =  '/root/initrd-2.6.16.29-xen.img'
     2.1 --- a/tools/python/scripts/xapi.py	Thu Nov 30 14:48:42 2006 +0000
     2.2 +++ b/tools/python/scripts/xapi.py	Thu Nov 30 14:50:27 2006 +0000
     2.3 @@ -35,11 +35,14 @@ SR_LIST_FORMAT = '%(name_label)-18s %(uu
     2.4                   '%(type)-10s'
     2.5  VDI_LIST_FORMAT = '%(name_label)-18s %(uuid)-36s %(virtual_size)-8s '\
     2.6                    '%(sector_size)-8s'
     2.7 +VBD_LIST_FORMAT = '%(name_label)-18s %(uuid)-36s %(VDI)-8s '\
     2.8 +                  '%(image)-8s'
     2.9  
    2.10  COMMANDS = {
    2.11      'host-info': ('', 'Get Xen Host Info'),
    2.12      'host-set-name': ('', 'Set host name'),
    2.13      'sr-list':   ('', 'List all SRs'),
    2.14 +    'vbd-list':  ('', 'List all VBDs'),
    2.15      'vbd-create': ('<domname> <pycfg> [opts]',
    2.16                     'Create VBD attached to domname'),
    2.17      'vdi-create': ('<pycfg> [opts]', 'Create a VDI'),
    2.18 @@ -165,6 +168,13 @@ def resolve_vm(server, session, vm_name)
    2.19      else:
    2.20          return vm_uuid[0]
    2.21  
    2.22 +def resolve_vdi(server, session, vdi_name):
    2.23 +    vdi_uuid = execute(server.VDI.get_by_name_label, session, vdi_name)
    2.24 +    if not vdi_uuid:
    2.25 +        return None
    2.26 +    else:
    2.27 +        return vdi_uuid[0]
    2.28 +
    2.29  #
    2.30  # Actual commands
    2.31  #
    2.32 @@ -223,9 +233,9 @@ def xapi_vm_list(*args):
    2.33      for uuid in vm_uuids:
    2.34          vm_info = execute(server.VM.get_record, session, uuid)
    2.35          if is_long:
    2.36 -            vbds = vm_info['vbds']
    2.37 -            vifs = vm_info['vifs']
    2.38 -            vtpms = vm_info['vtpms']
    2.39 +            vbds = vm_info['VBDs']
    2.40 +            vifs = vm_info['VIFs']
    2.41 +            vtpms = vm_info['VTPMs']
    2.42              vif_infos = []
    2.43              vbd_infos = []
    2.44              vtpm_infos = []
    2.45 @@ -238,9 +248,9 @@ def xapi_vm_list(*args):
    2.46              for vtpm in vtpms:
    2.47                  vtpm_info = execute(server.VTPM.get_record, session, vtpm)
    2.48                  vtpm_infos.append(vtpm_info)
    2.49 -            vm_info['vbds'] = vbd_infos
    2.50 -            vm_info['vifs'] = vif_infos
    2.51 -            vm_info['vtpms'] = vtpm_infos
    2.52 +            vm_info['VBDs'] = vbd_infos
    2.53 +            vm_info['VIFs'] = vif_infos
    2.54 +            vm_info['VTPMs'] = vtpm_infos
    2.55              pprint(vm_info)
    2.56          else:
    2.57              print VM_LIST_FORMAT % _stringify(vm_info)
    2.58 @@ -334,6 +344,22 @@ def xapi_vif_create(*args):
    2.59      vif_uuid = execute(server.VIF.create, session, cfg)
    2.60      print 'Done. (%s)' % vif_uuid
    2.61  
    2.62 +def xapi_vbd_list(*args):
    2.63 +    server, session = _connect()
    2.64 +    domname = args[0]
    2.65 +    
    2.66 +    dom_uuid = resolve_vm(server, session, domname)
    2.67 +    vbds = execute(server.VM.get_VBDs, session, dom_uuid)
    2.68 +    
    2.69 +    print VBD_LIST_FORMAT % {'name_label': 'VDI Label',
    2.70 +                             'uuid' : 'UUID',
    2.71 +                             'VDI': 'VDI',
    2.72 +                             'image': 'Image'}
    2.73 +    
    2.74 +    for vbd in vbds:
    2.75 +        vbd_struct = execute(server.VBD.get_record, session, vbd)
    2.76 +        print VBD_LIST_FORMAT % vbd_struct
    2.77 +
    2.78  def xapi_vdi_list(*args):
    2.79      server, session = _connect()
    2.80      vdis = execute(server.VDI.get_all, session)