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-cim

[Xen-cim] pywbem test script using kernel/ramdisk

To: Xen-CIM <xen-cim@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-cim] pywbem test script using kernel/ramdisk
From: Jim Fehlig <jfehlig@xxxxxxxxxx>
Date: Thu, 19 Jul 2007 10:12:36 -0600
Delivery-date: Thu, 19 Jul 2007 09:10:25 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-cim-request@lists.xensource.com?subject=help>
List-id: xen-cim mailing list <xen-cim.lists.xensource.com>
List-post: <mailto:xen-cim@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-cim>, <mailto:xen-cim-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-cim>, <mailto:xen-cim-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-cim-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 1.5.0.8 (X11/20060911)
Luke,

Here is an example pywbem script using kernel/ramdisk instead of
bootloader.  Something similar should work with the xm test ramdisk.

Jim
#!/usr/bin/python

import sys
import pywbem
import time

# Connect to cimom
conn = pywbem.WBEMConnection('http://localhost', ('root', 'novell'))

# Get instance of Virtual System Management Service
print 'Looking for Virtual System Management Service...'
vsms = conn.EnumerateInstanceNames("Xen_VirtualSystemManagementService")
print 'Got Virtual System Management Service: %s' % str(vsms[0])


# Create virtual system settings for new VM
vssd = pywbem.CIMInstance('Xen_ComputerSystemSettingData',
        {'VirtualSystemIdentifier':'sles10_graphics',
         'VirtualSystemType':'xen-3.0-x86_32p',
         'Kernel':'/tests/kernels/vmlinuz-xenpae-sles10_sp1',
         'RAMDisk':'/tests/kernels/initrd-xenpae-sles10_sp1',
         'UUID':'20904d23-8a89-1d63-134c-d2606f2fcc47',
         'KernelOptions':'Term=xterm',
         'OnPoweroff':pywbem.Uint16(0),
         'OnReboot':pywbem.Uint16(1),
         'OnCrash':pywbem.Uint16(2)})

proc_rasd = pywbem.CIMInstance('Xen_ProcessorSettingData',
        {'ResourceType':pywbem.Uint16(3),
         'VirtualQuantity':pywbem.Uint64(2),
         'AllocationUnits':'Cores',
         'Weight':pywbem.Uint32(512),
         'Limit':pywbem.Uint64(100)})

mem_rasd = pywbem.CIMInstance('Xen_MemorySettingData',
        {'ResourceType':pywbem.Uint16(4), 
         'VirtualQuantity':pywbem.Uint64(512),
         'AllocationUnits':'MegaBytes'})

disk0_rasd = pywbem.CIMInstance('Xen_DiskSettingData',
         {'ResourceType':pywbem.Uint16(19),
         
'DiskConfigInfo':'file:/var/lib/xen/images/sles10_graphics/disk0,xvda,w'})

disk1_rasd = pywbem.CIMInstance('Xen_DiskSettingData',
        {'ResourceType':pywbem.Uint16(19),
         
'DiskConfigInfo':'file:/var/lib/xen/images/sles10_graphics/disk1,xvdb,w'})

nic_rasd = pywbem.CIMInstance('Xen_NetworkPortSettingData', 
        {'ResourceType':pywbem.Uint16(10), 
         'NICConfigInfo':'mac=00:16:3e:39:7a:f7'})

con_rasd = pywbem.CIMInstance('Xen_ConsoleSettingData', 
        {'ResourceType':pywbem.Uint16(24),
         'Protocol':pywbem.Uint16(1),
         'ConsoleConfigInfo':'vncunused=1'})

rasds = [proc_rasd, mem_rasd, disk0_rasd, disk1_rasd, nic_rasd, con_rasd]

in_params = {'SystemSettings': vssd, 'ResourceSettings': rasds}


# Invoke DefineSystem on Virtual System Management Serive to define a new VM,
# providing the new VM settings and its resource settings.
new_vm = None
try:
    print 'Calling DefineSystem to create a new VM ...'
    (rval, out_params) = conn.InvokeMethod('DefineSystem', vsms[0], **in_params)
    print 'Return Value of DefineSystem: %s' % rval
    print 'Output = %s' % out_params
    new_vm = out_params['ResultingSystem']

except pywbem.CIMError, arg:
    print 'Caught exception when calling InvokeMethod'
    if arg[0] != pywbem.CIM_ERR_NOT_SUPPORTED:
        print 'InvokeMethod(instancename): %s' % arg[1]
        sys.exit(1)

except ValueError, e:
    pass


# Get instances of Xen_ComputerSystem
print 'Enumerating instances of Xen_ComputerSystem:'
inst_names = conn.EnumerateInstanceNames('Xen_ComputerSystem')
for n in inst_names:
    inst = conn.GetInstance(n, LocalOnly=False)
    print 'Domain %s:  EnabledState %s' % (inst['Name'], inst['EnabledState'])

time.sleep(5)

print 'Activating newly defined VM ...'
try:
    # state 2 = enabled(running)
    (rval, out_params) = conn.InvokeMethod('RequestStateChange', new_vm, 
RequestedState='2')
except Exception, e:
    sys.stderr.write('Exception caught in starting VM: %s\n' % e)
    sys.exit(1)
    if rval == 0:
        print 'Successfully activated new vm'
    else:
        sys.stderr.write('Unable to start VM, return code: %s\n' % rval)
        sys.exit(1)

time.sleep(5)

print 'Enumerating instances of Xen_ComputerSystem:'
inst_names = conn.EnumerateInstanceNames('Xen_ComputerSystem')
for n in inst_names:
    inst = conn.GetInstance(n, LocalOnly=False)
    print 'Domain %s:  EnabledState %s' % (inst['Name'], inst['EnabledState'])

_______________________________________________
Xen-cim mailing list
Xen-cim@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-cim
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-cim] pywbem test script using kernel/ramdisk, Jim Fehlig <=