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