attempting to fix ::Provision
[p5sagit/Oyster.git] / lib / Oyster / Provision.pm
index 2b82200..38b8b43 100644 (file)
@@ -2,18 +2,73 @@ package Oyster::Provision;
 
 use Moose;
 
-sub config {
-    return {provision_backend => 'Oyster::Provision::Rackspace'};
-}
+has 'api_username' => ( is => 'ro', isa => 'Str');
+has 'api_password' => ( is => 'ro', isa => 'Str');
+has 'name'    => ( is => 'ro', isa => 'Str');
+has 'size'    => ( is => 'ro', isa => 'Str');
+has 'image'   => ( is => 'ro', isa => 'Str');
+has 'pub_ssh' => ( is => 'ro', isa => 'Str');
+has 'provision_backend'  => (is => 'rw', isa => 'Str', required => 1, default => 'Oyster::Provision::Rackspace' );
 
 sub BUILD {
 
     my $self = shift;
 
-    my $role = $self->config()->{provision_backend};
-
+    my $role = $self->provision_backend;
+    
     eval "use $role";
     "$role"->meta->apply($self);
 }
 
 1;
+
+__END__
+
+=head1 NAME
+
+Oyster::Provision - Provision an Oyster
+
+=head1 SYNOPSIS
+
+    my $server = Oyster::Provision->new(
+        name => 'Ostrica',
+        size => '256',
+        image => 'Meerkat',
+        pub_ssh => "$ENV{HOME}/.ssh/id_rsa.pub",
+    );
+    $server->create;
+
+=head1 BACKENDS
+
+By default, the L<Oyster::Provision::Rackspace> backend
+will be used.
+
+Each backend needs to accept at least the C<name>,
+C<size>, C<image> and C<pub_ssh> parameters. The meaning
+of these parameters may differ from one backend to another.
+
+=head1 METHOS
+
+Each backend usually implements the following C<required>
+methods:
+
+=over
+
+=item create
+
+Creates a new server by given name, if such server does
+not exist.
+
+Installs the required packages for the distribution
+
+=item delete
+
+Gets rid of the server instance
+
+=item resize
+
+Hopefully scales the server
+
+=back
+
+=cut