WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [XENAPI] Update test scripts to move from

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [XENAPI] Update test scripts to move from VBD.image to creating VDI's
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 25 Jan 2007 08:55:24 -0800
Delivery-date: Thu, 25 Jan 2007 08:57:07 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Alastair Tse <atse@xxxxxxxxxxxxx>
# Date 1169653738 0
# Node ID 072ce22bcc91e4b48c5ceccccec41f26a73cdd82
# Parent  665be23d7fe9d7ab1380df4630e0c85169786ba5
[XENAPI] Update test scripts to move from VBD.image to creating VDI's
with the uri attribute.

Signed-off-by: Alastair Tse <atse@xxxxxxxxxxxxx>
---
 tools/python/scripts/test_vm_create.py |   57 +++++++++++++++++++++++++--------
 tools/python/scripts/xapi.py           |   25 +++++++++-----
 2 files changed, 60 insertions(+), 22 deletions(-)

diff -r 665be23d7fe9 -r 072ce22bcc91 tools/python/scripts/test_vm_create.py
--- a/tools/python/scripts/test_vm_create.py    Wed Jan 24 15:47:31 2007 +0000
+++ b/tools/python/scripts/test_vm_create.py    Wed Jan 24 15:48:58 2007 +0000
@@ -47,7 +47,8 @@ vdi_cfg = {
     'virtual_size': 100 * 1024,
     'sector_size': 1024,
     'type': 'system',
-    'parent': '',    
+    'parent': '',
+    'SR_name': 'QCoW',
     'sharable': False,
     'read_only': False,
 }
@@ -61,6 +62,19 @@ vbd_cfg = {
     'driver': 'paravirtualised',
 }
 
