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