SoftLayer.hardware

Hardware Manager/helpers

copyright:
  1. 2013, SoftLayer Technologies, Inc. All rights reserved.
license:

MIT, see LICENSE for more details.

class SoftLayer.managers.hardware.HardwareManager(client)[source]

Manages hardware devices.

Parameters:client (SoftLayer.API.Client) – an API client instance
account = None

Reference to the SoftLayer_Account API object.

cancel_hardware(hardware_id, reason='unneeded', comment='')[source]

Cancels the specified dedicated server.

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.
cancel_metal(hardware_id, immediate=False)[source]

Cancels the specified bare metal instance.

Parameters:
  • id (int) – The ID of the bare metal instance to be cancelled.
  • immediate (bool) – If true, the bare metal instance will be cancelled immediately. Otherwise, it will be scheduled to cancel on the anniversary date.
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.
client = None

A valid SoftLayer.API.Client object that will be used for all actions.

edit(hardware_id, userdata=None, hostname=None, domain=None, notes=None)[source]

Edit hostname, domain name, notes, and/or the 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 namem
  • notes (string) – notes about this particular hardware
get_available_dedicated_server_packages()[source]

Retrieves a list of packages that are available for ordering dedicated servers.

Returns:A list of tuples of available dedicated server packages in the form (id, name, description)
get_bare_metal_create_options()[source]

Retrieves the available options for creating a bare metal server.

Returns:A dictionary of creation options. The categories to order are contained within the ‘categories’ key. See _parse_package_data() for detailed information.

Note

The information for ordering bare metal instances comes from multiple API calls. In order to make the process easier, this function will make those calls and reformat the results into a dictionary that’s easier to manage. It’s recommended that you cache these results with a reasonable lifetime for performance reasons.

get_cancellation_reasons()[source]

Returns a dictionary of valid cancellation reasons that can be used when cancelling a dedicated server via cancel_hardware().

get_dedicated_server_create_options(package_id)[source]

Retrieves the available options for creating a dedicated server in a specific chassis (based on package ID).

Parameters:package_id (int) – The package ID to retrieve the creation options for. This should come from get_available_dedicated_server_packages().
Returns:A dictionary of creation options. The categories to order are contained within the ‘categories’ key. See _parse_package_data() for detailed information.

Note

The information for ordering dedicated servers comes from multiple API calls. In order to make the process simpler, this function will make those calls and reformat the results into a dictionary that’s easier to manage. It’s recommended that you cache these results with a reasonable lifetime for performance reasons.

get_hardware(hardware_id, **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.
hardware = None

Reference to the SoftLayer_Hardware_Server API object.

list_hardware(tags=None, cpus=None, memory=None, hostname=None, domain=None, datacenter=None, nic_speed=None, public_ip=None, private_ip=None, **kwargs)[source]

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

Parameters:
  • tags (list) – filter based on tags
  • cpus (integer) – filter based on number of CPUS
  • memory (integer) – filter based on amount of memory in gigabytes
  • hostname (string) – filter based on hostname
  • domain (string) – filter based on domain
  • datacenter (string) – filter based on datacenter
  • nic_speed (integer) – filter based on network speed (in MBPS)
  • public_ip (string) – filter based on public ip address
  • private_ip (string) – filter based on private ip address
  • **kwargs (dict) – response-level arguments (limit, offset, etc.)
Returns:

Returns a list of dictionaries representing the matching hardware. This list will contain both dedicated servers and bare metal computing instances

place_order(**kwargs)[source]

Places an order for a piece of hardware. See _generate_create_dict() for a list of available options.

Warning

Due to how the ordering structure currently works, all ordering takes place using price IDs rather than quantities. See the following sample for an example of using HardwareManager functions for ordering a basic server.

# client is assumed to be an initialized SoftLayer.API.Client object
mgr = HardwareManager(client)

# Package ID 32 corresponds to the 'Quad Processor, Quad Core Intel'
# package. This information can be obtained from the
# :func:`get_available_dedicated_server_packages` function.
options = mgr.get_dedicated_server_create_options(32)

# Review the contents of options to find the information that
# applies to your order. For the sake of this example, we assume
# that your selections are a series of item IDs for each category
# organized into a key-value dictionary.

# This contains selections for all required categories
selections = {
    'server': 542, # Quad Processor Quad Core Intel 7310 - 1.60GHz
    'pri_ip_addresses': 15, # 1 IP Address
    'notification': 51, # Email and Ticket
    'ram': 280, # 16 GB FB-DIMM Registered 533/667
    'bandwidth': 173, # 5000 GB Bandwidth
    'lockbox': 45, # 1 GB Lockbox
    'monitoring': 49, # Host Ping
    'disk0': 14, # 500GB SATA II (for the first disk)
    'response': 52, # Automated Notification
    'port_speed': 187, # 100 Mbps Public & Private Networks
    'power_supply': 469, # Redundant Power Supplies
    'disk_controller': 487, # Non-RAID
    'vulnerability_scanner': 307, # Nessus
    'vpn_management': 309, # Unlimited SSL VPN Users
    'remote_management': 504, # Reboot / KVM over IP
    'os': 4166, # Ubuntu Linux 12.04 LTS Precise Pangolin (64 bit)
}

args = {
    'location': 'FIRST_AVAILABLE', # Pick the first available DC
    'disks': [],
}

for cat, item_id in selections:
    for item in options['categories'][cat]['items'].items():
        if item['id'] == item_id:
            if 'disk' not in cat or 'disk_controller' == cat:
                args[cat] = item['price_id']
            else:
                args['disks'].append(item['price_id'])

# You can call :func:`verify_order` here to test the order instead
# of actually placing it if you prefer.
result = mgr.place_order(**args)
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
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:
resolvers = []

A list of resolver functions. Used primarily by the CLI to provide a variety of methods for uniquely identifying an object such as hostname and IP address.

verify_order(**kwargs)[source]

Verifies an order for a piece of hardware without actually placing it. See _generate_create_dict() for a list of available options.

SoftLayer.managers.hardware.get_default_value(package_options, category)[source]

Returns the default price ID for the specified category.

This determination is made by parsing the items in the package_options argument and finding the first item that has zero specified for every fee field.

Note

If the category has multiple items with no fee, this will return the first it finds and then short circuit. This may not match the default value presented on the SoftLayer ordering portal. Additionally, this method will return None if there are no free items in the category.

Returns:Returns the price ID of the first free item it finds or None if there are no free items.
Read the Docs v: v3.0.2
Versions
latest
v3.0.2
v3.0.1
v3.0.0
v2.3.1
v2.3.0
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.