[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [XENAPI] Update debugging scripts to support vbd_list



# HG changeset patch
# User Alastair Tse <atse@xxxxxxxxxxxxx>
# Node ID 96621d417bd485b6f3a7f1d715dda39d7df1e275
# Parent  09c29e91e3cd58429757d366c593008e7fc9cd88
[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@xxxxxxxxxxxxx>
---
 tools/python/scripts/xapi.domcfg.py |    2 -
 tools/python/scripts/xapi.py        |   38 ++++++++++++++++++++++++++++++------
 2 files changed, 33 insertions(+), 7 deletions(-)

diff -r 09c29e91e3cd -r 96621d417bd4 tools/python/scripts/xapi.domcfg.py
--- a/tools/python/scripts/xapi.domcfg.py       Thu Nov 30 14:48:42 2006 +0000
+++ b/tools/python/scripts/xapi.domcfg.py       Thu Nov 30 14:50:27 2006 +0000
@@ -26,7 +26,7 @@ platform_localtime =  False
 platform_localtime =  False
 platform_clock_offset =  False
 platform_enable_audio =  False
-builder =  ''
+builder =  'linux'
 boot_method =  '' # this will remove the kernel/initrd ??
 kernel_kernel =  '/boot/vmlinuz-2.6.16.29-xen'
 kernel_initrd =  '/root/initrd-2.6.16.29-xen.img'
diff -r 09c29e91e3cd -r 96621d417bd4 tools/python/scripts/xapi.py
--- a/tools/python/scripts/xapi.py      Thu Nov 30 14:48:42 2006 +0000
+++ b/tools/python/scripts/xapi.py      Thu Nov 30 14:50:27 2006 +0000
@@ -35,11 +35,14 @@ SR_LIST_FORMAT = '%(name_label)-18s %(uu
                  '%(type)-10s'
 VDI_LIST_FORMAT = '%(name_label)-18s %(uuid)-36s %(virtual_size)-8s '\
                   '%(sector_size)-8s'
+VBD_LIST_FORMAT = '%(name_label)-18s %(uuid)-36s %(VDI)-8s '\
+                  '%(image)-8s'
 
 COMMANDS = {
     'host-info': ('', 'Get Xen Host Info'),
     'host-set-name': ('', 'Set host name'),
     'sr-list':   ('', 'List all SRs'),
+    'vbd-list':  ('', 'List all VBDs'),
     'vbd-create': ('<domname> <pycfg> [opts]',
                    'Create VBD attached to domname'),
     'vdi-create': ('<pycfg> [opts]', 'Create a VDI'),
@@ -165,6 +168,13 @@ def resolve_vm(server, session, vm_name)
     else:
         return vm_uuid[0]
 
+def resolve_vdi(server, session, vdi_name):
+    vdi_uuid = execute(server.VDI.get_by_name_label, session, vdi_name)
+    if not vdi_uuid:
+        return None
+    else:
+        return vdi_uuid[0]
+
 #
 # Actual commands
 #
@@ -223,9 +233,9 @@ def xapi_vm_list(*args):
     for uuid in vm_uuids:
         vm_info = execute(server.VM.get_record, session, uuid)
         if is_long:
-            vbds = vm_info['vbds']
-            vifs = vm_info['vifs']
-            vtpms = vm_info['vtpms']
+            vbds = vm_info['VBDs']
+            vifs = vm_info['VIFs']
+            vtpms = vm_info['VTPMs']
             vif_infos = []
             vbd_infos = []
             vtpm_infos = []
@@ -238,9 +248,9 @@ def xapi_vm_list(*args):
             for vtpm in vtpms:
                 vtpm_info = execute(server.VTPM.get_record, session, vtpm)
                 vtpm_infos.append(vtpm_info)
-            vm_info['vbds'] = vbd_infos
-            vm_info['vifs'] = vif_infos
-            vm_info['vtpms'] = vtpm_infos
+            vm_info['VBDs'] = vbd_infos
+            vm_info['VIFs'] = vif_infos
+            vm_info['VTPMs'] = vtpm_infos
             pprint(vm_info)
         else:
             print VM_LIST_FORMAT % _stringify(vm_info)
@@ -333,6 +343,22 @@ def xapi_vif_create(*args):
     cfg['VM'] = vm_uuid
     vif_uuid = execute(server.VIF.create, session, cfg)
     print 'Done. (%s)' % vif_uuid
+
+def xapi_vbd_list(*args):
+    server, session = _connect()
+    domname = args[0]
+    
+    dom_uuid = resolve_vm(server, session, domname)
+    vbds = execute(server.VM.get_VBDs, session, dom_uuid)
+    
+    print VBD_LIST_FORMAT % {'name_label': 'VDI Label',
+                             'uuid' : 'UUID',
+                             'VDI': 'VDI',
+                             'image': 'Image'}
+    
+    for vbd in vbds:
+        vbd_struct = execute(server.VBD.get_record, session, vbd)
+        print VBD_LIST_FORMAT % vbd_struct
 
 def xapi_vdi_list(*args):
     server, session = _connect()

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.