Skip to content

Instantly share code, notes, and snippets.

# So we can talk to the SoftLayer API:
import xmlrpclib
# For nice debug output:
import pprint
# API Connection Details.
# We're going to connect to two API services.
# Use SoftLayer_Virtual_Guest to get the order template from our
# CCI and use SoftLayer_Product_Order to verify and place an
# So we can talk to the SoftLayer API:
import SoftLayer.API
# For nice debug output:
import pprint
# Grab these from the SoftLayer portal.
username = "set me!"
apiKey = "set me too!"
<?php
/**
* Reboot a SoftLayer server
*
* Given a server id call the rebootDefault() method in the
* SoftLayer_Hardware_Server service to attempt to reboot the server via IPMI
* or its power strip if remote management is unavailable.
*
* This assumes the SoftLayer API PHP client
* <http://github.com/softlayer/softlayer-api-php-client> is installed in the
<?php
/**
* Order a new SoftLayer IP subnet
*
* Build a SoftLayer_Container_Product_Order_Network_Subnet object for a new
* IP subnet order and pass it to the SoftLayer_Product_Order API service to
* order it. See below for more details.
*
* This assumes the SoftLayer API PHP client
* <http://github.com/softlayer/softlayer-api-php-client> is installed in the
#!/usr/bin/perl
# Retrieve a list of hardware and print a report with server hostname, domain,
# login info, network, CPU, and RAM details.
#
# This script makes a single call to the getHardware() method in the
# SoftLayer_Account API service
# (http://sldn.softlayer.com/reference/services/SoftLayer_Account/getHardware)
# and uses an object mask to retrieve related information. It uses the
# SoftLayer API Perl client
<?php
/**
* Order a new server.
*
* Build a SoftLayer_Container_Product_Order_Hardware_Server object for a new
* server order and pass it to the SoftLayer_Product_Order API service to order
* it. In this care we'll order a Xeon 3060 server with 2G RAM, 100mbit NICs,
* 2000GB bandwidth, a 250G SATA drive, CentOS 5 64-bit, and default server
* order options. See below for more details.
*
"""
Perform a simple server OS reload.
Reload a server with its current operating system, software, and drive
partitions. SoftLayer provides a single method to perform a simple OS
reload. See the manual page for the reloadCurrentOperatingSystemConfiguration()
method in the SoftLayer_Hardware_Server API service
<http://sldn.softlayer.com/reference/services/SoftLayer_Hardware_Server/reloadCurrentOperatingSystemConfiguration>
for more information. Please perform server backups as necessary before
reloading your operating system.
"""
Perform a server OS reload with custom partitions.
Reload a server with its current operating system, software, but with custom
drive partitions. SoftLayer's standard reloadOperatingSystem() method in the
SoftLayer_Hardware_Server API service
<http://sldn.softlayer.com/reference/services/SoftLayer_Hardware_Server/reloadOperatingSystem>
takes care of the heavy lifting after you've defined your new drive partitions.
Please perform server backups as necessary before reloading your operating
system.
"""
Perform a server OS reload with a new operating system.
Reload a server with a new operating system, software, and a custom drive
partition scheme. In this case we're loading a server with Windows 2008 R2
Standard Edition, 64-bit with a 50G C: partition and a D: partition that fills
up the rest of the disk's free space. SoftLayer's standard
reloadOperatingSystem() method in the SoftLayer_Hardware_Server API service
<http://sldn.softlayer.com/reference/services/SoftLayer_Hardware_Server/reloadOperatingSystem>
takes care of the heavy lifting after you've defined your new software options
#!/usr/bin/perl
# Retrieve a list of switchport statistics for a server's network interfaces.
#
# This script makes a single call to the getPortStatistics() method in the
# SoftLayer_Network_Component API service
# (http://sldn.softlayer.com/reference/services/SoftLayer_NetworkComponent/getPortStatistics)
# for each of a server's network components to query port statistics for that
# interface from SoftLayer's switches. Port statistics are modeled by the
# SoftLayer__Container_Network_Port_Statistic data type
# (http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Network_Port_Statistic).