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] Python script problems, part 2 - known good scripts

To: <xen-cim@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-cim] Python script problems, part 2 - known good scripts
From: "Szymanski, Lukasz K" <Lukasz.Szymanski@xxxxxxxxxx>
Date: Tue, 3 Jul 2007 11:18:54 -0400
Delivery-date: Tue, 03 Jul 2007 08:16:59 -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
Thread-index: Aceutr1ggmNJyTauRHCQf/b41f8fUQOy+/Sg
Thread-topic: Python script problems, part 2 - known good scripts
 

-----Original Message-----
From: Jim Fehlig 
Sent: Thursday, June 14, 2007 3:04 PM
To: Szymanski, Lukasz K
Subject: Re: Some updates

I tried both python scripts with success.  The scripts have been tweaked
a little so here they are for your viewing pleasure :-).  I'm using a
xen 3.1.0 based system with latest provider code.  The xen code has
patches that were sent to xen-devel, but don't think any of them would
prevent these scripts from working.

We'll have to dig in if you're still having problems.

Jim

Szymanski, Lukasz K wrote:
>
> Jim -
>
> So here is an update:  I have two problems, possibly related.
>
> 1)
> I applied the patch you emailed
> I applied the latest from CIM
>
> As a result I get a request that starts, but never finishes executing.

> The RequestStateChange starts with no errors, but the script just sits

> there.  Xm list shows the vm at a 'bp' state.  If I crtl-C the script 
> and try to run it again, I cannot get past the initial 
> EnumerateInstanceNames at the beginning of the script.  I have to 
> ctrl-C openwbem.  It's as if there's a locking/spinning issue 
> somewhere.
>
> 2)
> In a possibly related story, I cannot get the embedded instance script

> to work either.  The setting he is looking for is CMPI_string or 
> CMPI_instance, but not getting it (see ERROR)
>
> If I use the pywbem which comes with my SUSE, I get this in the 
> openwbem output
> CMPIMethodProviderProxy::invokeMethod()
> [INFO] [06/13/2007 12:18:18] 17404 ---
> Xen_VirtualSystemManagementService.c(749) : Entering InvokeMethod() 
> [WARNING] [06/13/2007 12:18:18] 17404 ---
> Xen_VirtualSystemManagementService.c(750) : --- 
> self="methodXen_VirtualSystemManagementService"
>
> [WARNING] [06/13/2007 12:18:18] 17404 ---
> Xen_VirtualSystemManagementService.c(751) : --- context="** Object not

> recognized (0x0x43002310) **"
>
> [WARNING] [06/13/2007 12:18:18] 17404 ---
> Xen_VirtualSystemManagementService.c(752) : --- 
> reference="/root/cimv2:Xen_VirtualSystemManagementService.CreationClas
> sName="Xen_VirtualSystemManagementService",SystemName="1089",Name="Xen
> Hypervisor",SystemCreationClassName="CIM_ComputerSystem""
>
> [WARNING] [06/13/2007 12:18:18] 17404 ---
> Xen_VirtualSystemManagementService.c(753) : ---
methodname="DefineSystem"
> [WARNING] [06/13/2007 12:18:18] 17404 ---
> Xen_VirtualSystemManagementService.c(754) : --- namespace="root/cimv2"
> [WARNING] [06/13/2007 12:18:18] 17404 ---
> Xen_VirtualSystemManagementService.c(762) : --- # argsin=3 [ERROR] 
> [06/13/2007 12:18:18] 17404 ---
> Xen_VirtualSystemManagementService.c(827) : --- Invalid setting type -

> UNKNOWN [INFO] [06/13/2007 12:18:18] 17404 ---
> Xen_VirtualSystemManagementService.c(1076) : Exiting 
> InvokeMethod()=Failed [1124096320] XMLExecute::processSimpleReq caught

> CIM exception:
> Code: 4
> File: OW_CMPIMethodProviderProxy.cpp
>  Line: 106
> Message: invalid parameter passed to method (Invalid setting type)
>
> I thought maybe this was an outdated pywbem.  If I go to the latest 
> from sourceforge, this is the output I get from the embedded script.
>
> Calling DefineSystem to create a new VM ...
> Traceback (most recent call last):
>   File "inst_embed_test.py", line 66, in ?
>     (rval, out_params) = conn.InvokeMethod('DefineSystem', vsms[0],
> **in_params)
>   File
> "/usr/local/lib64/python2.4/site-packages/pywbem/cim_operations.py",
> line 763, in InvokeMethod
>     result = self.methodcall(MethodName, obj, **params)
>   File
> "/usr/local/lib64/python2.4/site-packages/pywbem/cim_operations.py",
> line 262, in methodcall
>     plist = [cim_xml.PARAMVALUE(x[0], paramvalue(x[1]),
paramtype(x[1]))
>   File
> "/usr/local/lib64/python2.4/site-packages/pywbem/cim_operations.py",
> line 260, in paramvalue
>     raise TypeError('Unsupported parameter type "%s"' % type(obj))
> TypeError: Unsupported parameter type "<type 'instance'>"
>
> -------------------------------
>
> If you have seen any of this before and have a fix, then please let me

> know.  What version is your Xen, SUSE, python, etc.?  Maybe I can work

> backwords from something that works.
>
> Thanks,
> Luke
>
#!/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',
         'Bootloader':'/usr/lib/xen/boot/domUloader.py',
         
'BootloaderOptions':'--entry=xvda2:/boot/vmlinuz-xenpae,/boot/initrd-xenpae',
         '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'])

#!/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 = '''
instance of Xen_ComputerSystemSettingData {
VirtualSystemIdentifier = "sles10_graphics";
VirtualSystemType = "xen-3.0-x86_32p";
Bootloader = "/usr/lib/xen/boot/domUloader.py";
BootloaderOptions = "--entry=xvda2:/boot/vmlinuz-xenpae,/boot/initrd-xenpae";
UUID = "20904d23-8a89-1d63-134c-d2606f2fcc47";
OnPoweroff = 0;
OnReboot = 1;
OnCrash = 2;
KernelOptions = "Term=xterm";
};
'''

# Create resource settings for the new VM
proc_rasd = '''
instance of Xen_ProcessorSettingData {
ResourceType = 3;
VirtualQuantity = 2;
AllocationUnits = "Cores";
Limit = 100;
Weight = 512;
};
'''

mem_rasd = '''
instance of Xen_MemorySettingData {
ResourceType = 4;
VirtualQuantity = 512;
AllocationUnits = "MegaBytes";
};
'''

disk0_rasd = '''
instance of Xen_DiskSettingData {
ResourceType = 19;
DiskConfigInfo =  "file:/var/lib/xen/images/sles10_graphics/disk0,xvda,w";
};
'''

disk1_rasd = '''
instance of Xen_DiskSettingData {
ResourceType = 19;
DiskConfigInfo =  "file:/var/lib/xen/images/sles10_graphics/disk1,xvdb,w";
};
'''

nic_rasd = '''
instance of Xen_NetworkPortSettingData {
 ResourceType = 10;
 NICConfigInfo = "mac=00:16:3e:39:7a:f7";
};
'''

con_rasd = '''
instance of Xen_ConsoleSettingData {
 ResourceType = 24;
 Protocol = 1;
 ConsoleConfigInfo = "vncdisplay=5";
};
'''

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)


# 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] Python script problems, part 2 - known good scripts, Szymanski, Lukasz K <=