X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FOyster%2FProvision%2FRackspace.pm;h=f1127d194be408024e978dee4573fd6e904eacb7;hb=e4c303246b11e0ccd6606d601a9c3e5836c95474;hp=66d9ade3fff437ddfb5df2cfe80568968e11d1ff;hpb=fd5557b21d84b7b9552a65c23ff441b7cd95b339;p=p5sagit%2FOyster.git diff --git a/lib/Oyster/Provision/Rackspace.pm b/lib/Oyster/Provision/Rackspace.pm index 66d9ade..f1127d1 100644 --- a/lib/Oyster/Provision/Rackspace.pm +++ b/lib/Oyster/Provision/Rackspace.pm @@ -7,15 +7,17 @@ use MIME::Base64; requires 'config'; -has 'api_username' => ( is => 'ro', isa => 'Str', required => 1, default => sub { +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, default => sub { +has 'api_password' => ( is => 'ro', isa => 'Str', required => 1, lazy_build => 1); +sub _build_api_password { return $ENV{CLOUDSERVERS_KEY} if exists $ENV{CLOUDSERVERS_KEY}; confess "Need api_password or CLOUDSERVERS_KEY in environment"; -}); +} has '_rs' => ( is => 'rw', isa => 'Net::RackSpace::CloudServers', default => sub { my $self = shift; @@ -26,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; @@ -55,7 +47,7 @@ sub create { # Build the server my $server = Net::RackSpace::CloudServers::Server->new( - cloudservers => $self->_cs, + cloudservers => $self->_rs, name => $self->name, flavor => $self->size, image => $self->image,