Merge branch 'master' of p5sagit@git.shadowcat.co.uk:Oyster
Paul Tipper [Sat, 20 Nov 2010 19:28:57 +0000 (19:28 +0000)]
lib/Dist/Zilla/App/Command/provision.pm
lib/Oyster/Provision/Rackspace.pm

index 7f4160a..3df6420 100644 (file)
@@ -35,7 +35,7 @@ sub execute {
     
   my %hash = @hashes > 1 ? %{ merge( @hashes ) } : $hashes[0];
 
-  $hash{provision_backend} = delete $hash{type} || 'Rackspace';
+  $hash{provision_backend} = delete $hash{type} || 'Oyster::Provision::Rackspace';
   $hash{pub_ssh} ||= "$ENV{HOME}/.ssh/id_rsa.pub";
   $hash{size}    ||= 1;  # id 1 - ram 256 MiB - disk 10 GiB
   $hash{image}   ||= 69; # id 69 - Ubuntu 10.10 (meerkat)
@@ -43,6 +43,7 @@ sub execute {
   use Oyster::Provision;
   my $server = Oyster::Provision->new(
         name => $name,
+        config => \%hash,
         %hash,
   );
   $server->create;
index fff8bcd..6929a9a 100644 (file)
@@ -11,7 +11,7 @@ has 'api_username' => ( is => 'ro', isa => 'Str', required => 1, lazy_build => 1
 sub _build_api_username {
     return $ENV{CLOUDSERVERS_USER} if exists $ENV{CLOUDSERVERS_USER};
     confess "Need api_username or CLOUDSERVERS_USER in environment";
-});
+}
 
 has 'api_password' => ( is => 'ro', isa => 'Str', required => 1, lazy_build => 1);
 sub _build_api_password {
@@ -28,16 +28,6 @@ has '_rs' => ( is => 'rw', isa => 'Net::RackSpace::CloudServers', default => sub
     $rs;
 });
 
-after BUILD => sub {
-    my $self = shift;
-    # get api username and key from config?
-    my $config = $self->config;
-    
-
-    
-    # ...
-};
-
 sub create {
    my $self = shift;
 
@@ -57,16 +47,16 @@ sub create {
 
    # Build the server
    my $server = Net::RackSpace::CloudServers::Server->new(
-       cloudservers => $self->_cs,
-       name => $self->name,
-       flavor => $self->size,
-       image => $self->image,
-       personality => [
+      cloudservers => $self->_rs,
+      name         => $self->name,
+      flavorid     => $self->size,
+      imageid      => $self->image,
+      personality => [
            {
                path     => $self->pub_ssh,
                contents => encode_base64($pub_ssh),
            },
-       ],
+      ],
    );
    $server->create_server;