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

[Xen-API] perl Xen API How to


  • To: "xen-api@xxxxxxxxxxxxx" <xen-api@xxxxxxxxxxxxx>
  • From: "Rawat, Vishwanath" <Vishwanath.Rawat@xxxxxxxxxx>
  • Date: Fri, 9 Nov 2012 11:38:11 +0000
  • Accept-language: en-US
  • Delivery-date: Fri, 09 Nov 2012 11:49:11 +0000
  • List-id: User and development list for XCP and XAPI <xen-api.lists.xen.org>
  • Thread-index: Ac29wvndmW4OOO+UQ+W0dcnu51dVng==
  • Thread-topic: perl Xen API How to

Hi,

                I am writing some perl scripts which will perform some action on Xen server. I am using RPC::XML for that.

 

This the basic perl script that I am using.

 

use Data::Dumper;

use RPC::XML;

use RPC::XML::Client;

use RPC::XML::Server;

 

my $xenhost = <some_host>;

my $user = "$user";

my $passwd = "$passwd";

 

my $xen = RPC::XML::Client->new("http://$xenhost:80");

print "Coming here\n";

my $s = $xen->simple_request("session.login_with_password",$user,$passwd);

if (! $s) {

    print "error is $@ \n";

}

 

# print Dumper($s);

 

my $session = extractvalue($xen->simple_request("session.login_with_password",

              $user,$passwd));

 

if (! $session){

    print "connection failure : $xenhost\n";

    exit;

}

 

I need help with the following

1.       I was trying to start a vm using following code

$start_paused = 1;

$force = 0;

$vm_ref = <vm_opaque_ref>;

$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.

 

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®.