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

Re: [Xen-API] perl Xen API How to



On 12/11/12 09:28, Rawat, Vishwanath wrote:
> Yes I did that. I got the same error. Here is my code and its output.
> 
> Code: 
> 
> my $vm = "vm9_WinXP_x86";
> my $vm_ref = extractvalue($xen->simple_request("VM.get_by_name_label", 
> $session, $vm));
> print Dumper($vm_ref);
> 
> my $sp = XMLRPC::PurePerl->double(1);

Why is this a double? start_paused should be a bool.

> print Dumper($sp);
> $s_p = $sp->value();
> print "asdfa " . $s_p . "\n";;
> $host_ref = extractvalue($xen->simple_request("VM.start", $session, 
> $vm_ref->[0], $s_p, 0));
> 
> sub extractvalue{
>     my ($val) = @_;
>     print Dumper ($val);
>     if ($val->{'Status'} eq "Success"){
>         return $val->{'Value'};
>     } else {
>         return undef;
>     }
> }
> 
> Output
> 
> $VAR1 = {
>           'Value' => [
>                      'OpaqueRef:04969f9f-41f9-15e0-8821-93395c8d22ed'
>                    ],
>           'Status' => 'Success'
>         };
> $VAR1 = [
>           'OpaqueRef:04969f9f-41f9-15e0-8821-93395c8d22ed'
>         ];
> $VAR1 = bless( {
>                  'val' => 1,
>                  'type' => 'double'
>                }, 'XMLRPC::PurePerl::Type::double' );
> asdfa 1
> $VAR1 = {
>           'ErrorDescription' => [
>                                 'FIELD_TYPE_ERROR',
>                                 'start_paused'
>                               ],
>           'Status' => 'Failure'
>         };
> 
> Regards,
> Rawat
> 
> -----Original Message-----
> From: Mike McClurg [mailto:mike.mcclurg@xxxxxxxxxx] 
> Sent: Monday, November 12, 2012 2:50 PM
> To: Rawat, Vishwanath
> Cc: xen-api@xxxxxxxxxxxxx
> Subject: Re: [Xen-API] perl Xen API How to
> 
> On 12/11/12 09:15, Rawat, Vishwanath wrote:
>> Mike,
>>      I tried encoding value as Boolean using XMLRPC::PurePerl it didn't work.
>> For second part I tried passing int($min) instead of $min but still didn't 
>> work.
>>
> 
> Did it give you a type error again? Is there any way you can ask the library 
> to encode the request so that you can then print it out and verify that it's 
> correct, without actually sending the request to the server?
> 
> Mike
> 
>> Regards,
>> Rawat
>>
>> -----Original Message-----
>> From: Mike McClurg [mailto:mike.mcclurg@xxxxxxxxxx]
>> Sent: Friday, November 09, 2012 5:30 PM
>> To: Rawat, Vishwanath
>> Cc: xen-api@xxxxxxxxxxxxx
>> Subject: Re: [Xen-API] perl Xen API How to
>>
>> On 09/11/12 11:38, Rawat, Vishwanath wrote:
>>> Hi,
>>>
>>>                 I am writing some perl scripts which will perform 
>>> some action on Xen server. I am using RPC::XML for that.
>>>
>>
>> <snip>
>>
>>> $xen->simple_request("VM.start", $session, $vm_ref, $start_paused, 
>>> $force);
>>>
>>>         Error displayed upon execution of above code is
>>>
>>>        $VAR1 = [
>>>
>>>            'FIELD_TYPE_ERROR',
>>>
>>>            'start_paused'
>>>
>>>         ];
>>>
>>>   start_paused option is of type Boolean so I tried all different 
>>> combination like True, TRUE, true, Yes, ON. Nothing seems to be working.
>>> Can someone let me know what is the correct way of passing Boolean 
>>> value to simple_request method.
>>>
>>
>> This looks like a Perl XMLRPC problem to me. See here:
>>
>> http://search.cpan.org/~rdietrich/xmlrpc-pureperl-0.03/lib/XMLRPC/PurePerl.pm#DATATYPES:
>>
>> You can use that to explicitly encode a value as a boolean. I'm not much of 
>> a Perl expert, so I don't know if that library is compatible with yours, but 
>> I guess that link should get you moving in the right direction.
>>
>> For your question below, those values are supposed to be integers. I'm 
>> not sure why you'd be getting a field error there; maybe Perl is 
>> treating 'min' as a string? (Everything in Perl is a string, right? ;) 
>> )
>>
>> You probably know this already, but make sure you have the XenAPI reference 
>> at hand when working with the API:
>> http://docs.vmd.citrix.com/XenServer/6.1.0/1.0/en_gb/api/
>>
>> Mike
>>
>>>  
>>>
>>> 2.       I was trying to set dynamic memory range of a VM. Code is
>>>
>>> $min = 1024*1024*1024; # (also tried 1g,1GiB)
>>>
>>> $max = 2*1024*1024*1024;  #(also tried 2g,2GiB)
>>>
>>> $vm_ref = <vm_opaque_ref>;
>>>
>>>       $xen->simple_request("VM.set_memory_dynamic_range", $session, 
>>> $vm_ref, $min, $max);
>>>
>>>   Getting same error as above
>>>
>>> $VAR1 = [
>>>
>>>            'FIELD_TYPE_ERROR',
>>>
>>>            'min'
>>>
>>>         ];
>>>
>>> Would like to know what is the correct way of passing these type of values.
>>>
>>>  
>>>
>>> 3.       Was trying to create network on a given Xen server.
>>>
>>> $network_name = "some_network_xenbr";
>>>
>>> $xen->simple_request("network.create", $session, $network_name);
>>>
>>>   Getting the following error
>>>
>>> $VAR1 = [
>>>
>>>           'XMLRPC_UNMARSHAL_FAILURE',
>>>
>>>           'unbox: Element=string should contain \'struct\'',
>>>
>>>           '<string>name-label=NACL_Test_Xenbr1352382351</string>'
>>>
>>>         ];
>>>
>>> $network_name should be of type "network record", which I don't know 
>>> what it means. Can someone help me with this.
>>>
>>>  
>>>
>>> Thanks a lot in advance.
>>>
>>>  
>>>
>>> Regards,
>>>
>>> Rawat
>>>
>>>  
>>>
>>>  
>>>
>>
> 


_______________________________________________
Xen-api mailing list
Xen-api@xxxxxxxxxxxxx
http://lists.xen.org/cgi-bin/mailman/listinfo/xen-api


 


Rackspace

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