NAME

VM::JiffyBox::Box - Representation of a Virtual Machine in JiffyBox

VERSION

version 0.031

SYNOPSIS

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.)

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. The following caches are available:

last

Always contains the last information.

backup_cache

Contains information of the last call to get_backups().

details_cache

Contains information of the last call to get_details().

start_cache

Contains information of the last call to start().

stop_cache

Contains information of the last call to stop().

delete_cache

Contains information of the last call to delete().

freeze_cache

Contains information of the last call to freeze().

thaw_cache

Contains information of the last call to thaw().

METHODS

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

Creates a box-object. Requires two parameters.

id

ID of the box. Required. See the official documentation of JiffyBox for more information.

hypervisor

An object reference to VM::JiffyBox. Required.

Optional parameters

  • name

    Name of the box

get_details

Returns hashref with information about the virtual machine. Takes no arguments.

get_backups

Returns hashref with information about the backups of the virtual machine. Takes no arguments.

clone

Clones a virtual machine. Needs a name and a planid. Returns a VM::JiffyBox::Box object.

my $clone = $box->clone(
    name   => 'Clonename',
    planid => 22,
);

start

Starts a virtual machine. It must be ensured (by you) that the machine has the state READY before calling this.

stop

Stop a virtual machine.

$box->stop();

freeze

freeze a virtual machine.

$box->freeze();

thaw

Thaw a virtual machine.

$box->thaw();

delete

Delete a virtual machine. (Be sure that the VM has the appropriate state for doing so)

SEE ALSO

  • 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.

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.