Boris Däppen > VM-JiffyBox-0.026 > VM::JiffyBox::Box

Download:
VM-JiffyBox-0.026.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.026   Source   Latest Release: VM-JiffyBox-0.027

NAME ^

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

VERSION ^

version 0.026

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

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

id

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

hypervisor

An object reference to VM::JiffyBox. Required.

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.

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.

delete

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

SEE ALSO ^

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.

syntax highlighting: