
On 09/04/2012 03:45 PM, Frank Wall wrote:
Hi,
I was searching for a Perl Client for the oVirt REST API, but I couldn't find one, so I hacked up one myself. It's called Net::oVirt::Lite and it's entirely based on Net::Twitter::Lite, so credits go to it's author Marc Mims for this nice module.
Net::oVirt::Lite uses most of the XML examples from the REST API Guide [1]. You just need to pass the required params to the module and it will complete the XML code itself. The XML answer from oVirt Engine is parsed with XML::Simple and returned as a hashref for ease of use. You don't need to write or parse any XML.
Although Net::oVirt::Lite is a quick hack and far from complete I'd like to share what I've got. If someone is interested I'd like to maintain and further enhance it. Feedback, patches, bug reports are very welcome. There's no help file, so take a look at the source to get the API calls and params you need.
[1] https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Enterprise_Virtualiza...
DOWNLOAD ============================== Temporary download location: http://dl.moov.de/perl/Net-oVirt-Lite-0.1.tar.gz (sorry, not a complete distribution yet, no tests, no Makefile, no docs)
LICENSE ============================== Net::oVirt::Lite is Copyright (c) 2012 inotronic Computers GmbH Net::Twitter::Lite is Copyright (c) 2009 Marc Mims The oVirt API itself, and the description text used in this module is: Copyright (c) 2011 Red Hat, Inc.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SYNOPSIS ============================== use Net::oVirt::Lite;
my $ov = Net::oVirt::Lite->new( apiurl => 'https://ovirt-engine.example.com:8443/api', username => $user, password => $password );
# Test connection my $result = eval { $ov->api_connection_test };
# List all VMs eval { my $vms = $ov->vms; foreach my $vm ( keys %{ $vms->{'vm'} } ) { print "Found $vm with ID " . $vms->{'vm'}->{$vm}->{'id'} . "\n"; } print "No VMs found.\n" if scalar(keys %{ $vms->{'vm'} }) < 1; }; warn "$@\n" if $@;
# Stop VM $result = eval { $ov->stop_vm({ vm_id => '8cc4b549-b79f-4fd5-82f1-556175225cf3' }) };
# Change CPU Cores $ov->vm_cpu({ vm_id => '8cc4b549-b79f-4fd5-82f1-556175225cf3', cpu_cores => 2, cpu_sockets => 1 });
Regards - Frank
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
great to see this. have you considered doing this based on the RSDL meta data to generate this, rather than maintain?