VM::JiffyBox::Box - Representation of a Virtual Machine in JiffyBox
version 0.025
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.)
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.
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().
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
.
Creates a box-object. Requires two paramters.
ID
of the box. Required. See the official documentation of JiffyBox for more information.
An object reference to VM::JiffyBox
. Required.
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.
Starts a virtual machine. It must be ensured (by you) that the machine has the state READY
before calling this.
Stop a virtual machine.
Delete a virtual machine. (Be sure that the VM has the appropriate state for doing so)
Tim Schwarz, Boris Däppen <bdaeppen.perl@gmail.com>
This software is copyright (c) 2013 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.