NAME

Net::OpenNebula - Access OpenNebula RPC via Perl.

DESCRIPTION

With this module you can access the OpenNebula XML-RPC service.

To inspect the return values of the methods we suggest to use Data::Dumper.

SYNOPSIS

use Net::OpenNebula;
use Data::Dumper; # for the Dumper() function.
   
my $one = Net::OpenNebula->new(
   url      => "http://server:2633/RPC2",
   user     => "oneadmin",
   password => "onepass",
);
   
my @vms = $one->get_vms();
    
print Dumper(@vms);

METHODS

new(%option)

This is the constructor.

my $one = Net::OpenNebula->new(
   url      => "http://server:2633/RPC2",
   user     => "oneadmin",
   password => "onepass",
);
get_clusters()

This function calls one.clusterpool.info. This will return information of all clusters in the pool.

my @clusters = $one->get_clusters;
get_hosts()

This function calls one.hostpool.info. This will return information of all hosts in the pool.

my @hosts = $one->get_hosts;
get_host($id)

This function calls one.host.info. This will return information the given host. You need to refer to the host by its OpenNebula id.

my $host = $one->get_host(5);
get_vms()

This function calls one.vmpool.info. This will return information of all known virtual machines.

my @vms = $one->get_vms;
get_vm()

This function calls one.vm.info. This will return information of the given virtual machine.

my $vm = $one->get_vm(8);

You can also use the virtual machine's name.

my $vm = $one->get_vm('myvm');
get_templates()

This function calls one.templatepool.info. This will return information of all the templates available in OpenNebula.

my @templates = $one->get_templates;
create_vm(%option)

This function will call one.vm.allocate and create a new virtual machine.

my $vm = $one->create_vm(
   template => 7,
   name     => 'vmname',
);

You can also use the template name.

my $vm = $one->create_vm(
   template => 'centos',
   name     => 'vmname',
);
create_host(%option)

This function will call one.host.allocate and register a new host into OpenNebula.

my $host = $one->create_host(
   name    => 'my-computenode',
   im_mad  => 'im_mad_name',  # optional
   vmm_mad => 'vmm_mad_name', # optional
   vnm_mad => 'vnm_mad_name', # optional
   cluster => 'my-computenode',
);

The cluster option is optional. All other options are mandatory.