Whitespace removal
[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
6a2079a3 13# TODO after provision, add the server's name with "oyster-" prefixed to the
14# user's ~/.ssh/ssh_config file so any part of Oyster can ssh there
15# passwordlessly for deploying or whatnot
16
3ded6347 17sub BUILD {
18
19 my $self = shift;
20
a9e65cee 21 my $role = $self->provision_backend;
cd23eeaf 22
1d534f17 23 eval "use $role";
3ded6347 24 "$role"->meta->apply($self);
25}
c9ecd647 26
271;
40056462 28
29__END__
30
31=head1 NAME
32
33Oyster::Provision - Provision an Oyster
34
35=head1 SYNOPSIS
36
37 my $server = Oyster::Provision->new(
38 name => 'Ostrica',
39 size => '256',
40 image => 'Meerkat',
41 pub_ssh => "$ENV{HOME}/.ssh/id_rsa.pub",
42 );
43 $server->create;
44
45=head1 BACKENDS
46
47By default, the L<Oyster::Provision::Rackspace> backend
48will be used.
49
50Each backend needs to accept at least the C<name>,
51C<size>, C<image> and C<pub_ssh> parameters. The meaning
52of these parameters may differ from one backend to another.
53
54=head1 METHOS
55
56Each backend usually implements the following C<required>
57methods:
58
59=over
60
61=item create
62
63Creates a new server by given name, if such server does
64not exist.
65
66Installs the required packages for the distribution
67
68=item delete
69
70Gets rid of the server instance
71
72=item resize
73
74Hopefully scales the server
75
76=back
77
78=cut