Permalink
Browse files

Tidied up

  • Loading branch information...
1 parent 6519a36 commit 71e161807e9241750ace9e64d9a033a15483b789 @mfontani committed Jul 18, 2009
Showing with 21 additions and 29 deletions.
  1. +7 −16 lib/Net/RackSpace/CloudServers/Server.pm
  2. +3 −3 scripts/changename.pl
  3. +2 −2 scripts/changerootpass.pl
  4. +9 −8 scripts/serverinfo.pl
@@ -25,42 +25,33 @@ __PACKAGE__->meta->make_immutable();
sub change_root_password {
my $self = shift;
my $password = shift;
- my $uri = '/servers/' . $self->id;
- my $request = HTTP::Request->new(
+ my $uri = '/servers/' . $self->id;
+ my $request = HTTP::Request->new(
'PUT',
$self->cloudservers->server_management_url . $uri,
[ 'X-Auth-Token' => $self->cloudservers->token ],
- to_json({
- server => {
- adminPass => $password,
- }
- })
+ to_json( { server => { adminPass => $password, } } )
);
my $response = $self->cloudservers->_request($request);
confess 'Unknown error' if $response->code != 202;
return $response;
}
sub change_name {
- my $self = shift;
- my $name = shift;
- my $uri = '/servers/' . $self->id;
+ my $self = shift;
+ my $name = shift;
+ my $uri = '/servers/' . $self->id;
my $request = HTTP::Request->new(
'PUT',
$self->cloudservers->server_management_url . $uri,
[ 'X-Auth-Token' => $self->cloudservers->token ],
- to_json({
- server => {
- name => $name,
- }
- })
+ to_json( { server => { name => $name, } } )
);
my $response = $self->cloudservers->_request($request);
confess 'Unknown error' if $response->code != 202;
return $response;
}
-
=head1 NAME
Net::RackSpace::CloudServers::Server - a RackSpace CloudServers Server instance
View
@@ -16,12 +16,12 @@
my @images = $CS->get_image_detail;
my @servers = $CS->get_server_detail;
-my $srvapi = (grep {$_->name eq 'apitest'} @servers)[0];
-die "can't find server named 'apitest'. Create one." if (!defined $srvapi);
+my $srvapi = ( grep { $_->name eq 'apitest' } @servers )[0];
+die "can't find server named 'apitest'. Create one." if ( !defined $srvapi );
print "changing server name..\n";
$srvapi->change_name('apitest2');
print "Changed\n";
@servers = $CS->get_server_detail;
-$srvapi = (grep {$_->name eq 'apitest'} @servers)[0];
+$srvapi = ( grep { $_->name eq 'apitest' } @servers )[0];
print "Done\n";
@@ -16,8 +16,8 @@
my @images = $CS->get_image_detail;
my @servers = $CS->get_server_detail;
-my $srvapi = (grep {$_->name eq 'apitest'} @servers)[0];
-die "can't find server named 'apitest'. Create one." if (!defined $srvapi);
+my $srvapi = ( grep { $_->name eq 'apitest' } @servers )[0];
+die "can't find server named 'apitest'. Create one." if ( !defined $srvapi );
print "changing root password..\n";
$srvapi->change_root_password('toor');
View
@@ -16,19 +16,20 @@
my @images = $CS->get_image_detail;
my @servers = $CS->get_server_detail;
-print '#'x72, "\n";
+print '#' x 72, "\n";
foreach my $server (@servers) {
print "Server ID ", $server->id, " Name ", $server->name, "\n";
- print "Server status ", $server->status || 'undef', " progress ", $server->progress || 'undef', "\n";
- print "Public IPs: ", join(' ', @{ $server->public_address || () } ), "\n";
- print "Private IPs: ", join(' ', @{ $server->private_address || () } ), "\n";
- my $img = (grep {$_->id == $server->imageid} @images)[0]; # find image by id
- die "Can't find image ID ", $server->imageid, " on list" if (!defined $img);
+ print "Server status ", $server->status || 'undef', " progress ", $server->progress || 'undef',
+ "\n";
+ print "Public IPs: ", join( ' ', @{ $server->public_address || () } ), "\n";
+ print "Private IPs: ", join( ' ', @{ $server->private_address || () } ), "\n";
+ my $img = ( grep { $_->id == $server->imageid } @images )[0]; # find image by id
+ die "Can't find image ID ", $server->imageid, " on list" if ( !defined $img );
print "Image ID ", $server->imageid, " (", $img->name, ")",
" status ", $img->status || 'undef', " progress ", $img->progress || 'undef', "\n";
- my $flv = (grep {$_->id == $server->flavorid} @flavors)[0]; # find flavor by id
- die "Can't find flavor ID ", $server->flavorid, " on list" if (!defined $flv);
+ my $flv = ( grep { $_->id == $server->flavorid } @flavors )[0]; # find flavor by id
+ die "Can't find flavor ID ", $server->flavorid, " on list" if ( !defined $flv );
print "Flavor ID ", $server->flavorid, " (", $flv->name, ")",
" ram ", $flv->ram || 'undef', " disk ", $flv->disk || 'undef', "\n";
}

0 comments on commit 71e1618

Please sign in to comment.