NAME
VM::JiffyBox - OO-API for JiffyBox Virtual Machine
VERSION
version 0.007
SYNOPSIS
#############################
# CREAT A CLONE FROM BACKUP #
#############################
# stuff we need to know our self
my $auth_token = $ARGV[0];
my $box_name = $ARGV[1];
my $clone_name = $ARGV[2];
# prepare connection to VM-Server
my $jiffy = VM::JiffyBox->new(token => $auth_token);
# translate VM-Name (String) to ID (Number)
my $master_box_id = $jiffy->get_id_from_name($box_name);
say "master_box_id: $master_box_id";
# prepare connection to the VM
my $master_box = $jiffy->get_vm($master_box_id);
# collect information about the VM
my $backup_id = $master_box->get_backups()->{result}->{daily}->{id};
my $plan_id = $master_box->get_details()->{result}->{plan}->{id};
say "backup_id: $backup_id";
say "plan_id: $plan_id";
# create a clone of the VM
my $clone_box = $jiffy->create_vm( $clone_name, $plan_id, $backup_id );
# abort if create failed
unless ($clone_box) {
# FAIL
die $jiffy->last->{messages}->[0]->{message};
}
# wait for the clone to be ready
do {
say "waiting for clone to get READY";
sleep 15;
} while (not $clone_box->get_details->{result}->{status} eq 'READY');
# start the clone
$clone_box->start();
(See the examples
directory for more examples of working code.)
ERROR HANDLING
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.
CACHING
There are possibilities to take advantage of caching functionality. If you have once called get_details(), the results will be stored in the attribute details_cache
.
METHODS
get_details
Returns hashref with information about the hypervisor and its virtual machines. Takes no arguments.
Results are cached in details_cache
.
get_id_from_name
Returns the ID for a specific virtual machine. Takes the name for the virtual machine as first argument.
(Also updates the details_cache
)
get_vm
Returns an object-ref to an existing virtual machine (VM::JiffyBox::Box). Takes the ID for the virtual machine as first argument.
create_vm
Creates a new virtual machine and returns an object-ref to it (VM::JiffyBox::Box). Takes 3 arguments:
name: The name for the new VM.
plan_id: The ID for pricing.
backup_id: Name of the backup-image to take.
Note: This methods interface could change in future releases, since it does not yet cover full functionality.
SEE ALSO
Source, contributions, patches: https://github.com/tim-schwarz/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.
AUTHOR
Tim Schwarz, Boris Däppen <bdaeppen.perl@gmail.com>
COPYRIGHT AND LICENSE
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.