VM::JiffyBox::Box - Representation of a Virtual Machine in JiffyBox
version 0.032
This module should be used together with VM::JiffyBox. VM::JiffyBox is the factory for producing objects of this module. However if you want to do it yourself:
my $box = VM::JiffyBox::Box->new(id => $box_id, hypervisor => $ref);
You then can do a lot of stuff with this box:
# get some info my $backup_id = $box->get_backups()->{result}->{daily}->{id}; my $plan_id = $box->get_details()->{result}->{plan}->{id}; # get more info using the caching technique my $state = $box->details_chache->{result}->{status}; my $ip = $box->last->{result}->{ips}->{public}->[0]; # ... or use Data::Dumper; print Dumper( $box->backup_cache->{result} ); # start, stop, delete... if ( $box->start ) { print "VM started" } # and so on...
(See also the SYNOPSIS of VM::JiffyBox or the examples directory for more examples of working code.)
examples
All methods will return 0 on failure, so you can check for this with a simple if on the return value. If you need the error message you can use the cache and look into the attribute last. The form of the message is open. It can contain a simple string, or also a hash. This depends on the kind of error. So if you want to be sure, just use Data::Dumper to print it.
0
if
last
There are possibilities to take advantage of caching functionality. The following caches are available:
Always contains the last information.
Contains information of the last call to get_backups().
Contains information of the last call to get_details().
Contains information of the last call to start().
Contains information of the last call to stop().
Contains information of the last call to delete().
Contains information of the last call to freeze().
Contains information of the last call to thaw().
All methods (exluding new) will return information about the request, instead of doing a call to the API if the hypervisor is in test_mode.
new
test_mode
Creates a box-object. Requires two parameters.
ID of the box. Required. See the official documentation of JiffyBox for more information.
ID
An object reference to VM::JiffyBox. Required.
VM::JiffyBox
Optional parameters
name
Name of the box
Returns hashref with information about the virtual machine. Takes no arguments.
Returns hashref with information about the backups of the virtual machine. Takes no arguments.
Clones a virtual machine. Needs a name and a planid. Returns a VM::JiffyBox::Box object.
planid
VM::JiffyBox::Box
my $clone = $box->clone( name => 'Clonename', planid => 22, );
Starts a virtual machine. It must be ensured (by you) that the machine has the state READY before calling this.
READY
Stop a virtual machine.
$box->stop();
freeze a virtual machine.
$box->freeze();
Thaw a virtual machine.
$box->thaw({ planid => 22, });
Delete a virtual machine. (Be sure that the VM has the appropriate state for doing so)
Source, contributions, patches: https://github.com/borisdaeppen/VM-JiffyBox
This module is not officially supported by or related to the company domainfactory in Germany. However it aims to provide an interface to the API of their product JiffyBox. So to use this module with success you should also read their API-Documentation, available for registered users of their service.
Tim Schwarz, Boris Däppen <bdaeppen.perl@gmail.com>
This software is copyright (c) 2016 by Tim Schwarz, Boris Däppen, plusW.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install VM::JiffyBox, copy and paste the appropriate command in to your terminal.
cpanm
cpanm VM::JiffyBox
CPAN shell
perl -MCPAN -e shell install VM::JiffyBox
For more information on module installation, please visit the detailed CPAN module installation guide.