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