SoftLayer.hardware

Hardware Manager/helpers

license:MIT, see LICENSE for more details.
class SoftLayer.managers.hardware.HardwareManager(client, ordering_manager=None)[source]

Manage SoftLayer hardware servers.

Example:

# Initialize the Manager.
# env variables. These can also be specified in ~/.softlayer,
# or passed directly to SoftLayer.Client()
# SL_USERNAME = YOUR_USERNAME
# SL_API_KEY = YOUR_API_KEY
import SoftLayer
client = SoftLayer.Client()
mgr = SoftLayer.HardwareManager(client)

See product information here: http://www.softlayer.com/bare-metal-servers

Parameters:
  • client (SoftLayer.API.BaseClient) – the client instance
  • ordering_manager (SoftLayer.managers.OrderingManager) – an optional manager to handle ordering. If none is provided, one will be auto initialized.
cancel_hardware(hardware_id, reason='unneeded', comment='', immediate=False)[source]

Cancels the specified dedicated server.

Example:

# Cancels hardware id 1234
result = mgr.cancel_hardware(hardware_id=1234)
Parameters:
  • hardware_id (int) – The ID of the hardware to be cancelled.
  • reason (string) – The reason code for the cancellation. This should come from get_cancellation_reasons().
  • comment (string) – An optional comment to include with the cancellation.
change_port_speed(hardware_id, public, speed)[source]

Allows you to change the port speed of a server’s NICs.

Parameters:
  • hardware_id (int) – The ID of the server
  • public (bool) – Flag to indicate which interface to change. True (default) means the public interface. False indicates the private interface.
  • speed (int) – The port speed to set.

Warning

A port speed of 0 will disable the interface.

Example:

#change the Public interface to 10Mbps on instance 12345
result = mgr.change_port_speed(hardware_id=12345,
                               public=True, speed=10)
# result will be True or an Exception
edit(hardware_id, userdata=None, hostname=None, domain=None, notes=None, tags=None)[source]

Edit hostname, domain name, notes, user data of the hardware.

Parameters set to None will be ignored and not attempted to be updated.

Parameters:
  • hardware_id (integer) – the instance ID to edit
  • userdata (string) – user data on the hardware to edit. If none exist it will be created
  • hostname (string) – valid hostname
  • domain (string) – valid domain name
  • notes (string) – notes about this particular hardware
  • tags (string) – tags to set on the hardware as a comma separated list. Use the empty string to remove all tags.

Example:

# Change the hostname on instance 12345 to 'something'
result = mgr.edit(hardware_id=12345 , hostname="something")
#result will be True or an Exception
get_cancellation_reasons()[source]

Returns a dictionary of valid cancellation reasons.

These can be used when cancelling a dedicated server via cancel_hardware().

get_create_options(*args, **kwargs)[source]

Returns valid options for ordering hardware.

get_hardware(*args, **kwargs)[source]

Get details about a hardware device.

Parameters:id (integer) – the hardware ID
Returns:A dictionary containing a large amount of information about the specified server.

Example:

object_mask = "mask[id,networkVlans[vlanNumber]]"
# Object masks are optional
result = mgr.get_hardware(hardware_id=1234,mask=object_mask)
list_hardware(*args, **kwargs)[source]

List all hardware (servers and bare metal computing instances).

param list tags:
 filter based on tags
param integer cpus:
 filter based on number of CPUS
param integer memory:
 filter based on amount of memory in gigabytes
param string hostname:
 filter based on hostname
param string domain:
 filter based on domain
param string datacenter:
 filter based on datacenter
param integer nic_speed:
 filter based on network speed (in MBPS)
param string public_ip:
 filter based on public ip address
param string private_ip:
 filter based on private ip address
param dict **kwargs:
 response-level options (mask, limit, etc.)
returns:Returns a list of dictionaries representing the matching hardware. This list will contain both dedicated servers and bare metal computing instances

Example:

# Using a custom object-mask. Will get ONLY what is specified
# These will stem from the SoftLayer_Hardware_Server datatype
object_mask = "mask[hostname,monitoringRobot[robotStatus]]"
result = mgr.list_hardware(mask=object_mask)
place_order(**kwargs)[source]

Places an order for a piece of hardware.

See get_create_options() for valid arguments.

Parameters:
  • size (string) – server size name
  • hostname (string) – server hostname
  • domain (string) – server domain name
  • location (string) – location (datacenter) name
  • os (string) – operating system name
  • port_speed (int) – Port speed in Mbps
  • ssh_keys (list) – list of ssh key ids
  • post_uri (string) – The URI of the post-install script to run after reload
  • hourly (boolean) – True if using hourly pricing (default). False for monthly.
  • no_public (boolean) – True if this server should only have private interfaces
  • extras (list) – List of extra feature names
reload(hardware_id, post_uri=None, ssh_keys=None)[source]

Perform an OS reload of a server with its current configuration.

Parameters:
  • hardware_id (integer) – the instance ID to reload
  • post_url (string) – The URI of the post-install script to run after reload
  • ssh_keys (list) – The SSH keys to add to the root user
rescue(hardware_id)[source]

Reboot a server into the a recsue kernel.

Parameters:instance_id (integer) – the server ID to rescue

Example:

result = mgr.rescue(1234)
resolve_ids(identifier)

Takes a string and tries to resolve to a list of matching ids.

What exactly ‘identifier’ can be depends on the resolvers

Parameters:identifier (string) – identifying string
Returns list:
update_firmware(hardware_id, ipmi=True, raid_controller=True, bios=True, hard_drive=True)[source]

Update hardware firmware.

This will cause the server to be unavailable for ~20 minutes.

Parameters:
  • hardware_id (int) – The ID of the hardware to have its firmware updated.
  • ipmi (bool) – Update the ipmi firmware.
  • raid_controller (bool) – Update the raid controller firmware.
  • bios (bool) – Update the bios firmware.
  • hard_drive (bool) – Update the hard drive firmware.

Example:

# Check the servers active transactions to see progress
result = mgr.update_firmware(hardware_id=1234)
verify_order(**kwargs)[source]

Verifies an order for a piece of hardware.

See place_order() for a list of available options.