Skip to content

Instantly share code, notes, and snippets.

@ryanrhanson
ryanrhanson / cancelsubnet.php
Created October 22, 2013 17:46
Cancel Subnet by IP
<?php
// Grab an IP address
$ip = readline("IP: ");
require_once dirname(__FILE__) . '/SoftLayer/SoapClient.class.php';
$apiUsername = 'set me';
$apiKey = 'set me too';
@ryanrhanson
ryanrhanson / dns_bulkAddARecords.php
Created June 18, 2013 03:49
Add A records in bulk to a dns zone.
<?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 dns_bulkAddARecords.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/
Domain name - Domain to modify
File name - File to read from, with following format:
$host $target
<?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');
@ryanrhanson
ryanrhanson / virtdisks.php
Last active December 18, 2015 00:38
Grabbing virtual block device and disk image info for cloud instances
<?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/
// Cloud Instance - The CCI Id, found by clicking on the CCI at https://manage.softlayer.com/CloudLayer/computing and examining the "viewinstance" url of the next page.
// This script will grab all block devices for the given CCI, then loop through them to grab further information, such as disk image capacity and so on.
@ryanrhanson
ryanrhanson / domdel.php
Last active December 16, 2015 04:29
Domain deletion script - Removes all dns zones on an account
<?php
$single_use = true;
if ($single_use) {
if(!isset($_SERVER['argv'][1]) || !isset($_SERVER['argv'][2])){
die("single_use is set, please supply API Username and Key");
}
require_once('SoftLayer/SoapClient.class.php');
$apiUsername = $argv[1];
$apiKey = $argv[2];
@ryanrhanson
ryanrhanson / ccikvm.php
Last active December 14, 2015 22:29
Retrieve all CCI KVM IPs and ports on an account, along with root password on file (as this should be kvm password)
<?php
/*
/ ccikvm.php - Used to pull KVM credentials for all cloud instances on an account.
/ With single_use true, you need to supply the api username and password as the first and second arguments.
/ This assumes that you have ccikvm.php in the same directory as the 'SoftLayer' folder in the PHP api client.
/ Syntax: php ccikvm.php $apiUsername $apiKey
/
/ If single_use is false, this will look for configuration/apiconfig.php, which will need to contain the
/ apiUsername, apiKey, and the path to the SoftLayer php client directory. Only useful if you have a lot
/ of scripts to work with.
@ryanrhanson
ryanrhanson / dns.php
Last active December 14, 2015 16:29
Loop through dns records on account, storing them in 'zones/$domain.tld.db'
<?php
/*
This script will take all dns records on a SoftLayer account and create a dns zone file for them in the 'zones' subdirectory. If this subdirectory does not exist, it will be created.
If single_use is set to true, you can supply your API Username and Key as arguments to the script. single_use also assumes that it is in the same directory as the SoftLayer folder from the PHP API Client. If single_use is false, it will draw from a file in the 'configuration' subdirectory named apiconfig.php, which should define apiUsername, apiKey, and the path to the SoapClient.class.php file.
*/
$single_use = true;
if ($single_use) {
require_once('SoftLayer/SoapClient.class.php');