Skip to content

Instantly share code, notes, and snippets.

@ryanrhanson
Created February 10, 2014 19:10
Show Gist options
  • Save ryanrhanson/8922202 to your computer and use it in GitHub Desktop.
Save ryanrhanson/8922202 to your computer and use it in GitHub Desktop.
Server Info Dumper, with ipmi and os credentials included.
# This is optional and can be removed if you already have the SoftLayer
# directory that contains this module in your @INC path.
use lib 'Softlayer';
use SoftLayer::API::SOAP;
use Data::Dumper;
my %config = do 'apiconfig.pl';
# Initialize an API client for the SoftLayer_Account service.
my $client = SoftLayer::API::SOAP->new('SoftLayer_Account','',$config{apiUser},$config{apiKey});
# New style object mask, grabs only the information we actually want. This will grab the following:
# Account - Company Name
# Servers - ID, Fully Qualified Domain Name, IPMI IP, Primary Public IP, Primary Private IP, Operating System Long Description, IPMI Credentials, OS Credentials (with ID).
$mask = 'mask[companyName,hardware[id,fullyQualifiedDomainName,networkManagementIpAddress,primaryIpAddress,primaryBackendIpAddress,operatingSystem[id,passwords[username,password,id],softwareLicense[softwareDescription[longDescription]]],remoteManagementAccounts]]';
$client->setObjectMask($mask);
# Retrieve our account record
my $account = $client->getObject();
if ($account->fault) {
die 'Unable to retrieve account information: ' . $account->faultstring;
} else {
print "Server information for " . $account->result->{'companyName'} . "\n";
print "=====\n";
foreach my $server ( @{$account->result->{'hardware'} } ) {
print "Server ID: " . $server->{'id'} . "\n";
print "FQDN: " . $server->{'fullyQualifiedDomainName'} . "\n";
print "Public IP: " . $server->{'primaryIpAddress'} . "\n";
print "Private IP: " . $server->{'primaryBackendIpAddress'} . "\n";
print "OS: " . $server->{'operatingSystem'}->{'softwareLicense'}->{'softwareDescription'}->{'longDescription'} . "\n";
print "Credentials - \n";
foreach my $creds ( @{$server->{'operatingSystem'}->{'passwords'}} ){
print " - Password Object ID: " . $creds->{'id'} . "\n";
print " - Username: " . $creds->{'username'} . "\n";
print " - Password: " . $creds->{'password'} . "\n";
print " - --- \n";
}
print "IPMI IP: " . $server->{'networkManagementIpAddress'} . "\n";
print "IPMI Credentials - \n";
foreach my $ipmiCreds ( @{$server->{'remoteManagementAccounts'}} ) {
print " - Username: " . $ipmiCreds->{'username'} . "\n";
print " - Password: " . $ipmiCreds->{'password'} . "\n";
}
print "\n =-=-=-= \n";
}
}
@nothinman
Copy link

Thanks Ryan! -- I will give this a try tomorrow when I get to work. Martin @ Product Madness

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment