Created
June 9, 2013 10:34
-
-
Save ryanrhanson/5743075 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This relies on the Softlayer PHP API Client, available at https://github.com/softlayer/softlayer-api-php-client. | |
// Please make sure you have set this up before running the script. To run this, just drop it in the same directory | |
// as the "SoftLayer" folder and run 'php virtdisks.php' from the terminal. It will prompt for three things: | |
// API User - This is your SL Username | |
// API Key - Available at https://manage.softlayer.com/Administrative/apiKeychain or https://control.softlayer.com/account/user/profile/ | |
// apiconfig.php needs to have apiUsername, apiKey, and the path to the SLApi file that used to be in this script. | |
require_once('configuration/apiconfig.php'); | |
$client = SoftLayer_SoapClient::getClient('SoftLayer_Account', null, $apiUsername, $apiKey); | |
//Retrieve the account information (for the account ID) and the list of hardware servers on the account. | |
$accountInfo = $client->getObject(); | |
$hardware = $client->getHardware(); | |
//For each piece of hardware on the account, create a security scan request. | |
//This requires the account id, the hardware id, and the primary ip address. If it succeeds, it will output the scan id. | |
foreach ($hardware as $server){ | |
$scanclient = SoftLayer_SoapClient::getClient('SoftLayer_Network_Security_Scanner_Request', '', $apiUsername, $apiKey); | |
$scantemplate = new stdClass(); | |
$scantemplate->accountId = $accountInfo->id; | |
$scantemplate->hardwareId = $server->id; | |
$scantemplate->ipAddress = $server->primaryIpAddress; | |
try{ | |
$scan = $scanclient->createObject($scantemplate); | |
echo "Scan " . $scan->id . " successfully started!\n\r"; | |
} catch (Exception $e){ | |
echo $e->getMessage() . "\n\r"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment