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'); |
11 | has '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 |
17 | sub 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 | |
27 | 1; |
40056462 |
28 | |
29 | __END__ |
30 | |
31 | =head1 NAME |
32 | |
33 | Oyster::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 | |
47 | By default, the L<Oyster::Provision::Rackspace> backend |
48 | will be used. |
49 | |
50 | Each backend needs to accept at least the C<name>, |
51 | C<size>, C<image> and C<pub_ssh> parameters. The meaning |
52 | of these parameters may differ from one backend to another. |
53 | |
54 | =head1 METHOS |
55 | |
56 | Each backend usually implements the following C<required> |
57 | methods: |
58 | |
59 | =over |
60 | |
61 | =item create |
62 | |
63 | Creates a new server by given name, if such server does |
64 | not exist. |
65 | |
66 | Installs the required packages for the distribution |
67 | |
68 | =item delete |
69 | |
70 | Gets rid of the server instance |
71 | |
72 | =item resize |
73 | |
74 | Hopefully scales the server |
75 | |
76 | =back |
77 | |
78 | =cut |