August 10, 2016


Get storage credentials for Block Storage

Retrieving the username and password for Performance/Endurance Block storage

The following script allows you retrieve the username and password for Performance/Endurance Block storage. If you have not autorized hosts against the storage then you will get some basic information about the Block storage as a result.

<?php

/* You can use the getenv() module to pull your exported Username
and API key to keep from having to store them in your files */ 

require_once './vendor/autoload.php';
$apiUsername = getenv('SOFTLAYER_USERNAME');
$apiKey = getenv('SOFTLAYER_API_KEY');
$storageid = '123456';

try {
    $client = \SoftLayer\SoapClient::getClient('SoftLayer_Network_Storage_Iscsi', $storageid, $apiUsername, $apiKey);
    $objectMask = new \SoftLayer\Common\ObjectMask();
    $objectMask->allowedHardware->allowedHost->credential;
    $objectMask->allowedVirtualGuests->allowedHost->credential;
    $client->setObjectMask($objectMask);

    $response = $client->getObject();

    print_r($response);

} catch(Exception $e) {
    echo 'Unable to get Storage credentials: ' . $e->getMessage();
}
?>

Feedback?

If this article contains any error, or leaves any of your questions unanswered, please help us out by opening up a github issue.
Open an issue