Net::OpenNebula - Access OpenNebula RPC via Perl.
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.
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);
This is the constructor.
my $one = Net::OpenNebula->new( url => "http://server:2633/RPC2", user => "oneadmin", password => "onepass", );
This function calls one.clusterpool.info. This will return information of all clusters in the pool.
my @clusters = $one->get_clusters;
This function calls one.hostpool.info. This will return information of all hosts in the pool.
my @hosts = $one->get_hosts;
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);
This function calls one.vmpool.info. This will return information of all known virtual machines.
my @vms = $one->get_vms;
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');
This function calls one.templatepool.info. This will return information of all the templates available in OpenNebula.
my @templates = $one->get_templates;
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', );
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.
To install Net::OpenNebula, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::OpenNebula
CPAN shell
perl -MCPAN -e shell install Net::OpenNebula
For more information on module installation, please visit the detailed CPAN module installation guide.