+local_vdi_cfg = {
+    'name_label': 'gentoo.amd64.img',
+    'name_description': '',
+    'uri': 'file:/root/gentoo.amd64.img',
+    'virtual_size': 0,
+    'sector_size': 0,
+    'type': 'system',
+    'parent': '',
+    'SR_name': 'Local',
+    'sharable': False,
+    'read_only': False,
+}    
+
 local_vbd_cfg = {
     'VDI': '',
     'VM': '',
@@ -68,7 +82,6 @@ local_vbd_cfg = {
     'mode': 'RW',
     'type': 'disk',
     'driver': 'paravirtualised',
-    'image': 'file:/root/gentoo.amd64.img'
 }
 
 vif_cfg = {
@@ -90,6 +103,7 @@ def test_vm_create():
     server, session = connect()
     vm_uuid = None
     vdi_uuid = None
+    local_vdi_uuid = None
     local_vbd_uuid = None
     vbd_uuid = None
     vif_uuid = None
@@ -102,8 +116,13 @@ def test_vm_create():
         vm_names.append(vm_record['name_label'])
 
     # Get default SR
-    sr_list = execute(server, 'SR.get_by_name_label', (session, 'Local'))
+    sr_list = execute(server, 'SR.get_by_name_label', (session,
+                                                       vdi_cfg['SR_name']))
     sr_uuid = sr_list[0]
+
+    local_sr_list = execute(server, 'SR.get_by_name_label',
+                            (session, local_vdi_cfg['SR_name']))
+    local_sr_uuid = local_sr_list[0]
 
     # Get default network
     net_list = execute(server, 'network.get_all', (session,))
@@ -121,13 +140,18 @@ def test_vm_create():
         vbd_cfg['VM'] = vm_uuid
         vbd_cfg['VDI'] = vdi_uuid
         vbd_uuid = execute(server, 'VBD.create', (session, vbd_cfg))
-
+        
+        # Create a new VDI (Local)
+        local_vdi_cfg['SR'] = local_sr_uuid
+        local_vdi_uuid = execute(server, 'VDI.create',
+                                 (session, local_vdi_cfg))
+ 
         # Create a new VBD (Local)
         local_vbd_cfg['VM'] = vm_uuid
-        local_vbd_cfg['VDI'] = ''
+        local_vbd_cfg['VDI'] = local_vdi_uuid
         local_vbd_uuid = execute(server, 'VBD.create',
                                  (session, local_vbd_cfg))
-        
+
         # Create a new VIF
         vif_cfg['network'] = net_uuid
         vif_cfg['VM'] = vm_uuid
@@ -138,13 +162,15 @@ def test_vm_create():
 
         time.sleep(30)
 
-        print 'Suspending VM..'
-        execute(server, 'VM.suspend', (session, vm_uuid))
-        print 'Suspended VM.'
-        time.sleep(5)
-        print 'Resuming VM ...'
-        execute(server, 'VM.resume', (session, vm_uuid, False))
-        print 'Resumed VM.'
+        test_suspend = True
+        if test_suspend:
+            print 'Suspending VM..'
+            execute(server, 'VM.suspend', (session, vm_uuid))
+            print 'Suspended VM.'
+            time.sleep(5)
+            print 'Resuming VM ...'
+            execute(server, 'VM.resume', (session, vm_uuid, False))
+            print 'Resumed VM.'
 
         # Wait for user to say we're good to shut it down
         while True:
@@ -156,12 +182,17 @@ def test_vm_create():
         # Clean up
         if vif_uuid:
             execute(server, 'VIF.destroy', (session, vif_uuid))
+            
         if local_vbd_uuid:
             execute(server, 'VBD.destroy', (session, local_vbd_uuid))
+        if local_vdi_uuid:
+            execute(server, 'VDI.destroy', (session, local_vdi_uuid))
+            
         if vbd_uuid:
             execute(server, 'VBD.destroy', (session, vbd_uuid))
         if vdi_uuid:
             execute(server, 'VDI.destroy', (session, vdi_uuid))
+        
         if vm_uuid:
             try:
                 execute(server, 'VM.hard_shutdown', (session, vm_uuid))
diff -r 665be23d7fe9 -r 072ce22bcc91 tools/python/scripts/xapi.py
--- a/tools/python/scripts/xapi.py      Wed Jan 24 15:47:31 2007 +0000
+++ b/tools/python/scripts/xapi.py      Wed Jan 24 15:48:58 2007 +0000
@@ -37,7 +37,7 @@ 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 = '%(device)-6s %(uuid)-36s %(VDI)-8s %(image)-8s'
+VBD_LIST_FORMAT = '%(device)-6s %(uuid)-36s %(VDI)-8s'
 TASK_LIST_FORMAT = '%(name_label)-18s %(uuid)-36s %(status)-8s %(progress)-4s'
 VIF_LIST_FORMAT = '%(name)-8s %(device)-7s %(uuid)-36s %(MAC)-10s'
 
@@ -85,25 +85,28 @@ OPTIONS = {
                                          'action': 'store_true'})],
     
     'vdi-create': [(('--name-label',), {'help': 'Name for VDI'}),
-                   (('--description',), {'help': 'Description for VDI'}),
+                   (('--name-description',), {'help': 'Description for VDI'}),
                    (('--sector-size',), {'type': 'int',
-                                         'help': 'Sector size'}),
+                                         'help': 'Sector size',
+                                         'default': 0}),
                    (('--virtual-size',), {'type': 'int',
+                                          'default': 0,
                                           'help': 'Size of VDI in sectors'}),
                    (('--type',), {'choices': ['system', 'user', 'ephemeral'],
+                                  'default': 'system',
                                   'help': 'VDI type'}),
                    (('--sharable',), {'action': 'store_true',
                                       'help': 'VDI sharable'}),
                    (('--read-only',), {'action': 'store_true',
-                                       'help': 'Read only'})],
+                                       'help': 'Read only'}),
+                   (('--sr',), {})],
     
     'vbd-create': [(('--VDI',), {'help': 'UUID of VDI to attach to.'}),
                    (('--mode',), {'choices': ['RO', 'RW'],
                                   'help': 'device mount mode'}),
                    (('--driver',), {'choices':['paravirtualised', 'ioemu'],
                                     'help': 'Driver for VBD'}),
-                   (('--device',), {'help': 'Device name on guest domain'}),
-                   (('--image',), {'help': 'Location of drive image.'})]
+                   (('--device',), {'help': 'Device name on guest domain'})]
                    
 }
 
@@ -464,8 +467,7 @@ def xapi_vbd_list(args, async = False):
     
     print VBD_LIST_FORMAT % {'device': 'Device',
                              'uuid' : 'UUID',
-                             'VDI': 'VDI',
-                             'image': 'Image'}
+                             'VDI': 'VDI'}
     
     for vbd in vbds:
         vbd_struct = execute(server, 'VBD.get_record', (session, vbd))
@@ -547,7 +549,12 @@ def xapi_vdi_create(args, async = False)
         cfg[opt] = val
 
     server, session = connect()
-    srs = execute(server, 'SR.get_all', (session,))
+    srs = []
+    if cfg.get('SR'):    
+        srs = execute(server, 'SR.get_by_name_label', (session, cfg['SR']))
+    else:
+        srs = execute(server, 'SR.get_all', (session,))
+
     sr = srs[0]
     cfg['SR'] = sr
 

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [XENAPI] Update test scripts to move from VBD.image to creating VDI's, Xen patchbot-unstable <=