attempting to fix ::Provision
[p5sagit/Oyster.git] / lib / Oyster / Provision.pm
CommitLineData
3ded6347 1package Oyster::Provision;
2
3use Moose;
4
a9e65cee 5has 'api_username' => ( is => 'ro', isa => 'Str');
6has 'api_password' => ( is => 'ro', isa => 'Str');
7has 'name' => ( is => 'ro', isa => 'Str');
8has 'size' => ( is => 'ro', isa => 'Str');
9has 'image' => ( is => 'ro', isa => 'Str');
10has 'pub_ssh' => ( is => 'ro', isa => 'Str');
11has 'provision_backend' => (is => 'rw', isa => 'Str', required => 1, default => 'Oyster::Provision::Rackspace' );
3ded6347 12
13sub BUILD {
14
15 my $self = shift;
16
a9e65cee 17 my $role = $self->provision_backend;
8a0402ec 18
1d534f17 19 eval "use $role";
3ded6347 20 "$role"->meta->apply($self);
21}
c9ecd647 22
231;
40056462 24
25__END__
26
27=head1 NAME
28
29Oyster::Provision - Provision an Oyster
30
31=head1 SYNOPSIS
32
33 my $server = Oyster::Provision->new(
34 name => 'Ostrica',
35 size => '256',
36 image => 'Meerkat',
37 pub_ssh => "$ENV{HOME}/.ssh/id_rsa.pub",
38 );
39 $server->create;
40
41=head1 BACKENDS
42
43By default, the L<Oyster::Provision::Rackspace> backend
44will be used.
45
46Each backend needs to accept at least the C<name>,
47C<size>, C<image> and C<pub_ssh> parameters. The meaning
48of these parameters may differ from one backend to another.
49
50=head1 METHOS
51
52Each backend usually implements the following C<required>
53methods:
54
55=over
56
57=item create
58
59Creates a new server by given name, if such server does
60not exist.
61
62Installs the required packages for the distribution
63
64=item delete
65
66Gets rid of the server instance
67
68=item resize
69
70Hopefully scales the server
71
72=back
73
74=cut