Hardware Manager/helpers
copyright: |
|
---|---|
license: | MIT, see LICENSE for more details. |
Manages hardware devices.
Parameters: | client (SoftLayer.API.Client) – an API client instance |
---|
Reference to the SoftLayer_Account API object.
Cancels the specified dedicated server.
Parameters: |
|
---|
Cancels the specified bare metal instance.
Parameters: |
|
---|
Allows you to change the port speed of a server’s NICs.
Parameters: |
|
---|
A valid SoftLayer.API.Client object that will be used for all actions.
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: |
|
---|
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) |
---|
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.
Returns a dictionary of valid cancellation reasons that can be used when cancelling a dedicated server via cancel_hardware().
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 details about a hardware device
Parameters: | id (integer) – the hardware ID |
---|---|
Returns: | A dictionary containing a large amount of information about the specified server. |
Reference to the SoftLayer_Hardware_Server API object.
List all hardware (servers and bare metal computing instances).
Parameters: |
|
---|---|
Returns: | Returns a list of dictionaries representing the matching hardware. This list will contain both dedicated servers and bare metal computing instances |
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)
Perform an OS reload of a server with its current configuration.
Parameters: |
|
---|
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: |
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.
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. |
---|