SoftLayer API Python Client latest¶
API Docs |
GitHub |
Issues |
Pull Requests |
PyPI |
This is the documentation to SoftLayer’s Python API Bindings. These bindings use SoftLayer’s XML-RPC interface in order to manage SoftLayer services.
Installation¶
What’s Included¶
When you install softlayer-python you you will get the following:
- a python package called ‘SoftLayer’ (casing is important) available in your python path.
- a command-line client placed in your system path named ‘slcli’.
Debian/Ubuntu¶
For Debian “jessie” (currently testing) and Ubuntu 14.04, official system packages are available. These are typically a couple versions behind so it is recommended to install from pypi if problems are encountered.
$ sudo apt-get install python-softlayer
From Source¶
The project is developed on GitHub, at https://github.com/softlayer/softlayer-python.
Install from source via pip (requires git):
$ pip install git+git://github.com/softlayer/softlayer-python.git
You can clone the public repository:
$ git clone git@github.com:softlayer/softlayer-python.git
Or, Download the tarball:
$ curl -OL https://github.com/softlayer/softlayer-python/tarball/master
Or, download the zipball:
$ curl -OL https://github.com/softlayer/softlayer-python/zipball/master
Once you have a copy of the source you can install it with one of the following commands:
$ python setup.py install
Or:
$ pip install .
For more information about working with the source, or contributing to the project, please see the Contribution Guide.
Configuration File¶
The SoftLayer API bindings load your settings from a number of different locations.
- Input directly into SoftLayer.create_client_from_env(…)
- Enviorment variables (SL_USERNAME, SL_API_KEY)
- Config file locations (~/.softlayer, /etc/softlayer.conf)
- Or argument (-C/path/to/config or –config=/path/to/config)
The configuration file is INI-based and requires the softlayer section to be present. The only required fields are username and api_key. You can optionally supply the endpoint_url as well. This file is created automatically by the slcli setup command detailed here: Configuration Setup.
Config Example
[softlayer]
username = username
api_key = oyVmeipYQCNrjVS4rF9bHWV7D75S6pa1fghFl384v7mwRCbHTfuJ8qRORIqoVnha
endpoint_url = https://api.softlayer.com/xmlrpc/v3/
timeout = 40
Cloud.ibm.com Config Example
[softlayer]
username = apikey
api_key = 123cNyhzg45Ab6789ADyzwR_2LAagNVbySgY73tAQOz1
endpoint_url = https://api.softlayer.com/rest/v3.1/
timeout = 40
API Documentation¶
This is the primary API client to make API calls. It deals with constructing and executing XML-RPC calls against the SoftLayer API. Below are some links that will help to use the SoftLayer API.
>>> import SoftLayer
>>> client = SoftLayer.create_client_from_env(username="username", api_key="api_key")
>>> resp = client.call('Account', 'getObject')
>>> resp['companyName']
'Your Company'
Getting Started¶
You can pass in your username and api_key when creating a SoftLayer client instance. However, you can also set these in the environmental variables ‘SL_USERNAME’ and ‘SL_API_KEY’.
Creating a client instance by passing in the username/api_key:
import SoftLayer
client = SoftLayer.create_client_from_env(username='YOUR_USERNAME', api_key='YOUR_API_KEY')
Creating a client instance with environmental variables set:
$ export SL_USERNAME=YOUR_USERNAME
$ export SL_API_KEY=YOUR_API_KEY
$ python
>>> import SoftLayer
>>> client = SoftLayer.create_client_from_env()
Below is an example of creating a client instance with more options. This will create a client with the private API endpoint (only accessible from the SoftLayer private network) and a timeout of 4 minutes.
client = SoftLayer.create_client_from_env(username='YOUR_USERNAME',
api_key='YOUR_API_KEY'
endpoint_url=SoftLayer.API_PRIVATE_ENDPOINT,
timeout=240)
Managers¶
For day-to-day operation, most users will find the managers to be the most convenient means for interacting with the API. Managers abstract a lot of the complexities of using the API into classes that provide a simpler interface to various services. These are higher-level interfaces to the SoftLayer API.
from SoftLayer import VSManager, Client
client = Client(...)
vs = VSManager(client)
vs.list_instances()
[...]
Available managers:
SoftLayer.account¶
Account manager
license: | MIT, see License for more details. |
---|
-
class
SoftLayer.managers.account.
AccountManager
(client)[source]¶ Common functions for getting information from the Account service
Parameters: client (SoftLayer.API.BaseClient) – the client instance -
ack_event
(event_id)[source]¶ Acknowledge an event. This mostly prevents it from appearing as a notification in the control portal.
Parameters: event_id (int) – Notification_Occurrence_Event ID you want to ack Returns: True on success, Exception otherwise.
-
get_billing_items
(identifier)[source]¶ Gets all topLevelBillingItems from a specific invoice
Parameters: identifier (int) – Invoice Id Returns: Billing_Invoice_Item
-
get_event
(event_id)[source]¶ Gets details about a maintenance event
Parameters: event_id (int) – Notification_Occurrence_Event ID Returns: Notification_Occurrence_Event
-
get_invoices
(limit=50, closed=False, get_all=False)[source]¶ Gets an accounts invoices.
Parameters: - limit (int) – Number of invoices to get back in a single call.
- closed (bool) – If True, will also get CLOSED invoices
- get_all (bool) – If True, will paginate through invoices until all have been retrieved.
Returns: Billing_Invoice
-
get_upcoming_events
()[source]¶ Retreives a list of Notification_Occurrence_Events that have not ended yet
Returns: SoftLayer_Notification_Occurrence_Event
-
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:
-
SoftLayer.block¶
Block Storage Manager
license: | MIT, see LICENSE for more details. |
---|
-
class
SoftLayer.managers.block.
BlockStorageManager
(client)[source]¶ Manages SoftLayer Block Storage volumes.
See product information here: http://www.softlayer.com/block-storage
Parameters: client (SoftLayer.API.BaseClient) – the client instance Authorizes hosts to Block Storage Volumes
Parameters: - volume_id – The Block volume to authorize hosts to
- hardware_ids – A List of SoftLayer_Hardware ids
- virtual_guest_ids – A List of SoftLayer_Virtual_Guest ids
- ip_address_ids – A List of SoftLayer_Network_Subnet_IpAddress ids
Returns: Returns an array of SoftLayer_Network_Storage_Allowed_Host objects which now have access to the given Block volume
-
cancel_block_volume
(volume_id, reason='No longer needed', immediate=False)[source]¶ Cancels the given block storage volume.
Parameters: - volume_id (integer) – The volume ID
- reason (string) – The reason for cancellation
- immediate_flag (boolean) – Cancel immediately or on anniversary date
-
cancel_snapshot_space
(volume_id, reason='No longer needed', immediate=False)[source]¶ Cancels snapshot space for a given volume.
Parameters: - volume_id (integer) – The volume ID
- reason (string) – The reason for cancellation
- immediate_flag (boolean) – Cancel immediately or on anniversary date
-
create_or_update_lun_id
(volume_id, lun_id)[source]¶ Set the LUN ID on a volume.
Parameters: - volume_id (integer) – The id of the volume
- lun_id (integer) – LUN ID to set on the volume
Returns: a SoftLayer_Network_Storage_Property object
-
create_snapshot
(volume_id, notes='', **kwargs)[source]¶ Creates a snapshot on the given block volume.
Parameters: - volume_id (integer) – The id of the volume
- notes (string) – The notes or “name” to assign the snapshot
Returns: Returns the id of the new snapshot
Revokes authorization of hosts to Block Storage Volumes
Parameters: - volume_id – The Block volume to deauthorize hosts to
- hardware_ids – A List of SoftLayer_Hardware ids
- virtual_guest_ids – A List of SoftLayer_Virtual_Guest ids
- ip_address_ids – A List of SoftLayer_Network_Subnet_IpAddress ids
Returns: Returns an array of SoftLayer_Network_Storage_Allowed_Host objects which have access to the given Block volume
-
delete_snapshot
(snapshot_id)[source]¶ Deletes the specified snapshot object.
Parameters: snapshot_id – The ID of the snapshot object to delete.
-
disable_snapshots
(volume_id, schedule_type)[source]¶ Disables snapshots for a specific block volume at a given schedule
Parameters: - volume_id (integer) – The id of the volume
- schedule_type (string) – ‘HOURLY’|’DAILY’|’WEEKLY’
Returns: Returns whether successfully disabled or not
-
enable_snapshots
(volume_id, schedule_type, retention_count, minute, hour, day_of_week, **kwargs)[source]¶ Enables snapshots for a specific block volume at a given schedule
Parameters: - volume_id (integer) – The id of the volume
- schedule_type (string) – ‘HOURLY’|’DAILY’|’WEEKLY’
- retention_count (integer) – Number of snapshots to be kept
- minute (integer) – Minute when to take snapshot
- hour (integer) – Hour when to take snapshot
- day_of_week (string) – Day when to take snapshot
Returns: Returns whether successfully scheduled or not
-
failback_from_replicant
(volume_id, replicant_id)[source]¶ Failback from a volume replicant.
Parameters: - volume_id (integer) – The id of the volume
- replicant_id (integer) – ID of replicant to failback from
Returns: Returns whether failback was successful or not
-
failover_to_replicant
(volume_id, replicant_id, immediate=False)[source]¶ Failover to a volume replicant.
Parameters: - volume_id (integer) – The id of the volume
- replicant_id (integer) – ID of replicant to failover to
- immediate (boolean) – Flag indicating if failover is immediate
Returns: Returns whether failover was successful or not
-
get_block_volume_access_list
(volume_id, **kwargs)[source]¶ Returns a list of authorized hosts for a specified volume.
Parameters: - volume_id – ID of volume.
- kwargs –
Returns: Returns a list of authorized hosts for a specified volume.
-
get_block_volume_details
(volume_id, **kwargs)[source]¶ Returns details about the specified volume.
Parameters: - volume_id – ID of volume.
- kwargs –
Returns: Returns details about the specified volume.
-
get_block_volume_snapshot_list
(volume_id, **kwargs)[source]¶ Returns a list of snapshots for the specified volume.
Parameters: - volume_id – ID of volume.
- kwargs –
Returns: Returns a list of snapshots for the specified volume.
-
get_replication_locations
(volume_id)[source]¶ Acquires list of the datacenters to which a volume can be replicated.
Parameters: volume_id – The ID of the primary volume to be replicated Returns: Returns an array of SoftLayer_Network_Storage objects
-
get_replication_partners
(volume_id)[source]¶ Acquires list of replicant volumes pertaining to the given volume.
Parameters: volume_id – The ID of the primary volume to be replicated Returns: Returns an array of SoftLayer_Location objects
-
list_block_volumes
(datacenter=None, username=None, storage_type=None, **kwargs)[source]¶ Returns a list of block volumes.
Parameters: - datacenter – Datacenter short name (e.g.: dal09)
- username – Name of volume.
- storage_type – Type of volume: Endurance or Performance
- kwargs –
Returns: Returns a list of block volumes.
-
list_volume_schedules
(volume_id)[source]¶ Lists schedules for a given volume
Parameters: volume_id (integer) – The id of the volume Returns: Returns list of schedules assigned to a given volume
-
order_block_volume
(storage_type, location, size, os_type, iops=None, tier_level=None, snapshot_size=None, service_offering='storage_as_a_service', hourly_billing_flag=False)[source]¶ Places an order for a block volume.
Parameters: - storage_type – ‘performance’ or ‘endurance’
- location – Datacenter in which to order iSCSI volume
- size – Size of the desired volume, in GB
- os_type – OS Type to use for volume alignment, see help for list
- iops – Number of IOPs for a “Performance” order
- tier_level – Tier level to use for an “Endurance” order
- snapshot_size – The size of optional snapshot space, if snapshot space should also be ordered (None if not ordered)
- service_offering – Requested offering package to use in the order (‘storage_as_a_service’, ‘enterprise’, or ‘performance’)
- hourly_billing_flag – Billing type, monthly (False) or hourly (True), default to monthly.
-
order_duplicate_volume
(origin_volume_id, origin_snapshot_id=None, duplicate_size=None, duplicate_iops=None, duplicate_tier_level=None, duplicate_snapshot_size=None, hourly_billing_flag=False)[source]¶ Places an order for a duplicate block volume.
Parameters: - origin_volume_id – The ID of the origin volume to be duplicated
- origin_snapshot_id – Origin snapshot ID to use for duplication
- duplicate_size – Size/capacity for the duplicate volume
- duplicate_iops – The IOPS per GB for the duplicate volume
- duplicate_tier_level – Tier level for the duplicate volume
- duplicate_snapshot_size – Snapshot space size for the duplicate
- hourly_billing_flag – Billing type, monthly (False) or hourly (True), default to monthly.
Returns: Returns a SoftLayer_Container_Product_Order_Receipt
-
order_modified_volume
(volume_id, new_size=None, new_iops=None, new_tier_level=None)[source]¶ Places an order for modifying an existing block volume.
Parameters: - volume_id – The ID of the volume to be modified
- new_size – The new size/capacity for the volume
- new_iops – The new IOPS for the volume
- new_tier_level – The new tier level for the volume
Returns: Returns a SoftLayer_Container_Product_Order_Receipt
-
order_replicant_volume
(volume_id, snapshot_schedule, location, tier=None, os_type=None)[source]¶ Places an order for a replicant block volume.
Parameters: - volume_id – The ID of the primary volume to be replicated
- snapshot_schedule – The primary volume’s snapshot schedule to use for replication
- location – The location for the ordered replicant volume
- tier – The tier (IOPS per GB) of the primary volume
- os_type – The OS type of the primary volume
Returns: Returns a SoftLayer_Container_Product_Order_Receipt
-
order_snapshot_space
(volume_id, capacity, tier, upgrade, **kwargs)[source]¶ Orders snapshot space for the given block volume.
Parameters: - volume_id (integer) – The id of the volume
- capacity (integer) – The capacity to order, in GB
- tier (float) – The tier level of the block volume, in IOPS per GB
- upgrade (boolean) – Flag to indicate if this order is an upgrade
Returns: Returns a SoftLayer_Container_Product_Order_Receipt
-
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:
SoftLayer.cdn¶
CDN Manager/helpers
license: | MIT, see LICENSE for more details. |
---|
-
class
SoftLayer.managers.cdn.
CDNManager
(client)[source]¶ Manage Content Delivery Networks in the account.
See product information here: https://www.ibm.com/cloud/cdn https://cloud.ibm.com/docs/infrastructure/CDN?topic=CDN-about-content-delivery-networks-cdn-
Parameters: client (SoftLayer.API.BaseClient) – the client instance -
add_origin
(unique_id, origin, path, origin_type='server', header=None, port=80, protocol='http', bucket_name=None, file_extensions=None, optimize_for='web', cache_query='include all')[source]¶ Creates an origin path for an existing CDN.
Parameters: - unique_id (str) – The unique ID associated with the CDN.
- path (str) – relative path to the domain provided, e.g. “/articles/video”
- origin (str) – ip address or hostname if origin_type=server, API endpoint for your S3 object storage if origin_type=storage
- origin_type (str) – it can be ‘server’ or ‘storage’ types.
- header (str) – the edge server uses the host header to communicate with the origin. It defaults to hostname. (optional)
- port (int) – the http port number (default: 80)
- protocol (str) – the protocol of the origin (default: HTTP)
- bucket_name (str) – name of the available resource
- file_extensions (str) – file extensions that can be stored in the CDN, e.g. “jpg,png”
- optimize_for (str) –
performance configuration, available options: web, video, and file where:
- ’web’ = ‘General web delivery’
- ’video’ = ‘Video on demand optimization’
- ’file’ = ‘Large file optimization’
- cache_query (str) – rules with the following formats: ‘include-all’, ‘ignore-all’, ‘include: space separated query-names’, ‘ignore: space separated query-names’.’
Returns: a CDN origin path object
-
get_cdn
(unique_id, **kwargs)[source]¶ Retrieves the information about the CDN account object.
Parameters: - unique_id (str) – The unique ID associated with the CDN.
- **kwargs (dict) – header-level option (mask)
Returns: The CDN object
-
get_origins
(unique_id, **kwargs)[source]¶ Retrieves list of origin pull mappings for a specified CDN account.
Parameters: - unique_id (str) – The unique ID associated with the CDN.
- **kwargs (dict) – header-level options (mask, limit, etc.)
Returns: The list of origin paths in the CDN object.
-
get_usage_metrics
(unique_id, history=30, frequency='aggregate')[source]¶ Retrieves the cdn usage metrics.
It uses the ‘days’ argument if start_date and end_date are None.
Parameters: - unique_id (int) – The CDN uniqueId from which the usage metrics will be obtained.
- history (int) – Last N days, default days is 30.
- frequency (str) – It can be day, week, month and aggregate. The default is “aggregate”.
Returns: A Container_Network_CdnMarketplace_Metrics object
-
list_cdn
(**kwargs)[source]¶ Lists Content Delivery Networks for the active user.
Parameters: **kwargs (dict) – header-level options (mask, limit, etc.) Returns: The list of CDN objects in the account
-
purge_content
(unique_id, path)[source]¶ Purges a URL or path from the CDN.
Parameters: - unique_id (str) – The unique ID associated with the CDN.
- path (str) – A string of url or path that should be purged.
Returns: A Container_Network_CdnMarketplace_Configuration_Cache_Purge array object
-
remove_origin
(unique_id, path)[source]¶ Removes an origin pull mapping with the given origin pull ID.
Parameters: - unique_id (str) – The unique ID associated with the CDN.
- path (str) – The origin path to delete.
Returns: A string value
-
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:
-
SoftLayer.dedicatedhost¶
DH Manager/helpers
license: | MIT, see License for more details. |
---|
-
class
SoftLayer.managers.dedicated_host.
DedicatedHostManager
(client, ordering_manager=None)[source]¶ Manages SoftLayer Dedicated Hosts.
See product information here https://www.ibm.com/cloud/dedicatedParameters: - 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_guests
(host_id)[source]¶ Cancel all guests into the dedicated host immediately.
To cancel an specified guest use the method VSManager.cancel_instance()
Parameters: host_id – The ID of the dedicated host. Returns: The id, fqdn and status of all guests into a dictionary. The status could be ‘Cancelled’ or an exception message, The dictionary is empty if there isn’t any guest in the dedicated host. - Example::
- # Cancel guests of dedicated host id 12345 result = mgr.cancel_guests(12345)
-
cancel_host
(host_id)[source]¶ Cancel a dedicated host immediately, it fails if there are still guests in the host.
Parameters: host_id – The ID of the dedicated host to be cancelled. Returns: True on success or an exception - Example::
- # Cancels dedicated host id 12345 result = mgr.cancel_host(12345)
-
get_host
(host_id, **kwargs)[source]¶ Get details about a dedicated host.
:param integer : the host ID :returns: A dictionary containing host information.
Example:
# Print out host ID 12345. dh = mgr.get_host(12345) print dh # Print out only name and backendRouter for instance 12345 object_mask = "mask[name,backendRouter[id]]" dh = mgr.get_host(12345, mask=mask) print dh
-
get_router_options
(datacenter=None, flavor=None)[source]¶ Returns available backend routers for the dedicated host.
-
list_guests
(host_id, tags=None, cpus=None, memory=None, hostname=None, domain=None, local_disk=None, nic_speed=None, public_ip=None, private_ip=None, **kwargs)[source]¶ Retrieve a list of all virtual servers on the dedicated host.
Example:
# Print out a list of instances with 4 cpu cores in the host id 12345. for vsi in mgr.list_guests(host_id=12345, cpus=4): print vsi['fullyQualifiedDomainName'], vsi['primaryIpAddress'] # Using a custom object-mask. Will get ONLY what is specified object_mask = "mask[hostname,monitoringRobot[robotStatus]]" for vsi in mgr.list_guests(mask=object_mask,cpus=4): print vsi
Parameters: - host_id (integer) – the identifier of dedicated host
- tags (list) – filter based on list of tags
- cpus (integer) – filter based on number of CPUS
- memory (integer) – filter based on amount of memory
- hostname (string) – filter based on hostname
- domain (string) – filter based on domain
- local_disk (string) – filter based on local_disk
- 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 options (mask, limit, etc.)
Returns: Returns a list of dictionaries representing the matching virtual servers
-
list_instances
(tags=None, cpus=None, memory=None, hostname=None, disk=None, datacenter=None, **kwargs)[source]¶ Retrieve a list of all dedicated hosts on the account
Parameters: - tags (list) – filter based on list of tags
- cpus (integer) – filter based on number of CPUS
- memory (integer) – filter based on amount of memory
- hostname (string) – filter based on hostname
- disk (string) – filter based on disk
- datacenter (string) – filter based on datacenter
- **kwargs (dict) – response-level options (mask, limit, etc.)
Returns: Returns a list of dictionaries representing the matching dedicated host.
-
place_order
(hostname, domain, location, flavor, hourly, router=None)[source]¶ Places an order for a dedicated host.
See get_create_options() for valid arguments.
Parameters: - hostname (string) – server hostname
- domain (string) – server domain name
- location (string) – location (datacenter) name
- hourly (boolean) – True if using hourly pricing (default). False for monthly.
- router (int) – an optional value for selecting a backend router
-
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:
-
verify_order
(hostname, domain, location, hourly, flavor, router=None)[source]¶ Verifies an order for a dedicated host.
See
place_order()
for a list of available options.
SoftLayer.dns¶
DNS Manager/helpers
license: | MIT, see LICENSE for more details. |
---|
-
class
SoftLayer.managers.dns.
DNSManager
(client)[source]¶ Manage SoftLayer DNS.
See product information here: http://www.softlayer.com/DOMAIN-SERVICES
Parameters: client (SoftLayer.API.BaseClient) – the client instance -
create_record
(zone_id, record, record_type, data, ttl=60)[source]¶ Create a resource record on a domain.
Parameters: - id (integer) – the zone’s ID
- record – the name of the record to add
- record_type – the type of record (A, AAAA, CNAME, TXT, etc.)
- data – the record’s value
- ttl (integer) – the TTL or time-to-live value (default: 60)
-
create_record_mx
(zone_id, record, data, ttl=60, priority=10)[source]¶ Create a mx resource record on a domain.
Parameters: - id (integer) – the zone’s ID
- record – the name of the record to add
- data – the record’s value
- ttl (integer) – the TTL or time-to-live value (default: 60)
- priority (integer) – the priority of the target host
-
create_record_ptr
(record, data, ttl=60)[source]¶ Create a reverse record.
Parameters: - record – the public ip address of device for which you would like to manage reverse DNS.
- data – the record’s value
- ttl (integer) – the TTL or time-to-live value (default: 60)
-
create_record_srv
(zone_id, record, data, protocol, port, service, ttl=60, priority=20, weight=10)[source]¶ Create a resource record on a domain.
Parameters: - id (integer) – the zone’s ID
- record – the name of the record to add
- data – the record’s value
- protocol (string) – the protocol of the service, usually either TCP or UDP.
- port (integer) – the TCP or UDP port on which the service is to be found.
- service (string) – the symbolic name of the desired service.
- ttl (integer) – the TTL or time-to-live value (default: 60)
- priority (integer) – the priority of the target host (default: 20)
- weight (integer) – relative weight for records with same priority (default: 10)
-
create_zone
(zone, serial=None)[source]¶ Create a zone for the specified zone.
Parameters: - zone – the zone name to create
- serial – serial value on the zone (default: strftime(%Y%m%d01))
-
delete_record
(record_id)[source]¶ Delete a resource record by its ID.
Parameters: id (integer) – the record’s ID
-
delete_zone
(zone_id)[source]¶ Delete a zone by its ID.
Parameters: zone_id (integer) – the zone ID to delete
-
dump_zone
(zone_id)[source]¶ Retrieve a zone dump in BIND format.
Parameters: id (integer) – The zone ID to dump
-
edit_record
(record)[source]¶ Update an existing record with the options provided.
The provided dict must include an ‘id’ key and value corresponding to the record that should be updated.
Parameters: record (dict) – the record to update
-
edit_zone
(zone)[source]¶ Update an existing zone with the options provided.
The provided dict must include an ‘id’ key and value corresponding to the zone that should be updated.
Parameters: zone (dict) – the zone to update
-
get_records
(zone_id, ttl=None, data=None, host=None, record_type=None)[source]¶ List, and optionally filter, records within a zone.
Parameters: - zone – the zone name in which to search.
- ttl (int) – time in seconds
- data (str) – the records data
- host (str) – record’s host
- record_type (str) – the type of record
Returns: A list of dictionaries representing the matching records within the specified zone.
-
get_zone
(zone_id, records=True)[source]¶ Get a zone and its records.
Parameters: zone – the zone name Returns: A dictionary containing a large amount of information about the specified zone.
-
list_zones
(**kwargs)[source]¶ Retrieve a list of all DNS zones.
Parameters: **kwargs (dict) – response-level options (mask, limit, etc.) Returns: A list of dictionaries representing the matching zones.
-
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:
-
SoftLayer.event_log¶
Network Manager/helpers
license: | MIT, see LICENSE for more details. |
---|
-
class
SoftLayer.managers.event_log.
EventLogManager
(client)[source]¶ Provides an interface for the SoftLayer Event Log Service.
See product information here: http://sldn.softlayer.com/reference/services/SoftLayer_Event_Log
-
static
build_filter
(date_min=None, date_max=None, obj_event=None, obj_id=None, obj_type=None, utc_offset=None)[source]¶ Returns a query filter that can be passed into EventLogManager.get_event_logs
Parameters: - date_min (string) – Lower bound date in MM/DD/YYYY format
- date_max (string) – Upper bound date in MM/DD/YYYY format
- obj_event (string) – The name of the events we want to filter by
- obj_id (int) – The id of the event we want to filter by
- obj_type (string) – The type of event we want to filter by
- utc_offset (string) – The UTC offset we want to use when converting date_min and date_max. (default ‘+0000’)
Returns: dict: The generated query filter
-
get_event_logs
(request_filter=None, log_limit=20, iterator=True)[source]¶ Returns a list of event logs
Example:
event_mgr = SoftLayer.EventLogManager(env.client) request_filter = event_mgr.build_filter(date_min="01/01/2019", date_max="02/01/2019") logs = event_mgr.get_event_logs(request_filter) for log in logs: print("Event Name: {}".format(log['eventName']))
Parameters: - request_filter (dict) – filter dict
- log_limit (int) – number of results to get in one API call
- iterator (bool) – False will only make one API call for log_limit results. True will keep making API calls until all logs have been retreived. There may be a lot of these.
Returns: List of event logs. If iterator=True, will return a python generator object instead.
-
static
SoftLayer.file¶
File Storage Manager
license: | MIT, see LICENSE for more details. |
---|
-
class
SoftLayer.managers.file.
FileStorageManager
(client)[source]¶ Manages file Storage volumes.
Authorizes hosts to File Storage Volumes
Parameters: - volume_id – The File volume to authorize hosts to
- hardware_ids – A List of SoftLayer_Hardware ids
- virtual_guest_ids – A List of SoftLayer_Virtual_Guest ids
- ip_address_ids – A List of SoftLayer_Network_Subnet_IpAddress ids
- subnet_ids – A List of SoftLayer_Network_Subnet ids
Returns: Returns an array of SoftLayer_Network_Storage_Allowed_Host objects which now have access to the given File volume
-
cancel_file_volume
(volume_id, reason='No longer needed', immediate=False)[source]¶ Cancels the given file storage volume.
Parameters: - volume_id (integer) – The volume ID
- reason (string) – The reason for cancellation
- immediate (boolean) – Cancel immediately or on anniversary date
-
cancel_snapshot_space
(volume_id, reason='No longer needed', immediate=False)[source]¶ Cancels snapshot space for a given volume.
Parameters: - volume_id (integer) – The volume ID
- reason (string) – The reason for cancellation
- immediate (boolean) – Cancel immediately or on anniversary date
-
create_snapshot
(volume_id, notes='', **kwargs)[source]¶ Creates a snapshot on the given file volume.
Parameters: - volume_id (integer) – The id of the volume
- notes (string) – The notes or “name” to assign the snapshot
Returns: Returns the id of the new snapshot
Revokes authorization of hosts to File Storage Volumes
Parameters: - volume_id – The File volume to deauthorize hosts to
- hardware_ids – A List of SoftLayer_Hardware ids
- virtual_guest_ids – A List of SoftLayer_Virtual_Guest ids
- ip_address_ids – A List of SoftLayer_Network_Subnet_IpAddress ids
- subnet_ids – A List of SoftLayer_Network_Subnet ids
Returns: Returns an array of SoftLayer_Network_Storage_Allowed_Host objects which have access to the given File volume
-
delete_snapshot
(snapshot_id)[source]¶ Deletes the specified snapshot object.
Parameters: snapshot_id – The ID of the snapshot object to delete.
-
disable_snapshots
(volume_id, schedule_type)[source]¶ Disables snapshots for a specific file volume at a given schedule
Parameters: - volume_id (integer) – The id of the volume
- schedule_type (string) – ‘HOURLY’|’DAILY’|’WEEKLY’
Returns: Returns whether successfully disabled or not
-
enable_snapshots
(volume_id, schedule_type, retention_count, minute, hour, day_of_week, **kwargs)[source]¶ Enables snapshots for a specific file volume at a given schedule
Parameters: - volume_id (integer) – The id of the volume
- schedule_type (string) – ‘HOURLY’|’DAILY’|’WEEKLY’
- retention_count (integer) – The number of snapshots to attempt to retain in this schedule
- minute (integer) – The minute of the hour at which HOURLY, DAILY, and WEEKLY snapshots should be taken
- hour (integer) – The hour of the day at which DAILY and WEEKLY snapshots should be taken
- day_of_week (string|integer) – The day of the week on which WEEKLY snapshots should be taken, either as a string (‘SUNDAY’) or integer (‘0’ is Sunday)
Returns: Returns whether successfully scheduled or not
-
failback_from_replicant
(volume_id, replicant_id)[source]¶ Failback from a volume replicant.
Parameters: - volume_id (integer) – The ID of the volume
- replicant_id (integer) – ID of replicant to failback from
Returns: Returns whether failback was successful or not
-
failover_to_replicant
(volume_id, replicant_id, immediate=False)[source]¶ Failover to a volume replicant.
Parameters: - volume_id (integer) – The ID of the volume
- replicant_id (integer) – ID of replicant to failover to
- immediate (boolean) – Flag indicating if failover is immediate
Returns: Returns whether failover was successful or not
-
get_file_volume_access_list
(volume_id, **kwargs)[source]¶ Returns a list of authorized hosts for a specified volume.
Parameters: - volume_id – ID of volume.
- kwargs –
Returns: Returns a list of authorized hosts for a specified volume.
-
get_file_volume_details
(volume_id, **kwargs)[source]¶ Returns details about the specified volume.
Parameters: - volume_id – ID of volume.
- kwargs –
Returns: Returns details about the specified volume.
-
get_file_volume_snapshot_list
(volume_id, **kwargs)[source]¶ Returns a list of snapshots for the specified volume.
Parameters: - volume_id – ID of volume.
- kwargs –
Returns: Returns a list of snapshots for the specified volume.
-
get_replication_locations
(volume_id)[source]¶ Acquires list of the datacenters to which a volume can be replicated.
Parameters: volume_id – The ID of the primary volume to be replicated Returns: Returns an array of SoftLayer_Network_Storage objects
-
get_replication_partners
(volume_id)[source]¶ Acquires list of replicant volumes pertaining to the given volume.
Parameters: volume_id – The ID of the primary volume to be replicated Returns: Returns an array of SoftLayer_Location objects
-
list_file_volumes
(datacenter=None, username=None, storage_type=None, **kwargs)[source]¶ Returns a list of file volumes.
Parameters: - datacenter – Datacenter short name (e.g.: dal09)
- username – Name of volume.
- storage_type – Type of volume: Endurance or Performance
- kwargs –
Returns: Returns a list of file volumes.
-
list_volume_schedules
(volume_id)[source]¶ Lists schedules for a given volume
Parameters: volume_id (integer) – The id of the volume Returns: Returns list of schedules assigned to a given volume
-
order_duplicate_volume
(origin_volume_id, origin_snapshot_id=None, duplicate_size=None, duplicate_iops=None, duplicate_tier_level=None, duplicate_snapshot_size=None, hourly_billing_flag=False)[source]¶ Places an order for a duplicate file volume.
Parameters: - origin_volume_id – The ID of the origin volume to be duplicated
- origin_snapshot_id – Origin snapshot ID to use for duplication
- duplicate_size – Size/capacity for the duplicate volume
- duplicate_iops – The IOPS per GB for the duplicate volume
- duplicate_tier_level – Tier level for the duplicate volume
- duplicate_snapshot_size – Snapshot space size for the duplicate
- hourly_billing_flag – Billing type, monthly (False) or hourly (True), default to monthly.
Returns: Returns a SoftLayer_Container_Product_Order_Receipt
-
order_file_volume
(storage_type, location, size, iops=None, tier_level=None, snapshot_size=None, service_offering='storage_as_a_service', hourly_billing_flag=False)[source]¶ Places an order for a file volume.
Parameters: - storage_type – ‘performance’ or ‘endurance’
- location – Name of the datacenter in which to order the volume
- size – Size of the desired volume, in GB
- iops – Number of IOPs for a “Performance” order
- tier_level – Tier level to use for an “Endurance” order
- snapshot_size – The size of optional snapshot space, if snapshot space should also be ordered (None if not ordered)
- service_offering – Requested offering package to use in the order (‘storage_as_a_service’, ‘enterprise’, or ‘performance’)
- hourly_billing_flag – Billing type, monthly (False) or hourly (True), default to monthly.
-
order_modified_volume
(volume_id, new_size=None, new_iops=None, new_tier_level=None)[source]¶ Places an order for modifying an existing file volume.
Parameters: - volume_id – The ID of the volume to be modified
- new_size – The new size/capacity for the volume
- new_iops – The new IOPS for the volume
- new_tier_level – The new tier level for the volume
Returns: Returns a SoftLayer_Container_Product_Order_Receipt
-
order_replicant_volume
(volume_id, snapshot_schedule, location, tier=None)[source]¶ Places an order for a replicant file volume.
Parameters: - volume_id – The ID of the primary volume to be replicated
- snapshot_schedule – The primary volume’s snapshot schedule to use for replication
- location – The location for the ordered replicant volume
- tier – The tier (IOPS per GB) of the primary volume
Returns: Returns a SoftLayer_Container_Product_Order_Receipt
-
order_snapshot_space
(volume_id, capacity, tier, upgrade, **kwargs)[source]¶ Orders snapshot space for the given file volume.
Parameters: - volume_id (integer) – The ID of the volume
- capacity (integer) – The capacity to order, in GB
- tier (float) – The tier level of the file volume, in IOPS per GB
- upgrade (boolean) – Flag to indicate if this order is an upgrade
Returns: Returns a SoftLayer_Container_Product_Order_Receipt
-
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:
SoftLayer.firewall¶
Firewall Manager/helpers
license: | MIT, see LICENSE for more details. |
---|
-
class
SoftLayer.managers.firewall.
FirewallManager
(client)[source]¶ Manages SoftLayer firewalls
See product information here: http://www.softlayer.com/firewalls
Parameters: client (SoftLayer.API.BaseClient) – the client instance -
add_standard_firewall
(server_id, is_virt=True)[source]¶ Creates a firewall for the specified virtual/hardware server.
Parameters: - server_id (int) – The ID of the server to create the firewall for
- is_virt (bool) – If true, will create the firewall for a virtual server, otherwise for a hardware server.
Returns: A dictionary containing the standard virtual server firewall order
-
add_vlan_firewall
(vlan_id, ha_enabled=False)[source]¶ Creates a firewall for the specified vlan.
Parameters: - vlan_id (int) – The ID of the vlan to create the firewall for
- ha_enabled (bool) – If True, an HA firewall will be created
Returns: A dictionary containing the VLAN firewall order
-
cancel_firewall
(firewall_id, dedicated=False)[source]¶ Cancels the specified firewall.
Parameters: - firewall_id (int) – Firewall ID to be cancelled.
- dedicated (bool) – If true, the firewall instance is dedicated, otherwise, the firewall instance is shared.
-
edit_dedicated_fwl_rules
(firewall_id, rules)[source]¶ Edit the rules for dedicated firewall.
Parameters: - firewall_id (integer) – the instance ID of the dedicated firewall
- rules (list) – the rules to be pushed on the firewall as defined by SoftLayer_Network_Firewall_Update_Request_Rule
-
edit_standard_fwl_rules
(firewall_id, rules)[source]¶ Edit the rules for standard firewall.
Parameters: - firewall_id (integer) – the instance ID of the standard firewall
- rules (dict) – the rules to be pushed on the firewall
-
get_dedicated_fwl_rules
(firewall_id)[source]¶ Get the rules of a dedicated firewall.
Parameters: firewall_id (integer) – the instance ID of the dedicated firewall Returns: A list of the rules.
-
get_dedicated_package
(ha_enabled=False)[source]¶ Retrieves the dedicated firewall package.
Parameters: ha_enabled (bool) – True if HA is to be enabled on the firewall False for No HA Returns: A dictionary containing the dedicated virtual server firewall package
-
get_firewalls
()[source]¶ Returns a list of all firewalls on the account.
Returns: A list of firewalls on the current account.
-
get_standard_fwl_rules
(firewall_id)[source]¶ Get the rules of a standard firewall.
Parameters: firewall_id (integer) – the instance ID of the standard firewall Returns: A list of the rules.
-
get_standard_package
(server_id, is_virt=True)[source]¶ Retrieves the standard firewall package for the virtual server.
Parameters: - server_id (int) – The ID of the server to create the firewall for
- is_virt (bool) – True if the ID provided is for a virtual server, False for a server
Returns: A dictionary containing the standard virtual server firewall package
-
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:
-
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.
- immediate (bool) – If set to True, will automatically update the cancelation ticket to request the resource be reclaimed asap. This request still has to be reviewed by a human
Returns: True on success or an exception
-
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_bandwidth_allocation
(instance_id)[source]¶ Combines getBandwidthAllotmentDetail() and getBillingCycleBandwidthUsage()
-
get_bandwidth_data
(instance_id, start_date=None, end_date=None, direction=None, rollup=3600)[source]¶ Gets bandwidth data for a server
Will get averaged bandwidth data for a given time period. If you use a rollup over 3600 be aware that the API will bump your start/end date to align with how data is stored. For example if you have a rollup of 86400 your start_date will be bumped to 00:00. If you are not using a time in the start/end date fields, this won’t really matter.
Parameters: - instance_id (int) – Hardware Id to get data for
- start_date (date) – Date to start pulling data for.
- end_date (date) – Date to finish pulling data for
- direction (string) – Can be either ‘public’, ‘private’, or None for both.
- rollup (int) – 300, 600, 1800, 3600, 43200 or 86400 seconds to average data over.
-
get_cancellation_reasons
()[source]¶ Returns a dictionary of valid cancellation reasons.
These can be used when cancelling a dedicated server via
cancel_hardware()
.
-
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. Example:
object_mask = "mask[id,networkVlans[vlanNumber]]" # Object masks are optional result = mgr.get_hardware(hardware_id=1234,mask=object_mask)
-
get_tracking_id
(instance_id)[source]¶ Returns the Metric Tracking Object Id for a hardware server
Parameters: instance_id (int) – Id of the hardware server
-
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).
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 or presetId
- 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
-
reflash_firmware
(hardware_id, ipmi=True, raid_controller=True, bios=True)[source]¶ Reflash hardware firmware.
This will cause the server to be unavailable for ~60 minutes. The firmware will not be upgraded but rather reflashed to the version installed.
Parameters: - hardware_id (int) – The ID of the hardware to have its firmware reflashed.
- ipmi (bool) – Reflash the ipmi firmware.
- raid_controller (bool) – Reflash the raid controller firmware.
- bios (bool) – Reflash the bios firmware.
Example:
# Check the servers active transactions to see progress result = mgr.reflash_firmware(hardware_id=1234)
-
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_uri (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.
-
wait_for_ready
(instance_id, limit=14400, delay=10, pending=False)[source]¶ Determine if a Server is ready.
A server is ready when no transactions are running on it.
Parameters: - instance_id (int) – The instance ID with the pending transaction
- limit (int) – The maximum amount of seconds to wait.
- delay (int) – The number of seconds to sleep before checks. Defaults to 10.
SoftLayer.image¶
Image Manager/helpers
license: | MIT, see LICENSE for more details. |
---|
-
class
SoftLayer.managers.image.
ImageManager
(client)[source]¶ Manages SoftLayer server images.
See product information here: https://console.bluemix.net/docs/infrastructure/image-templates/image_index.html
Parameters: client (SoftLayer.API.BaseClient) – the client instance -
delete_image
(image_id)[source]¶ Deletes the specified image.
Parameters: image_id (int) – The ID of the image.
-
edit
(image_id, name=None, note=None, tag=None)[source]¶ Edit image related details.
Parameters: - image_id (int) – The ID of the image
- name (string) – Name of the Image.
- note (string) – Note of the image.
- tag (string) – Tags of the image to be updated to.
-
export_image_to_uri
(image_id, uri, ibm_api_key=None)[source]¶ Export image into the given object storage
Parameters: - image_id (int) – The ID of the image
- uri (string) – The URI for object storage of the format swift://<objectStorageAccount>@<cluster>/<container>/<objectPath> or cos://<regionName>/<bucketName>/<objectPath> if using IBM Cloud Object Storage
- ibm_api_key (string) – Ibm Api Key needed to communicate with IBM Cloud Object Storage
-
get_image
(image_id, **kwargs)[source]¶ Get details about an image.
Parameters: - image (int) – The ID of the image.
- **kwargs (dict) – response-level options (mask, limit, etc.)
-
import_image_from_uri
(name, uri, os_code=None, note=None, ibm_api_key=None, root_key_crn=None, wrapped_dek=None, cloud_init=False, byol=False, is_encrypted=False)[source]¶ Import a new image from object storage.
Parameters: - name (string) – Name of the new image
- uri (string) – The URI for an object storage object (.vhd/.iso file) of the format: swift://<objectStorageAccount>@<cluster>/<container>/<objectPath> or (.vhd/.iso/.raw file) of the format: cos://<regionName>/<bucketName>/<objectPath> if using IBM Cloud Object Storage
- os_code (string) – The reference code of the operating system
- note (string) – Note to add to the image
- ibm_api_key (string) – Ibm Api Key needed to communicate with ICOS and your KMS
- root_key_crn (string) – CRN of the root key in your KMS. Go to your KMS (Key Protect or Hyper Protect) provider to get the CRN for your root key. An example CRN: crn:v1:bluemix:public:hs-crypto:us-south:acctID:serviceID:key:keyID’ Used only when is_encrypted is True.
- wrapped_dek (string) – Wrapped Data Encryption Key provided by your KMS. Used only when is_encrypted is True.
- cloud_init (boolean) – Specifies if image is cloud-init
- byol (boolean) – Specifies if image is bring your own license
- is_encrypted (boolean) – Specifies if image is encrypted
-
list_private_images
(guid=None, name=None, **kwargs)[source]¶ List all private images.
Parameters: - guid (string) – filter based on GUID
- name (string) – filter based on name
- **kwargs (dict) – response-level options (mask, limit, etc.)
-
list_public_images
(guid=None, name=None, **kwargs)[source]¶ List all public images.
Parameters: - guid (string) – filter based on GUID
- name (string) – filter based on name
- **kwargs (dict) – response-level options (mask, limit, etc.)
-
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:
-
SoftLayer.ipsec¶
IPSec VPN Manager
license: | MIT, see LICENSE for more details. |
---|
-
class
SoftLayer.managers.ipsec.
IPSECManager
(client)[source]¶ Manage SoftLayer IPSEC VPN tunnel contexts.
This provides helpers to manage IPSEC contexts, private and remote subnets, and NAT translations.
Parameters: - client (SoftLayer.API.BaseClient) – the client instance
- account (SoftLayer.API.BaseClient) – account service client
- context (SoftLayer.API.BaseClient) – tunnel context client
- customer_subnet (SoftLayer.API.BaseClient) – remote subnet client
-
add_internal_subnet
(context_id, subnet_id)[source]¶ Add an internal subnet to a tunnel context.
Parameters: - context_id (int) – The id-value representing the context instance.
- subnet_id (int) – The id-value representing the internal subnet.
Return bool: True if internal subnet addition was successful.
-
add_remote_subnet
(context_id, subnet_id)[source]¶ Adds a remote subnet to a tunnel context.
Parameters: - context_id (int) – The id-value representing the context instance.
- subnet_id (int) – The id-value representing the remote subnet.
Return bool: True if remote subnet addition was successful.
-
add_service_subnet
(context_id, subnet_id)[source]¶ Adds a service subnet to a tunnel context.
Parameters: - context_id (int) – The id-value representing the context instance.
- subnet_id (int) – The id-value representing the service subnet.
Return bool: True if service subnet addition was successful.
-
apply_configuration
(context_id)[source]¶ Requests network configuration for a tunnel context.
Parameters: context_id (int) – The id-value representing the context instance. Return bool: True if the configuration request was successfully queued.
-
create_remote_subnet
(account_id, identifier, cidr)[source]¶ Creates a remote subnet on the given account.
Parameters: - account_id (string) – The account identifier.
- identifier (string) – The network identifier of the remote subnet.
- cidr (string) – The CIDR value of the remote subnet.
Return dict: Mapping of properties for the new remote subnet.
-
create_translation
(context_id, static_ip, remote_ip, notes)[source]¶ Creates an address translation on a tunnel context/
Parameters: - context_id (int) – The id-value representing the context instance.
- static_ip (string) – The IP address value representing the internal side of the translation entry,
- remote_ip (string) – The IP address value representing the remote side of the translation entry,
- notes (string) – The notes to supply with the translation entry,
Return dict: Mapping of properties for the new translation entry.
-
delete_remote_subnet
(subnet_id)[source]¶ Deletes a remote subnet from the current account.
Parameters: subnet_id (string) – The id-value representing the remote subnet. Return bool: True if subnet deletion was successful.
-
get_translation
(context_id, translation_id)[source]¶ Retrieves a translation entry for the given id values.
Parameters: - context_id (int) – The id-value representing the context instance.
- translation_id (int) – The id-value representing the translation instance.
Return dict: Mapping of properties for the translation entry.
Raises: SoftLayerAPIError – If a translation cannot be found.
-
get_translations
(context_id)[source]¶ Retrieves all translation entries for a tunnel context.
Parameters: context_id (int) – The id-value representing the context instance. Return list(dict): Translations associated with the given context
-
get_tunnel_context
(context_id, **kwargs)[source]¶ Retrieves the network tunnel context instance.
Parameters: context_id (int) – The id-value representing the context instance. Return dict: Mapping of properties for the tunnel context. Raises: SoftLayerAPIError – If a context cannot be found.
-
get_tunnel_contexts
(**kwargs)[source]¶ Retrieves network tunnel module context instances.
Return list(dict): Contexts associated with the current account.
-
remove_internal_subnet
(context_id, subnet_id)[source]¶ Remove an internal subnet from a tunnel context.
Parameters: - context_id (int) – The id-value representing the context instance.
- subnet_id (int) – The id-value representing the internal subnet.
Return bool: True if internal subnet removal was successful.
-
remove_remote_subnet
(context_id, subnet_id)[source]¶ Removes a remote subnet from a tunnel context.
Parameters: - context_id (int) – The id-value representing the context instance.
- subnet_id (int) – The id-value representing the remote subnet.
Return bool: True if remote subnet removal was successful.
-
remove_service_subnet
(context_id, subnet_id)[source]¶ Removes a service subnet from a tunnel context.
Parameters: - context_id (int) – The id-value representing the context instance.
- subnet_id (int) – The id-value representing the service subnet.
Return bool: True if service subnet removal was successful.
-
remove_translation
(context_id, translation_id)[source]¶ Removes a translation entry from a tunnel context.
Parameters: - context_id (int) – The id-value representing the context instance.
- translation_id (int) – The id-value representing the translation.
Return bool: True if translation entry removal was successful.
-
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_translation
(context_id, translation_id, static_ip=None, remote_ip=None, notes=None)[source]¶ Updates an address translation entry using the given values.
Parameters: - context_id (int) – The id-value representing the context instance.
- template (dict) – A key-value mapping of translation properties.
- static_ip (string) – The static IP address value to update.
- remote_ip (string) – The remote IP address value to update.
- notes (string) – The notes value to update.
Return bool: True if the update was successful.
-
update_tunnel_context
(context_id, friendly_name=None, remote_peer=None, preshared_key=None, phase1_auth=None, phase1_crypto=None, phase1_dh=None, phase1_key_ttl=None, phase2_auth=None, phase2_crypto=None, phase2_dh=None, phase2_forward_secrecy=None, phase2_key_ttl=None)[source]¶ Updates a tunnel context using the given values.
Parameters: - context_id (string) – The id-value representing the context.
- friendly_name (string) – The friendly name value to update.
- remote_peer (string) – The remote peer IP address value to update.
- preshared_key (string) – The preshared key value to update.
- phase1_auth (string) – The phase 1 authentication value to update.
- phase1_crypto (string) – The phase 1 encryption value to update.
- phase1_dh (string) – The phase 1 diffie hellman group value to update.
- phase1_key_ttl (string) – The phase 1 key life value to update.
- phase2_auth (string) – The phase 2 authentication value to update.
- phase2_crypto (string) – The phase 2 encryption value to update.
- phase2_df (string) – The phase 2 diffie hellman group value to update.
- phase2_forward_secriecy (string) – The phase 2 perfect forward secrecy value to update.
- phase2_key_ttl (string) – The phase 2 key life value to update.
Return bool: True if the update was successful.
SoftLayer.load_balancer¶
Load Balancer Manager/helpers
license: | MIT, see LICENSE for more details. |
---|
-
class
SoftLayer.managers.load_balancer.
LoadBalancerManager
(client)[source]¶ Manages SoftLayer load balancers.
See product information here: https://www.ibm.com/cloud/load-balancer
Parameters: client (SoftLayer.API.BaseClient) – the client instance -
add_lb_l7_pool
(identifier, pool, members, health, session)[source]¶ Creates a new l7 pool for a LBaaS instance
- https://sldn.softlayer.com/reference/services/SoftLayer_Network_LBaaS_L7Pool/createL7Pool/
- https://cloud.ibm.com/docs/infrastructure/loadbalancer-service?topic=loadbalancer-service-api-reference
Parameters: - identifier – UUID of the LBaaS instance
- SoftLayer_Network_LBaaS_L7Pool (pool) – Description of the pool
- SoftLayer_Network_LBaaS_L7Member[] (members) – Array of servers with their address, port, weight
- SoftLayer_Network_LBaaS_L7HealthMonitor (monitor) – A health monitor
- SoftLayer_Network_LBaaS_L7SessionAffinity (session) – Weather to use affinity
-
add_lb_listener
(identifier, listener)[source]¶ Adds or update a listener to a LBaaS instance
When using this to update a listener, just include the ‘listenerUuid’ in the listener object See the following for listener configuration options https://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_LBaaS_LoadBalancerProtocolConfiguration/
Parameters: - identifier – UUID of the LBaaS instance
- listener – Object with all listener configurations
-
add_lb_member
(identifier, service_info)[source]¶ Adds a member to a LBaaS instance
https://sldn.softlayer.com/reference/services/SoftLayer_Network_LBaaS_Member/deleteLoadBalancerMembers/ :param identifier: UUID of the LBaaS instance :param service_info: datatypes/SoftLayer_Network_LBaaS_LoadBalancerServerInstanceInfo
-
cancel_lbaas
(uuid)[source]¶ Cancels a LBaaS instance.
https://sldn.softlayer.com/reference/services/SoftLayer_Network_LBaaS_LoadBalancer/cancelLoadBalancer/ :param uuid string: UUID of the LBaaS instance to cancel
-
delete_lb_member
(identifier, member_id)[source]¶ Removes a member from a LBaaS instance
https://sldn.softlayer.com/reference/services/SoftLayer_Network_LBaaS_Member/deleteLoadBalancerMembers/ :param identifier: UUID of the LBaaS instance :param member_id: Member UUID to remove.
-
get_adc
(identifier, mask=None)[source]¶ Returns a netscaler object.
Returns: SoftLayer_Network_Application_Delivery_Controller.
-
get_adcs
(mask=None)[source]¶ Returns a list of all netscalers.
Returns: SoftLayer_Network_Application_Delivery_Controller[].
-
get_lb
(identifier, mask=None)[source]¶ Returns a IBM Cloud LoadBalancer
Returns: SoftLayer_Network_LBaaS_LoadBalancer
-
get_lbaas
(mask=None)[source]¶ Returns a list of IBM Cloud Loadbalancers
Returns: SoftLayer_Network_LBaaS_LoadBalancer[]
-
get_lbaas_uuid_id
(identifier)[source]¶ Gets a LBaaS uuid, id. Since sometimes you need one or the other.
Parameters: identifier – either the LB Id, or UUID, this function will return both. Return (uuid, id):
-
order_lbaas
(datacenter, name, desc, protocols, subnet_id, public=False, verify=False)[source]¶ Allows to order a Load Balancer
Parameters: - datacenter – Shortname for the SoftLayer datacenter to order in.
- name – Identifier for the new LB.
- desc – Optional description for the lb.
- protocols – https://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_LBaaS_Listener/
- subnet_id – Id of the subnet for this new LB to live on.
- public – Use Public side for the backend.
- verify – Don’t actually order if True.
-
remove_lb_listener
(identifier, listener)[source]¶ Removes a listener to a LBaaS instance
Parameters: - identifier – UUID of the LBaaS instance
- listener – UUID of the Listner to be removed.
-
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:
-
SoftLayer.metadata¶
Metadata Manager/helpers
license: | MIT, see LICENSE for more details. |
---|
-
class
SoftLayer.managers.metadata.
MetadataManager
(client=None, timeout=5)[source]¶ Provides an interface for the SoftLayer metadata service.
See product information here: http://sldn.softlayer.com/reference/services/SoftLayer_Resource_Metadata
This provides metadata about the resourse it is called from. See METADATA_ATTRIBUTES for full list of attributes.
Usage:
>>> import SoftLayer >>> client = SoftLayer.create_client_from_env() >>> from SoftLayer import MetadataManager >>> meta = MetadataManager(client) >>> meta.get('datacenter') 'dal05' >>> meta.get('fqdn') 'test.example.com'
Parameters: client (SoftLayer.API.BaseClient) – the client instance -
get
(name, param=None)[source]¶ Retreive a metadata attribute.
Parameters: - name (string) – name of the attribute to retrieve. See attribs
- param – Required parameter for some attributes
-
-
metadata.
METADATA_ATTRIBUTES
= dict_keys(['backend_mac', 'datacenter', 'datacenter_id', 'domain', 'frontend_mac', 'fqdn', 'hostname', 'id', 'primary_backend_ip', 'primary_ip', 'primary_frontend_ip', 'provision_state', 'router', 'tags', 'user_data', 'user_metadata', 'vlan_ids', 'vlans'])¶
SoftLayer.network¶
Network Manager/helpers
license: | MIT, see LICENSE for more details. |
---|
-
class
SoftLayer.managers.network.
NetworkManager
(client)[source]¶ Manage SoftLayer network objects: VLANs, subnets, IPs and rwhois
See product information here: http://www.softlayer.com/networking
Parameters: client (SoftLayer.API.BaseClient) – the client instance -
add_global_ip
(version=4, test_order=False)[source]¶ Adds a global IP address to the account.
Parameters: - version (int) – Specifies whether this is IPv4 or IPv6
- test_order (bool) – If true, this will only verify the order.
-
add_securitygroup_rule
(group_id, remote_ip=None, remote_group=None, direction=None, ethertype=None, port_max=None, port_min=None, protocol=None)[source]¶ Add a rule to a security group
Parameters: - group_id (int) – The ID of the security group to add this rule to
- remote_ip (str) – The remote IP or CIDR to enforce the rule on
- remote_group (int) – The remote security group ID to enforce the rule on
- direction (str) – The direction to enforce (egress or ingress)
- ethertype (str) – The ethertype to enforce (IPv4 or IPv6)
- port_max (int) – The upper port bound to enforce (icmp code if the protocol is icmp)
- port_min (int) – The lower port bound to enforce (icmp type if the protocol is icmp)
- protocol (str) – The protocol to enforce (icmp, udp, tcp)
-
add_securitygroup_rules
(group_id, rules)[source]¶ Add rules to a security group
Parameters: - group_id (int) – The ID of the security group to add the rules to
- rules (list) – The list of rule dictionaries to add
-
add_subnet
(subnet_type, quantity=None, endpoint_id=None, version=4, test_order=False)[source]¶ Orders a new subnet
Parameters: - subnet_type (str) – Type of subnet to add: private, public, global,static
- quantity (int) – Number of IPs in the subnet
- endpoint_id (int) – id for the subnet to be placed into
- version (int) – 4 for IPv4, 6 for IPv6
- test_order (bool) – If true, this will only verify the order.
-
assign_global_ip
(global_ip_id, target)[source]¶ Assigns a global IP address to a specified target.
Parameters: - global_ip_id (int) – The ID of the global IP being assigned
- target (string) – The IP address to assign
-
attach_securitygroup_component
(group_id, component_id)[source]¶ Attaches a network component to a security group.
Parameters: - group_id (int) – The ID of the security group
- component_id (int) – The ID of the network component to attach
-
attach_securitygroup_components
(group_id, component_ids)[source]¶ Attaches network components to a security group.
Parameters: - group_id (int) – The ID of the security group
- component_ids (list) – The IDs of the network components to attach
-
cancel_global_ip
(global_ip_id)[source]¶ Cancels the specified global IP address.
Parameters: id (int) – The ID of the global IP to be cancelled.
-
cancel_subnet
(subnet_id)[source]¶ Cancels the specified subnet.
Parameters: subnet_id (int) – The ID of the subnet to be cancelled.
-
create_securitygroup
(name=None, description=None)[source]¶ Creates a security group.
Parameters: - name (string) – The name of the security group
- description (string) – The description of the security group
-
delete_securitygroup
(group_id)[source]¶ Deletes the specified security group.
Parameters: group_id (int) – The ID of the security group
-
detach_securitygroup_component
(group_id, component_id)[source]¶ Detaches a network component from a security group.
Parameters: - group_id (int) – The ID of the security group
- component_id (int) – The ID of the component to detach
-
detach_securitygroup_components
(group_id, component_ids)[source]¶ Detaches network components from a security group.
Parameters: - group_id (int) – The ID of the security group
- component_ids (list) – The IDs of the network components to detach
-
edit_rwhois
(abuse_email=None, address1=None, address2=None, city=None, company_name=None, country=None, first_name=None, last_name=None, postal_code=None, private_residence=None, state=None)[source]¶ Edit rwhois record.
-
edit_securitygroup
(group_id, name=None, description=None)[source]¶ Edit security group details.
Parameters: - group_id (int) – The ID of the security group
- name (string) – The name of the security group
- description (string) – The description of the security group
-
edit_securitygroup_rule
(group_id, rule_id, remote_ip=None, remote_group=None, direction=None, ethertype=None, port_max=None, port_min=None, protocol=None)[source]¶ Edit a security group rule.
Parameters: - group_id (int) – The ID of the security group the rule belongs to
- rule_id (int) – The ID of the rule to edit
- remote_ip (str) – The remote IP or CIDR to enforce the rule on
- remote_group (int) – The remote security group ID to enforce the rule on
- direction (str) – The direction to enforce (egress or ingress)
- ethertype (str) – The ethertype to enforce (IPv4 or IPv6)
- port_max (str) – The upper port bound to enforce
- port_min (str) – The lower port bound to enforce
- protocol (str) – The protocol to enforce (icmp, udp, tcp)
-
get_event_logs_by_request_id
(request_id)[source]¶ Gets all event logs by the given request id
Parameters: request_id (string) – The request id we want to filter on
-
get_nas_credentials
(identifier, **kwargs)[source]¶ Returns a list of IDs of VLANs which match the given VLAN name.
Parameters: instance_id (integer) – the instance ID Returns: A dictionary containing a large amount of information about the specified instance.
-
get_rwhois
()[source]¶ Returns the RWhois information about the current account.
Returns: A dictionary containing the account’s RWhois information.
-
get_securitygroup
(group_id, **kwargs)[source]¶ Returns the information about the given security group.
Parameters: id (string) – The ID for the security group Returns: A diction of information about the security group
-
get_subnet
(subnet_id, **kwargs)[source]¶ Returns information about a single subnet.
Parameters: id (string) – Either the ID for the subnet or its network identifier Returns: A dictionary of information about the subnet
-
get_vlan
(vlan_id)[source]¶ Returns information about a single VLAN.
Parameters: id (int) – The unique identifier for the VLAN Returns: A dictionary containing a large amount of information about the specified VLAN.
-
ip_lookup
(ip_address)[source]¶ Looks up an IP address and returns network information about it.
Parameters: ip_address (string) – An IP address. Can be IPv4 or IPv6 Returns: A dictionary of information about the IP
-
list_global_ips
(version=None, identifier=None, **kwargs)[source]¶ Returns a list of all global IP address records on the account.
Parameters: - version (int) – Only returns IPs of this version (4 or 6)
- identifier (string) – If specified, the list will only contain the global ips matching this network identifier.
-
list_securitygroup_rules
(group_id)[source]¶ List security group rules associated with a security group.
Parameters: group_id (int) – The security group to list rules for
-
list_subnets
(identifier=None, datacenter=None, version=0, subnet_type=None, network_space=None, **kwargs)[source]¶ Display a list of all subnets on the account.
This provides a quick overview of all subnets including information about data center residence and the number of devices attached.
Parameters: - identifier (string) – If specified, the list will only contain the subnet matching this network identifier.
- datacenter (string) – If specified, the list will only contain subnets in the specified data center.
- version (int) – Only returns subnets of this version (4 or 6).
- subnet_type (string) – If specified, it will only returns subnets of this type.
- network_space (string) – If specified, it will only returns subnets with the given address space label.
- **kwargs (dict) – response-level options (mask, limit, etc.)
-
list_vlans
(datacenter=None, vlan_number=None, name=None, **kwargs)[source]¶ Display a list of all VLANs on the account.
This provides a quick overview of all VLANs including information about data center residence and the number of devices attached.
Parameters: - datacenter (string) – If specified, the list will only contain VLANs in the specified data center.
- vlan_number (int) – If specified, the list will only contain the VLAN matching this VLAN number.
- name (int) – If specified, the list will only contain the VLAN matching this VLAN name.
- **kwargs (dict) – response-level options (mask, limit, etc.)
-
remove_securitygroup_rule
(group_id, rule_id)[source]¶ Remove a rule from a security group.
Parameters: - group_id (int) – The ID of the security group
- rule_id (int) – The ID of the rule to remove
-
remove_securitygroup_rules
(group_id, rules)[source]¶ Remove rules from a security group.
Parameters: - group_id (int) – The ID of the security group
- rules (list) – The list of IDs to remove
-
summary_by_datacenter
()[source]¶ Summary of the networks on the account, grouped by data center.
The resultant dictionary is primarily useful for statistical purposes. It contains count information rather than raw data. If you want raw information, see the
list_vlans()
method instead.Returns: A dictionary keyed by data center with the data containing a set of counts for subnets, hardware, virtual servers, and other objects residing within that data center.
-
SoftLayer.ordering¶
Ordering Manager
license: | MIT, see LICENSE for more details. |
---|
-
class
SoftLayer.managers.ordering.
OrderingManager
(client)[source]¶ Manager to help ordering via the SoftLayer API.
Parameters: client (SoftLayer.API.BaseClient) – the client instance -
static
filter_outlet_packages
(packages)[source]¶ Remove packages designated as OUTLET.
Those type of packages must be handled in a different way, and they are not supported at the moment.
Parameters: packages – Dictionary of packages. Name and description keys must be present in each of them.
-
generate_order
(package_keyname, location, item_keynames, complex_type=None, hourly=True, preset_keyname=None, extras=None, quantity=1)[source]¶ Generates an order with the given package and prices.
This function takes in parameters needed for an order and generates an order dictionary. This dictionary can then be used in either verify or placeOrder().
Parameters: - package_keyname (str) – The keyname for the package being ordered
- location (str) – The datacenter location string for ordering (Ex: DALLAS13)
- item_keynames (list) – The list of item keyname strings to order. To see list of possible keynames for a package, use list_items() (or slcli order item-list)
- complex_type (str) – The complex type to send with the order. Typically begins with SoftLayer_Container_Product_Order_.
- hourly (bool) – If true, uses hourly billing, otherwise uses monthly billing
- preset_keyname (string) – If needed, specifies a preset to use for that package. To see a list of possible keynames for a package, use list_preset() (or slcli order preset-list)
- extras (dict) – The extra data for the order in dictionary format. Example: A VSI order requires hostname and domain to be set, so extras will look like the following: {‘virtualGuests’: [{‘hostname’: ‘test’, ‘domain’: ‘softlayer.com’}]}
- quantity (int) – The number of resources to order
-
generate_order_template
(quote_id, extra, quantity=1)[source]¶ Generate a complete order template.
Parameters: - quote_id (int) – ID of target quote
- extra (dictionary) – Overrides for the defaults of SoftLayer_Container_Product_Order
- quantity (int) – Number of items to order.
-
get_item_prices
(package_id)[source]¶ Get item prices.
Retrieve a SoftLayer_Product_Package item prices record.
Parameters: package_id (int) – package identifier. Returns: A list of price IDs associated with the given package.
-
get_location_id
(location)[source]¶ Finds the location ID of a given datacenter
This is mostly used so either a dc name, or regions keyname can be used when ordering :param str location: Region Keyname (DALLAS13) or datacenter name (dal13) :returns: integer id of the datacenter
-
static
get_only_active_packages
(packages)[source]¶ Return only active packages.
If a package is active, it is eligible for ordering This will inspect the ‘isActive’ property on the provided packages
Parameters: packages – Dictionary of packages, isActive key must be present
-
get_order_container
(quote_id)[source]¶ Generate an order container from a quote object.
Parameters: quote_id – ID number of target quote
-
get_package_by_key
(package_keyname, mask=None)[source]¶ Get a single package with a given key.
If no packages are found, returns None
Parameters: - package_keyname – string representing the package key name we are interested in.
- mask (string) – Mask to specify the properties we want to retrieve
-
get_package_by_type
(package_type, mask=None)[source]¶ Get a single package of a given type.
Syntactic sugar to retrieve a single package of a given type. If multiple packages share the given type, this will return the first one returned by the API. If no packages are found, returns None
Parameters: package_type (string) – representing the package type key name we are interested in
-
get_package_id_by_type
(package_type)[source]¶ Return the package ID of a Product Package with a given type.
Parameters: package_type (string) – representing the package type key name we are interested in Raises: ValueError – when no package of the given type is found
-
get_packages_of_type
(package_types, mask=None)[source]¶ Get packages that match a certain type.
Each ordering package has a type, so return all packages that match the types we are looking for
Parameters: - package_types (list) – List of strings representing the package type keynames we are interested in.
- mask (string) – Mask to specify the properties we want to retrieve
-
get_preset_by_key
(package_keyname, preset_keyname, mask=None)[source]¶ Gets a single preset with the given key.
-
get_preset_prices
(preset)[source]¶ Get preset item prices.
Retrieve a SoftLayer_Product_Package_Preset record.
Parameters: preset (int) – preset identifier. Returns: A list of price IDs associated with the given preset_id.
-
get_price_id_list
(package_keyname, item_keynames, core=None)[source]¶ Converts a list of item keynames to a list of price IDs.
This function is used to convert a list of item keynames into a list of price IDs that are used in the Product_Order verifyOrder() and placeOrder() functions.
Parameters: - package_keyname (str) – The package associated with the prices
- item_keynames (list) – A list of item keyname strings
- core (str) – preset guest core capacity.
Returns: A list of price IDs associated with the given item keynames in the given package
-
get_quote_details
(quote_id)[source]¶ Retrieve quote details.
Parameters: quote_id – ID number of target quote
-
get_quotes
()[source]¶ Retrieve a list of active quotes.
Returns: a list of SoftLayer_Billing_Order_Quote
-
list_categories
(package_keyname, **kwargs)[source]¶ List the categories for the given package.
Parameters: package_keyname (str) – The package for which to get the categories. Returns: List of categories associated with the package
-
list_items
(package_keyname, **kwargs)[source]¶ List the items for the given package.
Parameters: package_keyname (str) – The package for which to get the items. Returns: List of items in the package
-
list_presets
(package_keyname, **kwargs)[source]¶ Gets active presets for the given package.
Parameters: package_keyname (str) – The package for which to get presets Returns: A list of package presets that can be used for ordering
-
order_quote
(quote_id, extra)[source]¶ Places an order using a quote
extras = { 'hardware': {'hostname': 'test', 'domain': 'testing.com'}, 'quantity': 2 } manager = ordering.OrderingManager(env.client) result = manager.order_quote(12345, extras)
Parameters: - quote_id (int) – ID for the target quote
- extra (dictionary) – Overrides for the defaults of SoftLayer_Container_Product_Order
- quantity (int) – Quantity to override default
-
package_locations
(package_keyname)[source]¶ List datacenter locations for a package keyname
Parameters: package_keyname (str) – The package for which to get the items. Returns: List of locations a package is orderable in
-
place_order
(package_keyname, location, item_keynames, complex_type=None, hourly=True, preset_keyname=None, extras=None, quantity=1)[source]¶ Places an order with the given package and prices.
This function takes in parameters needed for an order and places the order.
Parameters: - package_keyname (str) – The keyname for the package being ordered
- location (str) – The datacenter location string for ordering (Ex: DALLAS13)
- item_keynames (list) – The list of item keyname strings to order. To see list of possible keynames for a package, use list_items() (or slcli order item-list)
- complex_type (str) – The complex type to send with the order. Typically begins with SoftLayer_Container_Product_Order_.
- hourly (bool) – If true, uses hourly billing, otherwise uses monthly billing
- preset_keyname (string) – If needed, specifies a preset to use for that package. To see a list of possible keynames for a package, use list_preset() (or slcli order preset-list)
- extras (dict) – The extra data for the order in dictionary format. Example: A VSI order requires hostname and domain to be set, so extras will look like the following: {‘virtualGuests’: [{‘hostname’: ‘test’, domain’: ‘softlayer.com’}]}
- quantity (int) – The number of resources to order
-
place_quote
(package_keyname, location, item_keynames, complex_type=None, preset_keyname=None, extras=None, quantity=1, quote_name=None, send_email=False)[source]¶ Place a quote with the given package and prices.
This function takes in parameters needed for an order and places the quote.
Parameters: - package_keyname (str) – The keyname for the package being ordered
- location (str) – The datacenter location string for ordering (Ex: DALLAS13)
- item_keynames (list) – The list of item keyname strings to order. To see list of possible keynames for a package, use list_items() (or slcli order item-list)
- complex_type (str) – The complex type to send with the order. Typically begins with SoftLayer_Container_Product_Order_.
- preset_keyname (string) – If needed, specifies a preset to use for that package. To see a list of possible keynames for a package, use list_preset() (or slcli order preset-list)
- extras (dict) – The extra data for the order in dictionary format. Example: A VSI order requires hostname and domain to be set, so extras will look like the following: {‘virtualGuests’: [{‘hostname’: ‘test’, domain’: ‘softlayer.com’}]}
- quantity (int) – The number of resources to order
- quote_name (string) – A custom name to be assigned to the quote (optional).
- send_email (bool) – This flag indicates that the quote should be sent to the email address associated with the account or order.
-
verify_order
(package_keyname, location, item_keynames, complex_type=None, hourly=True, preset_keyname=None, extras=None, quantity=1)[source]¶ Verifies an order with the given package and prices.
This function takes in parameters needed for an order and verifies the order to ensure the given items are compatible with the given package.
Parameters: - package_keyname (str) – The keyname for the package being ordered
- location (str) – The datacenter location string for ordering (Ex: DALLAS13)
- item_keynames (list) – The list of item keyname strings to order. To see list of possible keynames for a package, use list_items() (or slcli order item-list)
- complex_type (str) – The complex type to send with the order. Typically begins with SoftLayer_Container_Product_Order_.
- hourly (bool) – If true, uses hourly billing, otherwise uses monthly billing
- preset_keyname (string) – If needed, specifies a preset to use for that package. To see a list of possible keynames for a package, use list_preset() (or slcli order preset-list)
- extras (dict) – The extra data for the order in dictionary format. Example: A VSI order requires hostname and domain to be set, so extras will look like the following: ‘virtualGuests’: [{‘hostname’: ‘test’, ‘domain’: ‘softlayer.com’}]}
- quantity (int) – The number of resources to order
-
verify_quote
(quote_id, extra)[source]¶ Verifies that a quote order is valid.
extras = { 'hardware': {'hostname': 'test', 'domain': 'testing.com'}, 'quantity': 2 } manager = ordering.OrderingManager(env.client) result = manager.verify_quote(12345, extras)
Parameters: - quote_id (int) – ID for the target quote
- extra (dictionary) – Overrides for the defaults of SoftLayer_Container_Product_Order
- quantity (int) – Quantity to override default
-
static
SoftLayer.sshkey¶
SSH Key Manager/helpers
license: | MIT, see LICENSE for more details. |
---|
-
class
SoftLayer.managers.sshkey.
SshKeyManager
(client)[source]¶ Manages account SSH keys in SoftLayer.
See product information here: https://knowledgelayer.softlayer.com/procedure/ssh-keys
Parameters: client (SoftLayer.API.BaseClient) – the client instance -
add_key
(key, label, notes=None)[source]¶ Adds a new SSH key to the account.
Parameters: - key (string) – The SSH key to add
- label (string) – The label for the key
- notes (string) – Additional notes for the key
Returns: A dictionary of the new key’s information.
-
delete_key
(key_id)[source]¶ Permanently deletes an SSH key from the account.
Parameters: key_id (int) – The ID of the key to delete
-
edit_key
(key_id, label=None, notes=None)[source]¶ Edits information about an SSH key.
Parameters: - key_id (int) – The ID of the key to edit
- label (string) – The new label for the key
- notes (string) – Notes to set or change on the key
Returns: A Boolean indicating success or failure
-
get_key
(key_id)[source]¶ Returns full information about a single SSH key.
Parameters: key_id (int) – The ID of the key to retrieve Returns: A dictionary of information about the key
-
list_keys
(label=None)[source]¶ Lists all SSH keys on the account.
Parameters: label (string) – Filter list based on SSH key label Returns: A list of dictionaries with information about each key
-
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:
-
SoftLayer.ssl¶
SSL Manager/helpers
license: | MIT, see LICENSE for more details. |
---|
-
class
SoftLayer.managers.ssl.
SSLManager
(client)[source]¶ Manages SSL certificates in SoftLayer.
See product information here: http://www.softlayer.com/ssl-certificates
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.SSLManager(client)
Parameters: client (SoftLayer.API.BaseClient) – the client instance -
add_certificate
(certificate)[source]¶ Creates a new certificate.
Parameters: certificate (dict) – A dictionary representing the parts of the certificate. See sldn.softlayer.com for more info. Example:
cert = ?? result = mgr.add_certificate(certificate=cert)
-
edit_certificate
(certificate)[source]¶ Updates a certificate with the included options.
The provided dict must include an ‘id’ key and value corresponding to the certificate ID that should be updated.
Parameters: certificate (dict) – the certificate to update. Example:
# Updates the cert id 1234 cert['id'] = 1234 cert['certificate'] = ?? result = mgr.edit_certificate(certificate=cert)
-
get_certificate
(cert_id)[source]¶ Gets a certificate with the ID specified.
Parameters: cert_id (integer) – the certificate ID to retrieve Example:
cert = mgr.get_certificate(cert_id=1234) print(cert)
-
list_certs
(method='all')[source]¶ List all certificates.
Parameters: method (string) – The type of certificates to list. Options are ‘all’, ‘expired’, and ‘valid’. Returns: A list of dictionaries representing the requested SSL certs. Example:
# Get all valid SSL certs certs = mgr.list_certs(method='valid') print certs
-
SoftLayer.ticket¶
Ticket Manager/helpers
license: | MIT, see LICENSE for more details. |
---|
-
class
SoftLayer.managers.ticket.
TicketManager
(client)[source]¶ Manages SoftLayer support tickets.
See product information here: http://www.softlayer.com/support
Parameters: client (SoftLayer.API.BaseClient) – the client instance -
attach_hardware
(ticket_id=None, hardware_id=None)[source]¶ Attach hardware to a ticket.
Parameters: - ticket_id (integer) – the id of the ticket to attach to
- hardware_id (integer) – the id of the hardware to attach
Returns: dict – The new ticket attachment
-
attach_virtual_server
(ticket_id=None, virtual_id=None)[source]¶ Attach a virtual server to a ticket.
Parameters: - ticket_id (integer) – the id of the ticket to attach to
- virtual_id (integer) – the id of the virtual server to attach
Returns: dict – The new ticket attachment
-
create_ticket
(title=None, body=None, subject=None, priority=None)[source]¶ Create a new ticket.
Parameters: - title (string) – title for the new ticket
- body (string) – body for the new ticket
- subject (integer) – id of the subject to be assigned to the ticket
- priority (integer) – Value from 1 (highest) to 4 (lowest)
-
detach_hardware
(ticket_id=None, hardware_id=None)[source]¶ Detach hardware from a ticket.
Parameters: - ticket_id – the id of the ticket to detach from
- hardware_id – the id of the hardware to detach
Returns: bool – Whether the detachment was successful
-
detach_virtual_server
(ticket_id=None, virtual_id=None)[source]¶ Detach a virtual server from a ticket.
Parameters: - ticket_id – the id of the ticket to detach from
- virtual_id – the id of the virtual server to detach
Returns: bool – Whether the detachment was successful
-
get_ticket
(ticket_id)[source]¶ Get details about a ticket.
Parameters: ticket_id (integer) – the ticket ID Returns: dict – information about the specified ticket
-
list_tickets
(open_status=True, closed_status=True)[source]¶ List all tickets.
Parameters: - open_status (boolean) – include open tickets
- closed_status (boolean) – include closed tickets
-
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_ticket
(ticket_id=None, body=None)[source]¶ Update a ticket.
Parameters: - ticket_id (integer) – the id of the ticket to update
- body (string) – entry to update in the ticket
-
upload_attachment
(ticket_id=None, file_path=None, file_name=None)[source]¶ Upload an attachment to a ticket.
Parameters: - ticket_id (integer) – the id of the ticket to upload the attachment to
- file_path (string) – The path of the attachment to be uploaded
- file_name (string) – The name of the attachment shown in the ticket
Returns: dict – The uploaded attachment
-
SoftLayer.vs¶
VS Manager/helpers
license: | MIT, see LICENSE for more details. |
---|
-
class
SoftLayer.managers.vs.
VSManager
(client, ordering_manager=None)[source]¶ Manages SoftLayer Virtual Servers.
See product information here: http://www.softlayer.com/virtual-servers
Example:
# Initialize the VSManager. # 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.VSManager(client)
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_instance
(instance_id)[source]¶ Cancel an instance immediately, deleting all its data.
Parameters: instance_id (integer) – the instance ID to cancel Example:
# Cancels instance 12345 mgr.cancel_instance(12345)
-
capture
(instance_id, name, additional_disks=False, notes=None)[source]¶ Capture one or all disks from a VS to a SoftLayer image.
Parameters set to None will be ignored and not attempted to be updated.
Parameters: - instance_id (integer) – the instance ID to edit
- name (string) – name assigned to the image
- additional_disks (bool) – set to true to include all additional attached storage devices
- notes (string) – notes about this particular image
Returns: dictionary – information about the capture transaction.
- Example::
- name = “Testing Images” notes = “Some notes about this image” result = mgr.capture(instance_id=12345, name=name, notes=notes)
-
change_port_speed
(instance_id, public, speed)[source]¶ Allows you to change the port speed of a virtual server’s NICs.
Example:
#change the Public interface to 10Mbps on instance 12345 result = mgr.change_port_speed(instance_id=12345, public=True, speed=10) # result will be True or an Exception
Parameters: - instance_id (int) – The ID of the VS
- 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.
-
create_instance
(**kwargs)[source]¶ Creates a new virtual server instance.
Warning
This will add charges to your account
Example:
new_vsi = { 'domain': u'test01.labs.sftlyr.ws', 'hostname': u'minion05', 'datacenter': u'hkg02', 'flavor': 'BL1_1X2X100' 'dedicated': False, 'private': False, 'os_code' : u'UBUNTU_LATEST', 'hourly': True, 'ssh_keys': [1234], 'disks': ('100','25'), 'local_disk': True, 'tags': 'test, pleaseCancel', 'public_security_groups': [12, 15] } vsi = mgr.create_instance(**new_vsi) # vsi will have the newly created vsi details if done properly. print vsi
Parameters: - cpus (int) – The number of virtual CPUs to include in the instance.
- memory (int) – The amount of RAM to order.
- hourly (bool) – Flag to indicate if this server should be billed hourly (default) or monthly.
- hostname (string) – The hostname to use for the new server.
- domain (string) – The domain to use for the new server.
- local_disk (bool) – Flag to indicate if this should be a local disk (default) or a SAN disk.
- datacenter (string) – The short name of the data center in which the VS should reside.
- os_code (string) – The operating system to use. Cannot be specified if image_id is specified.
- image_id (int) – The GUID of the image to load onto the server. Cannot be specified if os_code is specified.
- dedicated (bool) – Flag to indicate if this should be housed on adedicated or shared host (default). This will incur a fee on your account.
- public_vlan (int) – The ID of the public VLAN on which you want this VS placed.
- public_security_groups (list) – The list of security group IDs to apply to the public interface
- private_security_groups (list) – The list of security group IDs to apply to the private interface
- private_vlan (int) – The ID of the private VLAN on which you want this VS placed.
- disks (list) – A list of disk capacities for this server.
- post_uri (string) – The URI of the post-install script to run after reload
- private (bool) – If true, the VS will be provisioned only with access to the private network. Defaults to false
- ssh_keys (list) – The SSH keys to add to the root user
- nic_speed (int) – The port speed to set
- tags (string) – tags to set on the VS as a comma separated list
- flavor (string) – The key name of the public virtual server flavor being ordered.
- host_id (int) – The host id of a dedicated host to provision a dedicated host virtual server on.
-
create_instances
(config_list)[source]¶ Creates multiple virtual server instances.
This takes a list of dictionaries using the same arguments as create_instance().
Warning
This will add charges to your account
Example:
# Define the instance we want to create. new_vsi = { 'domain': u'test01.labs.sftlyr.ws', 'hostname': u'minion05', 'datacenter': u'hkg02', 'flavor': 'BL1_1X2X100' 'dedicated': False, 'private': False, 'os_code' : u'UBUNTU_LATEST', 'hourly': True, 'ssh_keys': [1234], 'disks': ('100','25'), 'local_disk': True, 'tags': 'test, pleaseCancel', 'public_security_groups': [12, 15] } # using .copy() so we can make changes to individual nodes instances = [new_vsi.copy(), new_vsi.copy(), new_vsi.copy()] # give each its own hostname, not required. instances[0]['hostname'] = "multi-test01" instances[1]['hostname'] = "multi-test02" instances[2]['hostname'] = "multi-test03" vsi = mgr.create_instances(config_list=instances) #vsi will be a dictionary of all the new virtual servers print vsi
-
edit
(instance_id, userdata=None, hostname=None, domain=None, notes=None, tags=None)[source]¶ Edit hostname, domain name, notes, and/or the user data of a VS.
Parameters set to None will be ignored and not attempted to be updated.
Parameters: - instance_id (integer) – the instance ID to edit
- userdata (string) – user data on VS to edit. If none exist it will be created
- hostname (string) – valid hostname
- domain (string) – valid domain namem
- notes (string) – notes about this particular VS
- tags (string) – tags to set on the VS as a comma separated list. Use the empty string to remove all tags.
Returns: bool – True or an Exception
- Example::
- # Change the hostname on instance 12345 to ‘something’ result = mgr.edit(instance_id=12345 , hostname=”something”) #result will be True or an Exception
-
get_bandwidth_allocation
(instance_id)[source]¶ Combines getBandwidthAllotmentDetail() and getBillingCycleBandwidthUsage()
-
get_bandwidth_data
(instance_id, start_date=None, end_date=None, direction=None, rollup=3600)[source]¶ Gets bandwidth data for a server
Will get averaged bandwidth data for a given time period. If you use a rollup over 3600 be aware that the API will bump your start/end date to align with how data is stored. For example if you have a rollup of 86400 your start_date will be bumped to 00:00. If you are not using a time in the start/end date fields, this won’t really matter.
Parameters: - instance_id (int) – Hardware Id to get data for
- start_date (date) – Date to start pulling data for.
- end_date (date) – Date to finish pulling data for
- direction (string) – Can be either ‘public’, ‘private’, or None for both.
- rollup (int) – 300, 600, 1800, 3600, 43200 or 86400 seconds to average data over.
-
get_create_options
()[source]¶ Retrieves the available options for creating a VS.
Returns: A dictionary of creation options. Example:
# Prints out the create option dictionary options = mgr.get_create_options() print(options)
-
get_instance
(instance_id, **kwargs)[source]¶ Get details about a virtual server instance.
Parameters: instance_id (integer) – the instance ID Returns: A dictionary containing a large amount of information about the specified instance. Example:
# Print out instance ID 12345. vsi = mgr.get_instance(12345) print vsi # Print out only FQDN and primaryIP for instance 12345 object_mask = "mask[fullyQualifiedDomainName,primaryIpAddress]" vsi = mgr.get_instance(12345, mask=mask) print vsi
-
get_summary_data_usage
(instance_id, start_date=None, end_date=None, valid_type=None, summary_period=None)[source]¶ Retrieve the usage information of a virtual server.
Parameters: - instance_id (string) – a string identifier used to resolve ids
- start_date (string) – the start data to retrieve the vs usage information
- end_date (string) – the start data to retrieve the vs usage information
- string valid_type (string) – the Metric_Data_Type keyName.
- summary_period (int) – summary period.
-
get_tracking_id
(instance_id)[source]¶ Returns the Metric Tracking Object Id for a hardware server
Parameters: instance_id (int) – Id of the hardware server
-
list_instances
(hourly=True, monthly=True, tags=None, cpus=None, memory=None, hostname=None, domain=None, local_disk=None, datacenter=None, nic_speed=None, public_ip=None, private_ip=None, transient=None, **kwargs)[source]¶ Retrieve a list of all virtual servers on the account.
Example:
# Print out a list of hourly instances in the DAL05 data center. for vsi in mgr.list_instances(hourly=True, datacenter='dal05'): print vsi['fullyQualifiedDomainName'], vsi['primaryIpAddress'] # Using a custom object-mask. Will get ONLY what is specified object_mask = "mask[hostname,monitoringRobot[robotStatus]]" for vsi in mgr.list_instances(mask=object_mask,hourly=True): print vsi
Parameters: - hourly (boolean) – include hourly instances
- monthly (boolean) – include monthly instances
- tags (list) – filter based on list of tags
- cpus (integer) – filter based on number of CPUS
- memory (integer) – filter based on amount of memory
- hostname (string) – filter based on hostname
- domain (string) – filter based on domain
- local_disk (string) – filter based on local_disk
- 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
- transient (boolean) – filter on transient or non-transient instances
- **kwargs (dict) – response-level options (mask, limit, etc.)
Returns: Returns a list of dictionaries representing the matching virtual servers
-
order_guest
(guest_object, test=False)[source]¶ Uses Product_Order::placeOrder to create a virtual guest.
Useful when creating a virtual guest with options not supported by Virtual_Guest::createObject specifically ipv6 support.
Parameters: guest_object (dictionary) – See SoftLayer.CLI.virt.create._parse_create_args Example:
new_vsi = { 'domain': u'test01.labs.sftlyr.ws', 'hostname': u'minion05', 'datacenter': u'hkg02', 'flavor': 'BL1_1X2X100' 'dedicated': False, 'private': False, 'transient': False, 'os_code' : u'UBUNTU_LATEST', 'hourly': True, 'ssh_keys': [1234], 'disks': ('100','25'), 'local_disk': True, 'tags': 'test, pleaseCancel', 'public_security_groups': [12, 15], 'ipv6': True } vsi = mgr.order_guest(new_vsi) # vsi will have the newly created vsi receipt. # vsi['orderDetails']['virtualGuests'] will be an array of created Guests print vsi
-
reload_instance
(instance_id, post_uri=None, ssh_keys=None, image_id=None)[source]¶ Perform an OS reload of an instance.
Parameters: - instance_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
- image_id (int) – The GUID of the image to load onto the server
Warning
This will reformat the primary drive. Post-provision script MUST be HTTPS for it to be executed.
Example:
# Reload instance ID 12345 then run a custom post-provision script. # Post-provision script MUST be HTTPS for it to be executed. post_uri = 'https://somehost.com/bootstrap.sh' vsi = mgr.reload_instance(12345, post_uri=post_url)
-
rescue
(instance_id)[source]¶ Reboot a VSI into the Xen recsue kernel.
Parameters: instance_id (integer) – the instance ID to rescue Returns: bool – True or an Exception - Example::
- # Puts instance 12345 into rescue mode result = mgr.rescue(instance_id=12345)
-
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:
Sets tags on a guest with a retry decorator
Just calls guest.setTags, but if it fails from an APIError will retry
-
upgrade
(instance_id, cpus=None, memory=None, nic_speed=None, public=True, preset=None)[source]¶ Upgrades a VS instance.
Example:
# Upgrade instance 12345 to 4 CPUs and 4 GB of memory import SoftLayer client = SoftLayer.create_client_from_env() mgr = SoftLayer.VSManager(client) mgr.upgrade(12345, cpus=4, memory=4)
Parameters: - instance_id (int) – Instance id of the VS to be upgraded
- cpus (int) – The number of virtual CPUs to upgrade to of a VS instance.
- preset (string) – preset assigned to the vsi
- memory (int) – RAM of the VS to be upgraded to.
- nic_speed (int) – The port speed to set
- public (bool) – CPU will be in Private/Public Node.
Returns: bool
-
verify_create_instance
(**kwargs)[source]¶ Verifies an instance creation command.
Without actually placing an order. See
create_instance()
for a list of available options.Example:
new_vsi = { 'domain': u'test01.labs.sftlyr.ws', 'hostname': u'minion05', 'datacenter': u'hkg02', 'flavor': 'BL1_1X2X100' 'dedicated': False, 'private': False, 'transient': False, 'os_code' : u'UBUNTU_LATEST', 'hourly': True, 'ssh_keys': [1234], 'disks': ('100','25'), 'local_disk': True, 'tags': 'test, pleaseCancel', 'public_security_groups': [12, 15] } vsi = mgr.verify_create_instance(**new_vsi) # vsi will be a SoftLayer_Container_Product_Order_Virtual_Guest # if your order is correct. Otherwise you will get an exception print vsi
-
wait_for_ready
(instance_id, limit=3600, delay=10, pending=False)[source]¶ Determine if a VS is ready and available.
In some cases though, that can mean that no transactions are running. The default arguments imply a VS is operational and ready for use by having network connectivity and remote access is available. Setting
pending=True
will ensure future API calls against this instance will not error due to pending transactions such as OS Reloads and cancellations.Parameters: - instance_id (int) – The instance ID with the pending transaction
- limit (int) – The maximum amount of seconds to wait.
- delay (int) – The number of seconds to sleep before checks. Defaults to 10.
- pending (bool) – Wait for pending transactions not related to provisioning or reloads such as monitoring.
Example:
# Will return once vsi 12345 is ready, or after 10 checks ready = mgr.wait_for_ready(12345, 10)
-
wait_for_transaction
(instance_id, limit, delay=10)[source]¶ Waits on a VS transaction for the specified amount of time.
This is really just a wrapper for wait_for_ready(pending=True). Provided for backwards compatibility.
Parameters: - instance_id (int) – The instance ID with the pending transaction
- limit (int) – The maximum amount of time to wait.
- delay (int) – The number of seconds to sleep before checks. Defaults to 10.
SoftLayer.vs_capacity¶
Reserved Capacity Manager and helpers
license: | MIT, see License for more details. |
---|
-
class
SoftLayer.managers.vs_capacity.
CapacityManager
(client, ordering_manager=None)[source]¶ Manages SoftLayer Reserved Capacity Groups.
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.
-
create
(name, backend_router_id, flavor, instances, test=False)[source]¶ Orders a Virtual_ReservedCapacityGroup
Parameters: - name (string) – Name for the new reserved capacity
- backend_router_id (int) – This selects the pod. See create_options for a list
- flavor (string) – Capacity KeyName, see create_options for a list
- instances (int) – Number of guest this capacity can support
- test (bool) – If True, don’t actually order, just test.
-
create_guest
(capacity_id, test, guest_object)[source]¶ Turns an empty Reserve Capacity into a real Virtual Guest
Parameters: - capacity_id (int) – ID of the RESERVED_CAPACITY_GROUP to create this guest into
- test (bool) – True will use verifyOrder, False will use placeOrder
- guest_object (dictionary) – Below is the minimum info you need to send in guest_object = { ‘domain’: ‘test.com’, ‘hostname’: ‘A1538172419’, ‘os_code’: ‘UBUNTU_LATEST_64’, ‘primary_disk’: ‘25’, }
-
get_available_routers
(dc=None)[source]¶ Pulls down all backendRouterIds that are available
Parameters: dc (string) – A specific location to get routers for, like ‘dal13’. Returns list: A list of locations where RESERVED_CAPACITY can be ordered.
-
get_object
(identifier, mask=None)[source]¶ Get a Reserved Capacity Group
Parameters: - identifier (int) – Id of the SoftLayer_Virtual_ReservedCapacityGroup
- mask (string) – override default object Mask
-
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:
SoftLayer.vs_placement¶
Placement Group Manager
license: | MIT, see License for more details. |
---|
-
class
SoftLayer.managers.vs_placement.
PlacementManager
(client)[source]¶ Manages SoftLayer Reserved Capacity Groups.
Product Information
- https://console.test.cloud.ibm.com/docs/vsi/vsi_placegroup.html#placement-groups
- https://softlayer.github.io/reference/services/SoftLayer_Account/getPlacementGroups/
- https://softlayer.github.io/reference/services/SoftLayer_Virtual_PlacementGroup_Rule/
Existing instances cannot be added to a placement group. You can only add a virtual server instance to a placement group at provisioning. To remove an instance from a placement group, you must delete or reclaim the instance.
Parameters: client (SoftLayer.API.BaseClient) – the client instance -
create
(placement_object)[source]¶ Creates a placement group
A placement_object is defined as:
placement_object = { 'backendRouterId': 12345, 'name': 'Test Name', 'ruleId': 12345 }
Parameters: placement_object (dictionary) –
-
delete
(group_id)[source]¶ Deletes a PlacementGroup
Placement group must be empty to be deleted. https://softlayer.github.io/reference/services/SoftLayer_Virtual_PlacementGroup/deleteObject
-
get_backend_router_id_from_hostname
(hostname)[source]¶ Finds the backend router Id that matches the hostname given
No way to use an objectFilter to find a backendRouter, so we have to search the hard way.
-
get_object
(group_id, mask=None)[source]¶ Returns a PlacementGroup Object
https://softlayer.github.io/reference/services/SoftLayer_Virtual_PlacementGroup/getObject
-
get_rule_id_from_name
(name)[source]¶ Finds the rule that matches name.
SoftLayer_Virtual_PlacementGroup_Rule.getAllObjects doesn’t support objectFilters.
-
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:
If you need more power or functionality than the managers provide, you can make direct API calls as well.
Making API Calls¶
For full control over your account and services, you can directly call the SoftLayer API. The SoftLayer API client for python leverages SoftLayer’s XML-RPC API. It supports authentication, object masks, object filters, limits, offsets, and retrieving objects by id. The following section assumes you have an initialized client named ‘client’.
The best way to test our setup is to call the getObject method on the SoftLayer_Account service.
client.call('Account', 'getObject')
For a more complex example we’ll retrieve a support ticket with id 123456 along with the ticket’s updates, the user it’s assigned to, the servers attached to it, and the datacenter those servers are in. To retrieve our extra information using an object mask.
Retrieve a ticket using object masks.
ticket = client.call('Ticket', 'getObject',
id=123456, mask="updates, assignedUser, attachedHardware.datacenter")
Now add an update to the ticket with Ticket.addUpdate. This uses a parameter, which translate to positional arguments in the order that they appear in the API docs.
update = client.call('Ticket', 'addUpdate', {'entry' : 'Hello!'}, id=123456)
Let’s get a listing of virtual guests using the domain example.com
client.call('Account', 'getVirtualGuests',
filter={'virtualGuests': {'domain': {'operation': 'example.com'}}})
This call gets tickets created between the beginning of March 1, 2013 and March 15, 2013. More information on Object Filters.
NOTE: | The value field for startDate and endDate is in [], if you do not put the date in brackets the filter will not work. |
---|
client.call('Account', 'getTickets',
filter={
'tickets': {
'createDate': {
'operation': 'betweenDate',
'options': [
{'name': 'startDate', 'value': ['03/01/2013 0:0:0']},
{'name': 'endDate', 'value': ['03/15/2013 23:59:59']}
]
}
}
}
)
SoftLayer’s XML-RPC API also allows for pagination.
from pprint import pprint
page1 = client.call('Account', 'getVirtualGuests', limit=10, offset=0) # Page 1
page2 = client.call('Account', 'getVirtualGuests', limit=10, offset=10) # Page 2
#Automatic Pagination (v5.5.3+), default limit is 100
result = client.call('Account', 'getVirtualGuests', iter=True, limit=10)
pprint(result)
# Using a python generator, default limit is 100
results = client.iter_call('Account', 'getVirtualGuests', limit=10)
for result in results:
pprint(result)
NOTE: | client.call(iter=True) will pull all results, then return. client.iter_call() will return a generator, and only make API calls as you iterate over the results. |
---|
Here’s how to create a new Cloud Compute Instance using SoftLayer_Virtual_Guest.createObject. Be warned, this call actually creates an hourly virtual server so this will have billing implications.
client.call('Virtual_Guest', 'createObject', {
'hostname': 'myhostname',
'domain': 'example.com',
'startCpus': 1,
'maxMemory': 1024,
'hourlyBillingFlag': 'true',
'operatingSystemReferenceCode': 'UBUNTU_LATEST',
'localDiskFlag': 'false'
})
Debugging¶
If you ever need to figure out what exact API call the client is making, you can do the following:
NOTE the print_reproduceable method produces different output for REST and XML-RPC endpoints. If you are using REST, this will produce a CURL call. IF you are using XML-RPC, it will produce some pure python code you can use outside of the SoftLayer library.
# Setup the client as usual
client = SoftLayer.Client()
# Create an instance of the DebugTransport, which logs API calls
debugger = SoftLayer.DebugTransport(client.transport)
# Set that as the default client transport
client.transport = debugger
# Make your API call
client.call('Account', 'getObject')
# Print out the reproduceable call
for call in client.transport.get_last_calls():
print(client.transport.print_reproduceable(call))
API Reference¶
SoftLayer Python API Client¶
SoftLayer API bindings
Usage:
>>> import SoftLayer
>>> client = SoftLayer.create_client_from_env(username="username",
api_key="api_key")
>>> resp = client.call('Account', 'getObject')
>>> resp['companyName']
'Your Company'
license: | MIT, see LICENSE for more details. |
---|
-
class
SoftLayer.
BaseClient
(auth=None, transport=None)[source]¶ Base SoftLayer API client.
Parameters: - auth – auth driver that looks like SoftLayer.auth.AuthenticationBase
- transport – An object that’s callable with this signature: transport(SoftLayer.transports.Request)
-
authenticate_with_password
(username, password, security_question_id=None, security_question_answer=None)[source]¶ Performs Username/Password Authentication
Parameters: - username (string) – your SoftLayer username
- password (string) – your SoftLayer password
- security_question_id (int) – The security question id to answer
- security_question_answer (string) – The answer to the security question
-
call
(service, method, *args, **kwargs)[source]¶ Make a SoftLayer API call.
Parameters: - method – the method to call on the service
- *args – (optional) arguments for the remote call
- id – (optional) id for the resource
- mask – (optional) object mask
- filter (dict) – (optional) filter dict
- headers (dict) – (optional) optional XML-RPC headers
- compress (boolean) – (optional) Enable/Disable HTTP compression
- raw_headers (dict) – (optional) HTTP transport headers
- limit (int) – (optional) return at most this many results
- offset (int) – (optional) offset results by this many
- iter (boolean) – (optional) if True, returns a generator with the results
- verify (bool) – verify SSL cert
- cert – client certificate path
- Usage:
>>> import SoftLayer >>> client = SoftLayer.create_client_from_env() >>> client.call('Account', 'getVirtualGuests', mask="id", limit=10) [...]
-
iter_call
(service, method, *args, **kwargs)[source]¶ A generator that deals with paginating through results.
Parameters: - service – the name of the SoftLayer API service
- method – the method to call on the service
- limit (integer) – result size for each API call (defaults to 100)
- *args – same optional arguments that
Service.call
takes - **kwargs – same optional keyword arguments that
Service.call
takes
-
SoftLayer.
create_client_from_env
(username=None, api_key=None, endpoint_url=None, timeout=None, auth=None, config_file=None, proxy=None, user_agent=None, transport=None, verify=True)[source]¶ Creates a SoftLayer API client using your environment.
Settings are loaded via keyword arguments, environemtal variables and config file.
Parameters: - username – an optional API username if you wish to bypass the package’s built-in username
- api_key – an optional API key if you wish to bypass the package’s built in API key
- endpoint_url – the API endpoint base URL you wish to connect to. Set this to API_PRIVATE_ENDPOINT to connect via SoftLayer’s private network.
- proxy – proxy to be used to make API calls
- timeout (integer) – timeout for API requests
- auth – an object which responds to get_headers() to be inserted into the xml-rpc headers. Example: BasicAuthentication
- config_file – A path to a configuration file used to load settings
- user_agent – an optional User Agent to report when making API calls if you wish to bypass the packages built in User Agent string
- transport – An object that’s callable with this signature: transport(SoftLayer.transports.Request)
- verify (bool) – decide to verify the server’s SSL/TLS cert. DO NOT SET TO FALSE WITHOUT UNDERSTANDING THE IMPLICATIONS.
Usage:
>>> import SoftLayer >>> client = SoftLayer.create_client_from_env() >>> resp = client.call('Account', 'getObject') >>> resp['companyName'] 'Your Company'
-
SoftLayer.
Client
(**kwargs)[source]¶ Get a SoftLayer API Client using environmental settings.
Deprecated in favor of create_client_from_env()
-
class
SoftLayer.
BasicAuthentication
(username, api_key)[source]¶ Token-based authentication class.
Parameters: - str (api_key) – a user’s username
- str – a user’s API key
Command-line Interface¶
The SoftLayer command line interface is available via the slcli command available in your PATH. The slcli command is a reference implementation of SoftLayer API bindings for python and how to efficiently make API calls. See the Usage Examples section to see how to discover all of the functionality not fully documented here.
Account Commands¶
account events¶
Summary and acknowledgement of upcoming and ongoing maintenance events
account events [OPTIONS]
Options
-
--ack-all
¶
Acknowledge every upcoming event. Doing so will turn off the popup in the control portal
account event-detail¶
Details of a specific event, and ability to acknowledge event.
account event-detail [OPTIONS] IDENTIFIER
Options
-
--ack
¶
Acknowledge Event. Doing so will turn off the popup in the control portal
Arguments
-
IDENTIFIER
¶
Required argument
Call API¶
call-api¶
Call arbitrary API endpoints with the given SERVICE and METHOD.
Example:
slcli call-api Account getObject
slcli call-api Account getVirtualGuests --limit=10 --mask=id,hostname
slcli call-api Virtual_Guest getObject --id=12345
slcli call-api Metric_Tracking_Object getBandwidthData --id=1234 \
"2015-01-01 00:00:00" "2015-01-1 12:00:00" public
slcli call-api Account getVirtualGuests \
-f 'virtualGuests.datacenter.name=dal05' \
-f 'virtualGuests.maxCpu=4' \
--mask=id,hostname,datacenter.name,maxCpu
slcli call-api Account getVirtualGuests \
-f 'virtualGuests.datacenter.name IN dal05,sng01'
call-api [OPTIONS] SERVICE METHOD [PARAMETERS]...
Options
-
--id
<_id>
¶ Init parameter
-
-f
,
--filter
<_filters>
¶ Object filters. This should be of the form: ‘property=value’ or ‘nested.property=value’. Complex filters like betweenDate are not currently supported. (multiple occurrence permitted)
-
--mask
<mask>
¶ String-based object mask
-
--limit
<limit>
¶ Result limit
-
--offset
<offset>
¶ Result offset
-
--output-python
,
--no-output-python
¶
Show python example code instead of executing the call
Arguments
-
SERVICE
¶
Required argument
-
METHOD
¶
Required argument
-
PARAMETERS
¶
Optional argument(s)
Interacting with CDN¶
cdn detail¶
Detail a CDN Account.
cdn detail [OPTIONS] UNIQUE_ID
Options
-
--history
<history>
¶ Bandwidth, Hits, Ratio counted over history number of days ago. 89 is the maximum.
Arguments
-
UNIQUE_ID
¶
Required argument
cdn list¶
List all CDN accounts.
cdn list [OPTIONS]
Options
-
--sortby
<sortby>
¶ Column to sort by
Options: unique_id|domain|origin|vendor|cname|status
cdn origin-add¶
Create an origin path for an existing CDN mapping.
For more information see the following documentation:
https://cloud.ibm.com/docs/infrastructure/CDN?topic=CDN-manage-your-cdn#adding-origin-path-details
cdn origin-add [OPTIONS] UNIQUE_ID ORIGIN PATH
Options
-
-t
,
--origin-type
<origin_type>
¶ The origin type. [default: server]
Options: server|storage
-
-H
,
--header
<header>
¶ The host header to communicate with the origin.
-
-b
,
--bucket-name
<bucket_name>
¶ The name of the available resource [required if –origin-type=storage]
-
-p
,
--port
<port>
¶ The http port number. [default: 80]
-
-P
,
--protocol
<protocol>
¶ The protocol used by the origin. [default: http]
-
-o
,
--optimize-for
<optimize_for>
¶ Performance configuration [default: web]
Options: web|video|file
-
-e
,
--extensions
<extensions>
¶ File extensions that can be stored in the CDN, example: ‘jpg, png, pdf’
-
-c
,
--cache-query
<cache_query>
¶ Cache query rules with the following formats: ‘ignore-all’, ‘include: <query-names>’, ‘ignore: <query-names>’ [default: include-all]
Arguments
-
UNIQUE_ID
¶
Required argument
-
ORIGIN
¶
Required argument
-
PATH
¶
Required argument
cdn origin-list¶
List origin path for an existing CDN mapping.
cdn origin-list [OPTIONS] UNIQUE_ID
Arguments
-
UNIQUE_ID
¶
Required argument
cdn origin-remove¶
Removes an origin path for an existing CDN mapping.
cdn origin-remove [OPTIONS] UNIQUE_ID ORIGIN_PATH
Arguments
-
UNIQUE_ID
¶
Required argument
-
ORIGIN_PATH
¶
Required argument
cdn purge¶
Creates a purge record and also initiates the purge call.
- Example:
- slcli cdn purge 9779455 /article/file.txt
For more information see the following documentation:
https://cloud.ibm.com/docs/infrastructure/CDN?topic=CDN-manage-your-cdn#purging-cached-content
cdn purge [OPTIONS] UNIQUE_ID PATH
Arguments
-
UNIQUE_ID
¶
Required argument
-
PATH
¶
Required argument
Config¶
Creating an IBMID apikey IBMid for services
config setup¶
Setup the ~/.softlayer file with username and apikey.
Set the username to ‘apikey’ for cloud.ibm.com accounts.
config setup [OPTIONS]
Event-Log Commands¶
event-log get¶
Get Event Logs
- Example:
- slcli event-log get -d 01/01/2019 -D 02/01/2019 -t User -l 10
event-log get [OPTIONS]
Options
-
-d
,
--date-min
<date_min>
¶ The earliest date we want to search for event logs in mm/dd/yyyy format.
-
-D
,
--date-max
<date_max>
¶ The latest date we want to search for event logs in mm/dd/yyyy format.
-
-e
,
--obj-event
<obj_event>
¶ The event we want to get event logs for
-
-i
,
--obj-id
<obj_id>
¶ The id of the object we want to get event logs for
-
-t
,
--obj-type
<obj_type>
¶ The type of the object we want to get event logs for
-
-z
,
--utc-offset
<utc_offset>
¶ UTC Offset for searching with dates. +/-HHMM format [default: -0000]
-
--metadata
,
--no-metadata
¶
Display metadata if present [default: False]
-
-l
,
--limit
<limit>
¶ Total number of result to return. -1 to return ALL, there may be a LOT of these. [default: 50]
There are usually quite a few events on an account, so be careful when using the –limit -1 option. The command will automatically break requests out into smaller sub-requests, but this command may take a very long time to complete. It will however print out data as it comes in.
Currently the types are as follows, more may be added in the future.
:......................:
: types :
:......................:
: Account :
: CDN :
: User :
: Bare Metal Instance :
: API Authentication :
: Server :
: CCI :
: Image :
: Bluemix LB :
: Facility :
: Cloud Object Storage :
: Security Group :
:......................:
Interacting with Hardware¶
hw bandwidth¶
Bandwidth data over date range. Bandwidth is listed in GB
Using just a date might get you times off by 1 hour, use T00:01 to get just the specific days data Timezones can also be included with the YYYY-MM-DDTHH:mm:ss.00000-HH:mm format.
Due to some rounding and date alignment details, results here might be slightly different than results in the control portal.
Example:
slcli hw bandwidth 1234 -s 2019-05-01T00:01 -e 2019-05-02T00:00:01.00000-12:00
hw bandwidth [OPTIONS] IDENTIFIER
Options
-
-s
,
--start_date
<start_date>
¶ Start Date YYYY-MM-DD, YYYY-MM-DDTHH:mm:ss, [required]
-
-e
,
--end_date
<end_date>
¶ End Date YYYY-MM-DD, YYYY-MM-DDTHH:mm:ss [required]
-
-p
,
--summary_period
<summary_period>
¶ 300, 600, 1800, 3600, 43200 or 86400 seconds [default: 3600]
-
-q
,
--quite_summary
¶
Only show the summary table [default: False]
Arguments
-
IDENTIFIER
¶
Required argument
hw cancel¶
Cancel a dedicated server.
hw cancel [OPTIONS] IDENTIFIER
Options
-
--immediate
¶
Cancels the server immediately (instead of on the billing anniversary)
-
--comment
<comment>
¶ An optional comment to add to the cancellation ticket
-
--reason
<reason>
¶ An optional cancellation reason. See cancel-reasons for a list of available options
Arguments
-
IDENTIFIER
¶
Required argument
hw create¶
Order/create a dedicated server.
hw create [OPTIONS]
Options
-
-H
,
--hostname
<hostname>
¶ Host portion of the FQDN [required]
-
-D
,
--domain
<domain>
¶ Domain portion of the FQDN [required]
-
-s
,
--size
<size>
¶ Hardware size [required]
-
-o
,
--os
<os>
¶ OS install code [required]
-
-d
,
--datacenter
<datacenter>
¶ Datacenter shortname [required]
-
--port-speed
<port_speed>
¶ Port speeds [required]
-
--billing
<billing>
¶ Billing rate [default: hourly]
Options: hourly|monthly
-
-i
,
--postinstall
<postinstall>
¶ Post-install script to download
-
-k
,
--key
<key>
¶ SSH keys to add to the root user (multiple occurrence permitted)
-
--no-public
¶
Private network only
-
-e
,
--extra
<extra>
¶ Extra options (multiple occurrence permitted)
-
--test
¶
Do not actually create the server
-
-t
,
--template
<template>
¶ A template file that defaults the command-line options
-
--export
<export>
¶ Exports options to a template file
-
--wait
<wait>
¶ Wait until the server is finished provisioning for up to X seconds before returning
Provides some basic functionality to order a server. slcli order has a more full featured method of ordering servers. This command only supports the FAST_PROVISION type.
hw credentials¶
List server credentials.
hw credentials [OPTIONS] IDENTIFIER
Arguments
-
IDENTIFIER
¶
Required argument
hw detail¶
Get details for a hardware device.
hw detail [OPTIONS] IDENTIFIER
Options
-
--passwords
¶
Show passwords (check over your shoulder!)
-
--price
¶
Show associated prices
Arguments
-
IDENTIFIER
¶
Required argument
hw edit¶
Edit hardware details.
hw edit [OPTIONS] IDENTIFIER
Options
-
-D
,
--domain
<domain>
¶ Domain portion of the FQDN
-
-F
,
--userfile
<userfile>
¶ Read userdata from file
-
-g
,
--tag
<tag>
¶ Tags to set or empty string to remove all
-
-H
,
--hostname
<hostname>
¶ Host portion of the FQDN
-
-u
,
--userdata
<userdata>
¶ User defined metadata string
-
--public-speed
<public_speed>
¶ Public port speed. -1 is best speed available
Options: 0|10|100|1000|10000|-1
-
--private-speed
<private_speed>
¶ Private port speed. -1 is best speed available
Options: 0|10|100|1000|10000|-1
Arguments
-
IDENTIFIER
¶
Required argument
When setting port speed, use “-1” to indicate best possible configuration. Using 10/100/1000/10000 on a server with a redundant interface may result the interface entering a degraded state. See setPublicNetworkInterfaceSpeed for more information.
hw list¶
List hardware servers.
hw list [OPTIONS]
Options
-
-c
,
--cpu
<cpu>
¶ Filter by number of CPU cores
-
-D
,
--domain
<domain>
¶ Filter by domain
-
-d
,
--datacenter
<datacenter>
¶ Filter by datacenter
-
-H
,
--hostname
<hostname>
¶ Filter by hostname
-
-m
,
--memory
<memory>
¶ Filter by memory in gigabytes
-
-n
,
--network
<network>
¶ Filter by network port speed in Mbps
-
--tag
<tag>
¶ Filter by tags (multiple occurrence permitted)
-
--sortby
<sortby>
¶ Column to sort by [default: hostname]
-
--columns
<columns>
¶ Columns to display. [options: guid, primary_ip, backend_ip, datacenter, action, created_by, tags] [default: id,hostname,primary_ip,backend_ip,datacenter,action]
-
-l
,
--limit
<limit>
¶ How many results to get in one api call, default is 100 [default: 100]
hw power-cycle¶
Power cycle a server.
hw power-cycle [OPTIONS] IDENTIFIER
Arguments
-
IDENTIFIER
¶
Required argument
hw power-off¶
Power off an active server.
hw power-off [OPTIONS] IDENTIFIER
Arguments
-
IDENTIFIER
¶
Required argument
hw power-on¶
Power on a server.
hw power-on [OPTIONS] IDENTIFIER
Arguments
-
IDENTIFIER
¶
Required argument
hw reboot¶
Reboot an active server.
hw reboot [OPTIONS] IDENTIFIER
Options
-
--hard
,
--soft
¶
Perform a hard or soft reboot
Arguments
-
IDENTIFIER
¶
Required argument
hw reload¶
Reload operating system on a server.
hw reload [OPTIONS] IDENTIFIER
Options
-
-i
,
--postinstall
<postinstall>
¶ Post-install script to download (Only HTTPS executes, HTTP leaves file in /root
-
-k
,
--key
<key>
¶ SSH keys to add to the root user (multiple occurrence permitted)
Arguments
-
IDENTIFIER
¶
Required argument
hw rescue¶
Reboot server into a rescue image.
hw rescue [OPTIONS] IDENTIFIER
Arguments
-
IDENTIFIER
¶
Required argument
hw reflash-firmware¶
Reflash server firmware.
hw reflash-firmware [OPTIONS] IDENTIFIER
Arguments
-
IDENTIFIER
¶
Required argument
Reflash here means the current version of the firmware running on your server will be re-flashed onto the selected hardware. This does require a reboot. See slcli hw update-firmware if you want the newest version.
hw update-firmware¶
Update server firmware.
hw update-firmware [OPTIONS] IDENTIFIER
Arguments
-
IDENTIFIER
¶
Required argument
This function updates the firmware of a server. If already at the latest version, no software is installed.
Interacting with IPSEC Tunnels¶
The IPSEC Command-line Interface commands can be used to configure an existing IPSEC tunnel context. Subnets in the SoftLayer private network can be associated to the tunnel context along with user-defined remote subnets. Address translation entries may also be defined to provide NAT functionality from static subnet IP addresses associated with the tunnel context to user-defined remote subnet IP addresses.
Note
Most CLI actions that affect an IPSEC tunnel context do not result in configuration changes to SoftLayer network devices. A separate configure command is available to issue a device configuration request.
To see more information about the IPSEC tunnel context module and API internaction, see IPSEC Module documentation.
ipsec list¶
A list of all IPSEC tunnel contexts associated with the current user’s account can be retrieved via the ipsec list
command. This provides a brief overview of all tunnel contexts and can be used to retrieve an individual context’s identifier, which all other CLI commands require.
$ slcli ipsec list
:.....:..........:...............:..........................:........................:...........................:
: id : name : friendly name : internal peer IP address : remote peer IP address : created :
:.....:..........:...............:..........................:........................:...........................:
: 445 : ipsec038 : ipsec tunnel : 173.192.250.79 : 158.85.80.22 : 2012-03-05T14:07:34-06:00 :
:.....:..........:...............:..........................:........................:...........................:
ipsec detail¶
More detailed information can be retrieved for an individual context using the ipsec detail
command. Using the detail command, information about associated internal subnets, remote subnets, static subnets, service subnets and address translations may also be retrieved using multiple instances of the -i|--include
option.
$ slcli ipsec detail 445 -i at -i is -i rs -i sr -i ss
Context Details:
:.................................:...........................:
: name : value :
:.................................:...........................:
: id : 445 :
: name : ipsec038 :
: friendly name : ipsec tunnel :
: internal peer IP address : 173.192.250.79 :
: remote peer IP address : 158.85.80.22 :
: advanced configuration flag : 0 :
: preshared key : secret :
: phase 1 authentication : MD5 :
: phase 1 diffie hellman group : 0 :
: phase 1 encryption : DES :
: phase 1 key life : 240 :
: phase 2 authentication : MD5 :
: phase 2 diffie hellman group : 1 :
: phase 2 encryption : DES :
: phase 2 key life : 240 :
: phase 2 perfect forward secrecy : 1 :
: created : 2012-03-05T14:07:34-06:00 :
: modified : 2017-05-17T12:01:33-06:00 :
:.................................:...........................:
Address Translations:
:.......:...................:......................:...................:......................:.................:
: id : static IP address : static IP address id : remote IP address : remote IP address id : note :
:.......:...................:......................:...................:......................:.................:
: 15920 : 10.1.249.86 : 9791681 : 158.85.80.22 : 98828 : windows server :
: 15918 : 10.1.249.84 : 9791679 : 158.85.80.20 : 98824 : unix server :
:.......:...................:......................:...................:......................:.................:
Internal Subnets:
:........:....................:......:......:
: id : network identifier : cidr : note :
:........:....................:......:......:
: 180767 : 10.28.67.128 : 26 : :
:........:....................:......:......:
Remote Subnets:
:......:....................:......:......:
: id : network identifier : cidr : note :
:......:....................:......:......:
: 7852 : 158.85.80.20 : 30 : :
:......:....................:......:......:
Static Subnets:
:........:....................:......:......:
: id : network identifier : cidr : note :
:........:....................:......:......:
: 231807 : 10.1.249.84 : 30 : :
:........:....................:......:......:
Service Subnets:
:........:....................:......:......:
: id : network identifier : cidr : note :
:........:....................:......:......:
: 162079 : 10.0.80.0 : 25 : :
:........:....................:......:......:
ipsec update¶
Most values listed in the tunnel context detail printout can be modified using the ipsec update
command. The following is given when executing with the -h|--help
option and highlights all properties that may be modified.
$ slcli ipsec update -h
Usage: slcli ipsec update [OPTIONS] CONTEXT_ID
Update tunnel context properties.
Updates are made atomically, so either all are accepted or none are.
Key life values must be in the range 120-172800.
Phase 2 perfect forward secrecy must be in the range 0-1.
A separate configuration request should be made to realize changes on
network devices.
Options:
--friendly-name TEXT Friendly name value
--remote-peer TEXT Remote peer IP address value
--preshared-key TEXT Preshared key value
--p1-auth, --phase1-auth [MD5|SHA1|SHA256]
Phase 1 authentication value
--p1-crypto, --phase1-crypto [DES|3DES|AES128|AES192|AES256]
Phase 1 encryption value
--p1-dh, --phase1-dh [0|1|2|5] Phase 1 diffie hellman group value
--p1-key-ttl, --phase1-key-ttl INTEGER RANGE
Phase 1 key life value
--p2-auth, --phase2-auth [MD5|SHA1|SHA256]
Phase 2 authentication value
--p2-crypto, --phase2-crypto [DES|3DES|AES128|AES192|AES256]
Phase 2 encryption value
--p2-dh, --phase2-dh [0|1|2|5] Phase 2 diffie hellman group value
--p2-forward-secrecy, --phase2-forward-secrecy INTEGER RANGE
Phase 2 perfect forward secrecy value
--p2-key-ttl, --phase2-key-ttl INTEGER RANGE
Phase 2 key life value
-h, --help Show this message and exit.
ipsec configure¶
A request to configure SoftLayer network devices for a given tunnel context can be issued using the ipsec configure
command.
Note
Once a configuration request is received, the IPSEC tunnel context will be placed into an unmodifiable state, and further changes against the tunnel context will be prevented. Once configuration changes have been made, the tunnel context may again be modified. The unmodifiable state of a tunnel context is indicated by an advanced configuration flag value of 1.
ipsec subnet-add¶
Internal, remote and service subnets can be associated to an IPSEC tunnel context using the ipsec subnet-add
command. Additionally, remote subnets can be created using this same command, which will then be associated to the targeted tunnel context.
Note
The targeted subnet type must be specified. A subnet id must be provided when associating internal and service subnets. Either a subnet id or a network identifier must be provided when associating remote subnets. If a network identifier is provided when associating a remote subnet, that subnet will first be created and then associated to the tunnel context.
The following is an exmaple of associating an internal subnet to a tunnel context.
$ slcli ipsec subnet-add 445 --subnet-id 180767 --subnet-type internal
Added internal subnet #180767
The following is an example of creating and associating a remote subnet to a tunnel context.
$ slcli ipsec subnet-add 445 --subnet-type remote --network 50.100.0.0/26
Created subnet 50.100.0.0/26 #21268
Added remote subnet #21268
ipsec subnet-remove¶
Internal, remote and service subnets can be disassociated from an IPSEC tunnel context via the ipsec subnet-remove
command.
Note
The targeted subnet id and type must be specified. When disassociating remote subnets, that subnet record will also be deleted.
The following is an example of disassociating an internal subnet from a tunnel context.
$ slcli ipsec subnet-remove 445 --subnet-id 180767 --subnet-type internal
Removed internal subnet #180767
ipsec translation-add¶
Address translation entries can be added to a tunnel context to provide NAT functionality from a statically routed subnet associated with the tunnel context to a remote subnet. This action is performed with the ipsec translation-add
command.
Note
Both static and remote IP address values must be specified. An optional note value may also be provided.
The following is an example of adding a new address translation entry.
$ slcli ipsec translation-add 445 --static-ip 10.1.249.87 --remote-ip 50.100.0.10 --note 'email server'
Created translation from 10.1.249.87 to 50.100.0.10 #15922
ipsec translation-remove¶
Address translation entries can be removed using the ipsec translation-remove
command.
The following is an example of removing an address translation entry.
$ slcli ipsec translation-remove 445 --translation-id 15922
Removed translation #15922
ipsec translation-update¶
Address translation entries may also be modified using the ipsec translation-update
command.
The following is an example of updating an existing address translation entry.
$ slcli ipsec translation-update 445 --translation-id 15924 --static-ip 10.1.249.86 --remote-ip 50.100.0.8 --note 'new email server'
Updated translation #15924
LoadBalancers¶
These commands were added in version 5.8.0
LBaaS Commands¶
loadbal detail¶
Get Load Balancer as a Service details.
loadbal detail [OPTIONS] IDENTIFIER
Arguments
-
IDENTIFIER
¶
Required argument
loadbal health¶
Manage LBaaS health checks.
loadbal health [OPTIONS] IDENTIFIER
Options
-
--uuid
<uuid>
¶ Health check UUID to modify. [required]
-
-i
,
--interval
<interval>
¶ Seconds between checks. [2-60]
-
-r
,
--retry
<retry>
¶ Number of times before marking as DOWN. [1-10]
-
-t
,
--timeout
<timeout>
¶ Seconds to wait for a connection. [1-59]
-
-u
,
--url
<url>
¶ Url path for HTTP/HTTPS checks.
Arguments
-
IDENTIFIER
¶
Required argument
loadbal member-add¶
Add a new LBaaS members.
loadbal member-add [OPTIONS] IDENTIFIER
Options
-
--private
,
--public
¶
Private or public IP of the new member. [required]
-
-m
,
--member
<member>
¶ Member IP address. [required]
-
-w
,
--weight
<weight>
¶ Weight of this member.
Arguments
-
IDENTIFIER
¶
Required argument
loadbal member-remote¶
Remove a LBaaS member.
Member UUID can be found from slcli lb detail.
loadbal member-remote [OPTIONS] IDENTIFIER
Options
-
-m
,
--member
<member>
¶ Member UUID [required]
Arguments
-
IDENTIFIER
¶
Required argument
loadbal pool-add¶
Adds a listener to the identifier LB
loadbal pool-add [OPTIONS] IDENTIFIER
Options
-
-P
,
--frontProtocol
<frontprotocol>
¶ Protocol type to use for incoming connections [default: HTTP]
Options: HTTP|HTTPS|TCP
-
-p
,
--backProtocol
<backprotocol>
¶ Protocol type to use when connecting to backend servers. Defaults to whatever –frontProtocol is.
Options: HTTP|HTTPS|TCP
-
-f
,
--frontPort
<frontport>
¶ Internet side port [required]
-
-b
,
--backPort
<backport>
¶ Private side port [required]
-
-m
,
--method
<method>
¶ Balancing Method [default: ROUNDROBIN]
Options: ROUNDROBIN|LEASTCONNECTION|WEIGHTED_RR
-
-c
,
--connections
<connections>
¶ Maximum number of connections to allow.
-
-s
,
--sticky
¶
Make sessions sticky based on source_ip.
-
-x
,
--sslCert
<sslcert>
¶ SSL certificate ID. See slcli ssl list
Arguments
-
IDENTIFIER
¶
Required argument
loadbal pool-edit¶
Updates a listener’s configuration.
LISTENER should be a UUID, and can be found from slcli lb detail <IDENTIFIER>
loadbal pool-edit [OPTIONS] IDENTIFIER LISTENER
Options
-
-P
,
--frontProtocol
<frontprotocol>
¶ Protocol type to use for incoming connections
Options: HTTP|HTTPS|TCP
-
-p
,
--backProtocol
<backprotocol>
¶ Protocol type to use when connecting to backend servers. Defaults to whatever –frontProtocol is.
Options: HTTP|HTTPS|TCP
-
-f
,
--frontPort
<frontport>
¶ Internet side port
-
-b
,
--backPort
<backport>
¶ Private side port
-
-m
,
--method
<method>
¶ Balancing Method
Options: ROUNDROBIN|LEASTCONNECTION|WEIGHTED_RR
-
-c
,
--connections
<connections>
¶ Maximum number of connections to allow.
-
-s
,
--sticky
¶
Make sessions sticky based on source_ip.
-
-x
,
--sslCert
<sslcert>
¶ SSL certificate ID. See slcli ssl list
Arguments
-
IDENTIFIER
¶
Required argument
-
LISTENER
¶
Required argument
loadbal pool-delete¶
Removes the listener from identified LBaaS instance
LISTENER should be a UUID, and can be found from slcli lb detail <IDENTIFIER>
loadbal pool-delete [OPTIONS] IDENTIFIER LISTENER
Arguments
-
IDENTIFIER
¶
Required argument
-
LISTENER
¶
Required argument
loadbal l7pool-add¶
Adds a new l7 pool
-S is in colon deliminated format to make grouping IP:port:weight a bit easier.
loadbal l7pool-add [OPTIONS] IDENTIFIER
Options
-
-n
,
--name
<name>
¶ Name for this L7 pool. [required]
-
-m
,
--method
<method>
¶ Balancing Method. [default: ROUNDROBIN]
Options: ROUNDROBIN|LEASTCONNECTION|WEIGHTED_RR
-
-P
,
--protocol
<protocol>
¶ Protocol type to use for incoming connections [default: HTTP]
Options: HTTP|HTTPS
-
-S
,
--server
<server>
¶ Backend servers that are part of this pool. Format is colon deliminated. BACKEND_IP:PORT:WEIGHT. eg. 10.0.0.1:80:50 (multiple occurrence permitted) [required]
-
--healthPath
<healthpath>
¶ Health check path. [default: /]
-
--healthInterval
<healthinterval>
¶ Health check interval between checks. [default: 5]
-
--healthRetry
<healthretry>
¶ Health check number of times before marking as DOWN. [default: 2]
-
--healthTimeout
<healthtimeout>
¶ Health check timeout. [default: 2]
-
-s
,
--sticky
¶
Make sessions sticky based on source_ip.
Arguments
-
IDENTIFIER
¶
Required argument
loadbal l7pool-del¶
Deletes the identified pool
Identifier is L7Pool Id. NOT the UUID
loadbal l7pool-del [OPTIONS] IDENTIFIER
Arguments
-
IDENTIFIER
¶
Required argument
loadbal order¶
Creates a LB. Protocols supported are TCP, HTTP, and HTTPS.
loadbal order [OPTIONS]
Options
-
-n
,
--name
<name>
¶ Label for this loadbalancer. [required]
-
-d
,
--datacenter
<datacenter>
¶ Datacenter shortname (dal13). [required]
-
-l
,
--label
<label>
¶ A descriptive label for this loadbalancer.
-
-f
,
--frontend
<frontend>
¶ PROTOCOL:PORT string for incoming internet connections. [default: HTTP:80; required]
-
-b
,
--backend
<backend>
¶ PROTOCOL:PORT string for connecting to backend servers. [default: HTTP:80; required]
-
-m
,
--method
<method>
¶ Balancing Method. [default: ROUNDROBIN]
Options: ROUNDROBIN|LEASTCONNECTION|WEIGHTED_RR
-
-s
,
--subnet
<subnet>
¶ Private subnet Id to order the LB on. See slcli lb order-options [required]
-
--public
¶
Use a Public to Public loadbalancer. [default: False]
-
--verify
¶
Only verify an order, dont actually create one. [default: False]
Ordering¶
The Order Command-line Interface commands can be used to build an order for any product in the SoftLayer catalog.
The basic flow for ordering goes something like this…
- package-list
- category-list <package key name>
- item-list <package key name>
- place <package key name> <item key names> <location>
order package-list¶
List packages that can be ordered via the placeOrder API.
# List out all packages for ordering
slcli order package-list
# List out all packages with "server" in the name
slcli order package-list --keyword server
# Select only specifict package types
slcli order package-list --package_type BARE_METAL_CPU
order package-list [OPTIONS]
Options
-
--keyword
<keyword>
¶ A word (or string) used to filter package names.
-
--package_type
<package_type>
¶ The keyname for the type of package. BARE_METAL_CPU for example
Note
- CLOUD_SERVER: These are Virtual Servers
- BARE_METAL_INSTANCE: Hourly Bare Metal
- BARE_METAL_SERVER: Other monthly server types
- #_PROC_#_DRIVES: Packages in this format will contain only this CPU model and Drive bays
- ADDITIONAL_PRODUCTS: Additional IPs, Vlans, SSL certs and other things are in here
- NETWORK_GATEWAY_APPLIANCE: Vyattas
Bluemix services listed here may still need to be ordered through the Bluemix CLI/Portal
order package-locations¶
List Datacenters a package can be ordered in.
Use the location Key Name to place orders
order package-locations [OPTIONS] PACKAGE_KEYNAME
Arguments
-
PACKAGE_KEYNAME
¶
Required argument
order category-list¶
List the categories of a package.
# List the categories of Bare Metal servers
slcli order category-list BARE_METAL_SERVER
# List the required categories for Bare Metal servers
slcli order category-list BARE_METAL_SERVER --required
order category-list [OPTIONS] PACKAGE_KEYNAME
Options
-
--required
¶
List only the required categories for the package
Arguments
-
PACKAGE_KEYNAME
¶
Required argument
Shows all the available categories for a certain package, useful in finding the required categories. Categories that are required will need to have a corresponding item included with any orders
These are all the required categories for BARE_METAL_SERVER
$ slcli order category-list BARE_METAL_SERVER
:........................................:.......................:............:
: name : categoryCode : isRequired :
:........................................:.......................:............:
: Server : server : Y :
: Operating System : os : Y :
: RAM : ram : Y :
: Disk Controller : disk_controller : Y :
: First Hard Drive : disk0 : Y :
: Public Bandwidth : bandwidth : Y :
: Uplink Port Speeds : port_speed : Y :
: Remote Management : remote_management : Y :
: Primary IP Addresses : pri_ip_addresses : Y :
: VPN Management - Private Network : vpn_management : Y :
:........................................:.......................:............:
order item-list¶
List package items used for ordering.
The item keyNames listed can be used with slcli order place to specify the items that are being ordered in the package.
Note
Items with a numbered category, like disk0 or gpu0, can be included multiple times in an order to match how many of the item you want to order.
# List all items in the VSI package
slcli order item-list CLOUD_SERVER
# List Ubuntu OSes from the os category of the Bare Metal package
slcli order item-list BARE_METAL_SERVER --category os --keyword ubuntu
order item-list [OPTIONS] PACKAGE_KEYNAME
Options
-
--keyword
<keyword>
¶ A word (or string) used to filter item names.
-
--category
<category>
¶ Category code to filter items by
Arguments
-
PACKAGE_KEYNAME
¶
Required argument
Shows all the prices for a given package. Collect all the items you want included on your server. Don’t forget to include the required category items. If forgotten, order place
will tell you about it.
order preset-list¶
List package presets.
Note
Presets are set CPU / RAM / Disk allotments. You still need to specify required items. Some packages do not have presets.
# List the presets for Bare Metal servers
slcli order preset-list BARE_METAL_SERVER
# List the Bare Metal server presets that include a GPU
slcli order preset-list BARE_METAL_SERVER --keyword gpu
order preset-list [OPTIONS] PACKAGE_KEYNAME
Options
-
--keyword
<keyword>
¶ A word (or string) used to filter preset names.
Arguments
-
PACKAGE_KEYNAME
¶
Required argument
order place¶
Place or verify an order.
This CLI command is used for placing/verifying an order of the specified package in the given location (denoted by a datacenter’s long name). Orders made via the CLI can then be converted to be made programmatically by calling SoftLayer.OrderingManager.place_order() with the same keynames.
Packages for ordering can be retrieved from slcli order package-list Presets for ordering can be retrieved from slcli order preset-list (not all packages have presets)
Items can be retrieved from slcli order item-list. In order to find required items for the order, use slcli order category-list, and then provide the –category option for each category code in slcli order item-list.
Example:
# Order an hourly VSI with 4 CPU, 16 GB RAM, 100 GB SAN disk,
# Ubuntu 16.04, and 1 Gbps public & private uplink in dal13
slcli order place --billing hourly CLOUD_SERVER DALLAS13 \
GUEST_CORES_4 \
RAM_16_GB \
REBOOT_REMOTE_CONSOLE \
1_GBPS_PUBLIC_PRIVATE_NETWORK_UPLINKS \
BANDWIDTH_0_GB_2 \
1_IP_ADDRESS \
GUEST_DISK_100_GB_SAN \
OS_UBUNTU_16_04_LTS_XENIAL_XERUS_MINIMAL_64_BIT_FOR_VSI \
MONITORING_HOST_PING \
NOTIFICATION_EMAIL_AND_TICKET \
AUTOMATED_NOTIFICATION \
UNLIMITED_SSL_VPN_USERS_1_PPTP_VPN_USER_PER_ACCOUNT \
NESSUS_VULNERABILITY_ASSESSMENT_REPORTING \
--extras '{"virtualGuests": [{"hostname": "test", "domain": "softlayer.com"}]}' \
--complex-type SoftLayer_Container_Product_Order_Virtual_Guest
order place [OPTIONS] PACKAGE_KEYNAME LOCATION [ORDER_ITEMS]...
Options
-
--preset
<preset>
¶ The order preset (if required by the package)
-
--verify
¶
Flag denoting whether or not to only verify the order, not place it
-
--quantity
<quantity>
¶ The quantity of the item being ordered
-
--billing
<billing>
¶ Billing rate [default: hourly]
Options: hourly|monthly
-
--complex-type
<complex_type>
¶ The complex type of the order. Starts with ‘SoftLayer_Container_Product_Order’.
-
--extras
<extras>
¶ JSON string denoting extra data that needs to be sent with the order
Arguments
-
PACKAGE_KEYNAME
¶
Required argument
-
LOCATION
¶
Required argument
-
ORDER_ITEMS
¶
Optional argument(s)
Now that you have the package you want, the prices needed, and found a location, it is time to place an order.
order place <preset>¶
$ slcli --really order place --preset D2620V4_64GB_2X1TB_SATA_RAID_1 BARE_METAL_SERVER TORONTO \
OS_UBUNTU_16_04_LTS_XENIAL_XERUS_64_BIT \
BANDWIDTH_0_GB_2 \
1_GBPS_PRIVATE_NETWORK_UPLINK \
REBOOT_KVM_OVER_IP 1_IP_ADDRESS \
UNLIMITED_SSL_VPN_USERS_1_PPTP_VPN_USER_PER_ACCOUNT \
--extras '{"hardware": [{"hostname" : "testOrder", "domain": "cgallo.com"}]}' \
--complex-type SoftLayer_Container_Product_Order_Hardware_Server
order place <Virtual Server>¶
$ slcli order place --billing hourly CLOUD_SERVER DALLAS13 \
GUEST_CORES_4 \
RAM_16_GB \
REBOOT_REMOTE_CONSOLE \
1_GBPS_PUBLIC_PRIVATE_NETWORK_UPLINKS \
BANDWIDTH_0_GB_2 \
1_IP_ADDRESS \
GUEST_DISK_100_GB_SAN \
OS_UBUNTU_16_04_LTS_XENIAL_XERUS_MINIMAL_64_BIT_FOR_VSI \
MONITORING_HOST_PING \
NOTIFICATION_EMAIL_AND_TICKET \
AUTOMATED_NOTIFICATION \
UNLIMITED_SSL_VPN_USERS_1_PPTP_VPN_USER_PER_ACCOUNT \
NESSUS_VULNERABILITY_ASSESSMENT_REPORTING \
--extras '{"virtualGuests": [{"hostname": "test", "domain": "softlayer.com"}]}' \
--complex-type SoftLayer_Container_Product_Order_Virtual_Guest
Quotes¶
order quote¶
View and Order a quote
order quote [OPTIONS] QUOTE
Options
-
--verify
¶
If specified, will only show what the quote will order, will NOT place an order [default: False]
-
--quantity
<quantity>
¶ The quantity of the item being ordered if different from quoted value
-
--complex-type
<complex_type>
¶ The complex type of the order. Starts with ‘SoftLayer_Container_Product_Order’. [default: SoftLayer_Container_Product_Order_Hardware_Server]
-
-u
,
--userdata
<userdata>
¶ User defined metadata string
-
-F
,
--userfile
<userfile>
¶ Read userdata from file
-
-i
,
--postinstall
<postinstall>
¶ Post-install script to download
-
-k
,
--key
<key>
¶ SSH keys to add to the root user (multiple occurrence permitted)
-
--fqdn
<fqdn>
¶ <hostname>.<domain.name.tld> formatted name to use. Specify one fqdn per server (multiple occurrence permitted) [required]
-
--image
<image>
¶ Image ID. See: ‘slcli image list’ for reference
Arguments
-
QUOTE
¶
Required argument
order quote-detail¶
View a quote
order quote-detail [OPTIONS] QUOTE
Arguments
-
QUOTE
¶
Required argument
order place-quote¶
Place a quote.
This CLI command is used for creating a quote of the specified package in the given location (denoted by a datacenter’s long name). Orders made via the CLI can then be converted to be made programmatically by calling SoftLayer.OrderingManager.place_quote() with the same keynames.
Packages for ordering can be retrieved from slcli order package-list Presets for ordering can be retrieved from slcli order preset-list (not all packages have presets)
Items can be retrieved from slcli order item-list. In order to find required items for the order, use slcli order category-list, and then provide the –category option for each category code in slcli order item-list.
Example:
# Place quote a VSI with 4 CPU, 16 GB RAM, 100 GB SAN disk,
# Ubuntu 16.04, and 1 Gbps public & private uplink in dal13
slcli order place-quote --name "foobar" --send-email CLOUD_SERVER DALLAS13 \
GUEST_CORES_4 \
RAM_16_GB \
REBOOT_REMOTE_CONSOLE \
1_GBPS_PUBLIC_PRIVATE_NETWORK_UPLINKS \
BANDWIDTH_0_GB_2 \
1_IP_ADDRESS \
GUEST_DISK_100_GB_SAN \
OS_UBUNTU_16_04_LTS_XENIAL_XERUS_MINIMAL_64_BIT_FOR_VSI \
MONITORING_HOST_PING \
NOTIFICATION_EMAIL_AND_TICKET \
AUTOMATED_NOTIFICATION \
UNLIMITED_SSL_VPN_USERS_1_PPTP_VPN_USER_PER_ACCOUNT \
NESSUS_VULNERABILITY_ASSESSMENT_REPORTING \
--extras '{"virtualGuests": [{"hostname": "test", "domain": "softlayer.com"}]}' \
--complex-type SoftLayer_Container_Product_Order_Virtual_Guest
order place-quote [OPTIONS] PACKAGE_KEYNAME LOCATION [ORDER_ITEMS]...
Options
-
--preset
<preset>
¶ The order preset (if required by the package)
-
--name
<name>
¶ A custom name to be assigned to the quote (optional)
-
--send-email
¶
The quote will be sent to the email address associated with your user.
-
--complex-type
<complex_type>
¶ The complex type of the order. Starts with ‘SoftLayer_Container_Product_Order’.
-
--extras
<extras>
¶ JSON string denoting extra data that needs to be sent with the order
Arguments
-
PACKAGE_KEYNAME
¶
Required argument
-
LOCATION
¶
Required argument
-
ORDER_ITEMS
¶
Optional argument(s)
Reports¶
There are a few report type commands in the SLCLI.
summary¶
Account summary.
summary [OPTIONS]
Options
-
--sortby
<sortby>
¶ Column to sort by
Options: datacenter|hardware|virtual_servers|vlans|subnets|public_ips
A list of datacenters, and how many servers, VSI, vlans, subnets and public_ips are in each.
report bandwidth¶
Bandwidth report for every pool/server.
This reports on the total data transfered for each virtual sever, hardware server and bandwidth pool.
report bandwidth [OPTIONS]
Options
-
--start
<start>
¶ datetime in the format ‘YYYY-MM-DD’ or ‘YYYY-MM-DD HH:MM:SS’
-
--end
<end>
¶ datetime in the format ‘YYYY-MM-DD’ or ‘YYYY-MM-DD HH:MM:SS’
-
--sortby
<sortby>
¶ Column to sort by [default: hostname]
Users¶
Version 5.6.0 introduces the ability to interact with user accounts from the cli.
user create¶
This command will create a user on your account.
Options¶
-e, --email TEXT | |
Email address for this user. Required for creation. [required] | |
-p, --password TEXT | |
Password to set for this user. If no password is provided, user will be sent an email to generate one, which expires in 24 hours. ‘-p generate’ will create a password for you (Requires Python 3.6+). Passwords require 8+ characters, upper and lowercase, a number and a symbol. | |
-u, --from-user TEXT | |
Base user to use as a template for creating this user. Will default to the user running this command. Information provided in –template supersedes this template. | |
-t, --template TEXT | |
A json string describing https://softlayer.github.io/reference/datatypes/SoftLayer_User_Customer/ | |
-a, --api-key | Create an API key for this user. |
-h, --help | Show this message and exit. |
slcli user create my@email.com -e my@email.com -p generate -a -t '{"firstName": "Test", "lastName": "Testerson"}'
user list¶
This command will list all Active users on the account that your user has access to view. There is the option to also filter by username
user detail <user>¶
Gives a variety of details about a specific user. <user> can be a user id, or username. Will always print a basic set of information about the user, but there are a few extra flags to pull in more detailed information.
user detail <user> -p, –permissions¶
Will list the permissions the user has. To see a list of all possible permissions, or to change a user’s permissions, see user permissions <user>
user detail <user> -h, –hardware¶
Will list the Hardware and Dedicated Hosts the user is able to access.
user detail <user> -v, –virtual¶
Will list the Virtual Guests the user has access to.
user detail <user> -l, –logins¶
Show login history of this user for the last 30 days. IBMId Users will show logins properly, but may not show failed logins.
user detail <user> -e, –events¶
Shows things that are logged in the Event_Log service. Logins, reboots, reloads, and other such actions will show up here.
user permissions <user>¶
Will list off all permission keyNames, along with which are assigned to that specific user.
user edit-permissions¶
Enable or Disable specific permissions. It is possible to set multiple permissions in one command as well.
$ slcli user edit-permissions USERID --enable -p TICKET_EDIT -p TICKET_ADD -p TICKET_SEARCH
Will enable TICKET_EDIT, TICKET_ADD, and TICKET_SEARCH permissions for the USERID
user edit-details¶
Edit a User’s details
JSON strings should be enclosed in ‘’ and each item should be enclosed in “”
slcli user edit-details testUser -t '{"firstName": "Test", "lastName": "Testerson"}'
Options¶
-t, --template TEXT | |
A json string describing SoftLayer_User_Customer . [required] | |
-h, --help | Show this message and exit. |
Working with Virtual Servers¶
Using the SoftLayer portal to order virtual servers is fine, but for a number of reasons it’s often more convenient to use the command line. For this, you can use SoftLayer’s command-line client to make administrative tasks quicker and easier. This page gives an intro to working with SoftLayer virtual servers using SoftLayer’s command-line client.
Note
The following assumes that the client is already configured with valid SoftLayer credentials.
First, let’s list the current virtual servers with slcli vs list.
$ slcli vs list
:.....:............:.........................:.......:........:..............:.............:....................:........:
: id : datacenter : host : cores : memory : primary_ip : backend_ip : active_transaction : owner :
:.....:............:.........................:.......:........:..............:.............:....................:........:
:.....:............:.........................:.......:........:..............:.............:....................:........:
We don’t have any virtual servers yet! Let’s fix that. Before we can create a virtual server (VS), we need to know what options are available to us: RAM, CPU, operating systems, disk sizes, disk types, datacenters, and so on. Luckily, there’s a simple command to show all options: slcli vs create-options.
Some values were ommitted for brevity
$ slcli vs create-options
:................................:.................................................................................:
: name : value :
:................................:.................................................................................:
: datacenter : ams01 :
: : ams03 :
: : wdc07 :
: flavors (balanced) : B1_1X2X25 :
: : B1_1X2X25 :
: : B1_1X2X100 :
: cpus (standard) : 1,2,4,8,12,16,32,56 :
: cpus (dedicated) : 1,2,4,8,16,32,56 :
: cpus (dedicated host) : 1,2,4,8,12,16,32,56 :
: memory : 1024,2048,4096,6144,8192,12288,16384,32768,49152,65536,131072,247808 :
: memory (dedicated host) : 1024,2048,4096,6144,8192,12288,16384,32768,49152,65536,131072,247808 :
: os (CENTOS) : CENTOS_5_64 :
: : CENTOS_LATEST_64 :
: os (CLOUDLINUX) : CLOUDLINUX_5_64 :
: : CLOUDLINUX_6_64 :
: : CLOUDLINUX_LATEST :
: : CLOUDLINUX_LATEST_64 :
: os (COREOS) : COREOS_CURRENT_64 :
: : COREOS_LATEST :
: : COREOS_LATEST_64 :
: os (DEBIAN) : DEBIAN_6_64 :
: : DEBIAN_LATEST_64 :
: os (OTHERUNIXLINUX) : OTHERUNIXLINUX_1_64 :
: : OTHERUNIXLINUX_LATEST :
: : OTHERUNIXLINUX_LATEST_64 :
: os (REDHAT) : REDHAT_5_64 :
: : REDHAT_6_64 :
: : REDHAT_7_64 :
: : REDHAT_LATEST :
: : REDHAT_LATEST_64 :
: san disk(0) : 25,100 :
: san disk(2) : 10,20,25,30,40,50,75,100,125,150,175,200,250,300,350,400,500,750,1000,1500,2000 :
: local disk(0) : 25,100 :
: local disk(2) : 25,100,150,200,300 :
: local (dedicated host) disk(0) : 25,100 :
: nic (dedicated host) : 100,1000 :
:................................:.................................................................................:
Here’s the command to create a 2-core virtual server with 1GiB memory, running Ubuntu 14.04 LTS, and that is billed on an hourly basis in the San Jose 1 datacenter using the command slcli vs create.
$ slcli vs create --hostname=example --domain=softlayer.com -f B1_1X2X25 -o DEBIAN_LATEST_64 --datacenter=ams01 --billing=hourly
This action will incur charges on your account. Continue? [y/N]: y
:..........:.................................:......................................:...........................:
: ID : FQDN : guid : Order Date :
:..........:.................................:......................................:...........................:
: 70112999 : testtesttest.test.com : 1abc7afb-9618-4835-89c9-586f3711d8ea : 2019-01-30T17:16:58-06:00 :
:..........:.................................:......................................:...........................:
:.........................................................................:
: OrderId: 12345678 :
:.......:.................................................................:
: Cost : Description :
:.......:.................................................................:
: 0.0 : Debian GNU/Linux 9.x Stretch/Stable - Minimal Install (64 bit) :
: 0.0 : 25 GB (SAN) :
: 0.0 : Reboot / Remote Console :
: 0.0 : 100 Mbps Public & Private Network Uplinks :
: 0.0 : 0 GB Bandwidth Allotment :
: 0.0 : 1 IP Address :
: 0.0 : Host Ping and TCP Service Monitoring :
: 0.0 : Email and Ticket :
: 0.0 : Automated Reboot from Monitoring :
: 0.0 : Unlimited SSL VPN Users & 1 PPTP VPN User per account :
: 0.0 : Nessus Vulnerability Assessment & Reporting :
: 0.0 : 2 GB :
: 0.0 : 1 x 2.0 GHz or higher Core :
: 0.000 : Total hourly cost :
:.......:.................................................................:
After the last command, the virtual server is now being built. It should instantly appear in your virtual server list now.
$ slcli vs list
:.........:............:.......................:.......:........:................:..............:....................:
: id : datacenter : host : cores : memory : primary_ip : backend_ip : active_transaction :
:.........:............:.......................:.......:........:................:..............:....................:
: 1234567 : ams01 : example.softlayer.com : 2 : 1G : 108.168.200.11 : 10.54.80.200 : Assign Host :
:.........:............:.......................:.......:........:................:..............:....................:
Cool. You may ask, “It’s creating… but how do I know when it’s done?” Well, here’s how:
$ slcli vs ready 'example' --wait=600
READY
When the previous command returns, you’ll know that the virtual server has finished the provisioning process and is ready to use. This is very useful for chaining commands together.
Now that you have your virtual server, let’s get access to it. To do that, use the slcli vs detail command. From the example below, you can see that the username is ‘root’ and password is ‘ABCDEFGH’.
Warning
Be careful when using the –passwords flag. This will print the virtual server’s password on the screen. Make sure no one is looking over your shoulder. It’s also advisable to change your root password soon after creating your virtual server, or to create a user with sudo access and disable SSH-based login directly to the root account.
$ slcli vs detail example --passwords
:..............:...........................:
: Name : Value :
:..............:...........................:
: id : 1234567 :
: hostname : example.softlayer.com :
: status : Active :
: state : Running :
: datacenter : ams01 :
: cores : 2 :
: memory : 1G :
: public_ip : 108.168.200.11 :
: private_ip : 10.54.80.200 :
: os : Debian :
: private_only : False :
: private_cpu : False :
: created : 2013-06-13T08:29:44-06:00 :
: modified : 2013-06-13T08:31:57-06:00 :
: users : root ABCDEFGH :
:..............:...........................:
vs bandwidth¶
Bandwidth data over date range. Bandwidth is listed in GB
Using just a date might get you times off by 1 hour, use T00:01 to get just the specific days data Timezones can also be included with the YYYY-MM-DDTHH:mm:ss.00000-HH:mm format.
Due to some rounding and date alignment details, results here might be slightly different than results in the control portal.
Example:
slcli hw bandwidth 1234 -s 2019-05-01T00:01 -e 2019-05-02T00:00:01.00000-12:00
vs bandwidth [OPTIONS] IDENTIFIER
Options
-
-s
,
--start_date
<start_date>
¶ Start Date YYYY-MM-DD, YYYY-MM-DDTHH:mm:ss, [required]
-
-e
,
--end_date
<end_date>
¶ End Date YYYY-MM-DD, YYYY-MM-DDTHH:mm:ss [required]
-
-p
,
--summary_period
<summary_period>
¶ 300, 600, 1800, 3600, 43200 or 86400 seconds [default: 3600]
-
-q
,
--quite_summary
¶
Only show the summary table [default: False]
Arguments
-
IDENTIFIER
¶
Required argument
If no timezone is specified, IMS local time (CST) will be assumed, which might not match your user’s selected timezone.
vs cancel¶
Cancel virtual servers.
vs cancel [OPTIONS] IDENTIFIER
Arguments
-
IDENTIFIER
¶
Required argument
vs capture¶
Capture one or all disks from a virtual server to a SoftLayer image.
vs capture [OPTIONS] IDENTIFIER
Options
-
-n
,
--name
<name>
¶ Name of the image [required]
-
--all
<all>
¶ Capture all disks belonging to the VS
-
--note
<note>
¶ Add a note to be associated with the image
Arguments
-
IDENTIFIER
¶
Required argument
vs create¶
Order/create virtual servers.
vs create [OPTIONS]
Options
-
-H
,
--hostname
<hostname>
¶ Host portion of the FQDN [required]
-
-D
,
--domain
<domain>
¶ Domain portion of the FQDN [required]
-
-c
,
--cpu
<cpu>
¶ Number of CPU cores (not available with flavors)
-
-m
,
--memory
<memory>
¶ Memory in mebibytes (not available with flavors)
-
-f
,
--flavor
<flavor>
¶ Public Virtual Server flavor key name
-
-d
,
--datacenter
<datacenter>
¶ Datacenter shortname [required]
-
-o
,
--os
<os>
¶ OS install code. Tip: you can specify <OS>_LATEST
-
--image
<image>
¶ Image ID. See: ‘slcli image list’ for reference
-
--boot-mode
<boot_mode>
¶ Specify the mode to boot the OS in. Supported modes are HVM and PV.
-
--billing
<billing>
¶ Billing rate [default: hourly]
Options: hourly|monthly
-
--dedicated
,
--public
¶
Create a Dedicated Virtual Server
-
--host-id
<host_id>
¶ Host Id to provision a Dedicated Host Virtual Server onto
-
--san
¶
Use SAN storage instead of local disk.
-
--test
¶
Do not actually create the virtual server
-
--export
<export>
¶ Exports options to a template file
-
-i
,
--postinstall
<postinstall>
¶ Post-install script to download
-
-k
,
--key
<key>
¶ SSH keys to add to the root user (multiple occurrence permitted)
-
--disk
<disk>
¶ Disk sizes (multiple occurrence permitted)
-
--private
¶
Forces the VS to only have access the private network
-
--like
<like>
¶ Use the configuration from an existing VS
-
-n
,
--network
<network>
¶ Network port speed in Mbps
-
-g
,
--tag
<tag>
¶ Tags to add to the instance (multiple occurrence permitted)
-
-t
,
--template
<template>
¶ A template file that defaults the command-line options
-
-u
,
--userdata
<userdata>
¶ User defined metadata string
-
-F
,
--userfile
<userfile>
¶ Read userdata from file
-
--vlan-public
<vlan_public>
¶ The ID of the public VLAN on which you want the virtual server placed
-
--vlan-private
<vlan_private>
¶ The ID of the private VLAN on which you want the virtual server placed
-
--subnet-public
<subnet_public>
¶ The ID of the public SUBNET on which you want the virtual server placed
-
--subnet-private
<subnet_private>
¶ The ID of the private SUBNET on which you want the virtual server placed
-
-S
,
--public-security-group
<public_security_group>
¶ Security group ID to associate with the public interface (multiple occurrence permitted)
-
-s
,
--private-security-group
<private_security_group>
¶ Security group ID to associate with the private interface (multiple occurrence permitted)
-
--wait
<wait>
¶ Wait until VS is finished provisioning for up to X seconds before returning
-
--placementgroup
<placementgroup>
¶ Placement Group name or Id to order this guest on. See: slcli vs placementgroup list
-
--ipv6
¶
Adds an IPv6 address to this guest
-
--transient
¶
Create a transient virtual server
vs dns-sync¶
Sync DNS records.
vs dns-sync [OPTIONS] IDENTIFIER
Options
-
-a
,
--a-record
¶
Sync the A record for the host
-
--aaaa-record
¶
Sync the AAAA record for the host
-
--ptr
¶
Sync the PTR record for the host
-
--ttl
<ttl>
¶ Sets the TTL for the A and/or PTR records [default: 7200]
Arguments
-
IDENTIFIER
¶
Required argument
vs edit¶
Edit a virtual server’s details.
vs edit [OPTIONS] IDENTIFIER
Options
-
-D
,
--domain
<domain>
¶ Domain portion of the FQDN
-
-H
,
--hostname
<hostname>
¶ Host portion of the FQDN. example: server
-
-g
,
--tag
<tag>
¶ Tags to set or empty string to remove all
-
-u
,
--userdata
<userdata>
¶ User defined metadata string
-
-F
,
--userfile
<userfile>
¶ Read userdata from file
-
--public-speed
<public_speed>
¶ Public port speed.
Options: 0|10|100|1000|10000
-
--private-speed
<private_speed>
¶ Private port speed.
Options: 0|10|100|1000|10000
Arguments
-
IDENTIFIER
¶
Required argument
vs list¶
List virtual servers.
vs list [OPTIONS]
Options
-
-c
,
--cpu
<cpu>
¶ Number of CPU cores
-
-D
,
--domain
<domain>
¶ Domain portion of the FQDN
-
-d
,
--datacenter
<datacenter>
¶ Datacenter shortname
-
-H
,
--hostname
<hostname>
¶ Host portion of the FQDN
-
-m
,
--memory
<memory>
¶ Memory in mebibytes
-
-n
,
--network
<network>
¶ Network port speed in Mbps
-
--hourly
¶
Show only hourly instances
-
--monthly
¶
Show only monthly instances
-
--transient
<transient>
¶ Filter by transient instances
-
--tag
<tag>
¶ Filter by tags (multiple occurrence permitted)
-
--sortby
<sortby>
¶ Column to sort by [default: hostname]
-
--columns
<columns>
¶ Columns to display. [options: guid, primary_ip, backend_ip, datacenter, action, power_state, created_by, tags] [default: id,hostname,primary_ip,backend_ip,datacenter,action]
-
-l
,
--limit
<limit>
¶ How many results to get in one api call, default is 100 [default: 100]
vs pause¶
Pauses an active virtual server.
vs pause [OPTIONS] IDENTIFIER
Arguments
-
IDENTIFIER
¶
Required argument
vs power-on¶
Power on a virtual server.
vs power-on [OPTIONS] IDENTIFIER
Arguments
-
IDENTIFIER
¶
Required argument
vs power-off¶
Power off an active virtual server.
vs power-off [OPTIONS] IDENTIFIER
Options
-
--hard
,
--soft
¶
Perform a hard shutdown
Arguments
-
IDENTIFIER
¶
Required argument
vs resume¶
Resumes a paused virtual server.
vs resume [OPTIONS] IDENTIFIER
Arguments
-
IDENTIFIER
¶
Required argument
vs rescue¶
Reboot into a rescue image.
vs rescue [OPTIONS] IDENTIFIER
Arguments
-
IDENTIFIER
¶
Required argument
vs reboot¶
Reboot an active virtual server.
vs reboot [OPTIONS] IDENTIFIER
Options
-
--hard
,
--soft
¶
Perform a hard or soft reboot
Arguments
-
IDENTIFIER
¶
Required argument
vs ready¶
Check if a virtual server is ready.
vs ready [OPTIONS] IDENTIFIER
Options
-
--wait
<wait>
¶ Seconds to wait [default: 0]
Arguments
-
IDENTIFIER
¶
Required argument
vs upgrade¶
Upgrade a virtual server.
vs upgrade [OPTIONS] IDENTIFIER
Options
-
--cpu
<cpu>
¶ Number of CPU cores
-
--private
¶
CPU core will be on a dedicated host server.
-
--memory
<memory>
¶ Memory in megabytes
-
--network
<network>
¶ Network port speed in Mbps
-
--flavor
<flavor>
¶ Flavor keyName Do not use –memory, –cpu or –private, if you are using flavors
Arguments
-
IDENTIFIER
¶
Required argument
vs usage¶
Usage information of a virtual server.
vs usage [OPTIONS] IDENTIFIER
Options
-
-s
,
--start_date
<start_date>
¶ Start Date e.g. 2019-3-4 (yyyy-MM-dd) [required]
-
-e
,
--end_date
<end_date>
¶ End Date e.g. 2019-4-2 (yyyy-MM-dd) [required]
-
-t
,
--valid_type
<valid_type>
¶ Metric_Data_Type keyName e.g. CPU0, CPU1, MEMORY_USAGE, etc. [required]
-
-p
,
--summary_period
<summary_period>
¶ 300, 600, 1800, 3600, 43200 or 86400 seconds
Arguments
-
IDENTIFIER
¶
Required argument
Reserved Capacity¶
Working with Reserved Capacity¶
There are two main concepts for Reserved Capacity. The Reserved Capacity Group and the Reserved Capacity Instance The Reserved Capacity Group, is a set block of capacity set aside for you at the time of the order. It will contain a set number of Instances which are all the same size. Instances can be ordered like normal VSIs, with the exception that you need to include the reservedCapacityGroupId, and it must be the same size as the group you are ordering the instance in.
The SLCLI supports some basic Reserved Capacity Features.
vs capacity create¶
This command will create a Reserved Capacity Group.
Warning
These groups can not be canceled until their contract expires in 1 or 3 years!
$ slcli vs capacity create --name test-capacity -d dal13 -b 1411193 -c B1_1X2_1_YEAR_TERM -q 10
vs cacpacity create_options¶
This command will print out the Flavors that can be used to create a Reserved Capacity Group, as well as the backend routers available, as those are needed when creating a new group.
vs capacity create_guest¶
This command will create a virtual server (Reserved Capacity Instance) inside of your Reserved Capacity Group. This command works very similar to the slcli vs create command.
$ slcli vs capacity create-guest --capacity-id 1234 --primary-disk 25 -H ABCD -D test.com -o UBUNTU_LATEST_64 --ipv6 -k test-key --test
vs capacity detail¶
This command will print out some basic information about the specified Reserved Capacity Group.
vs capacity list¶
This command will list out all Reserved Capacity Groups. a # symbol represents a filled instance, and a - symbol respresents an empty instance
$ slcli vs capacity list
:............................................................................................................:
: Reserved Capacity :
:......:......................:............:......................:..............:...........................:
: ID : Name : Capacity : Flavor : Location : Created :
:......:......................:............:......................:..............:...........................:
: 1234 : test-capacity : ####------ : B1.1x2 (1 Year Term) : bcr02a.dal13 : 2018-09-24T16:33:09-06:00 :
:......:......................:............:......................:..............:...........................:
Placement Groups¶
Working with Placement Groups¶
A Placement Group is a way to control which physical servers your virtual servers get provisioned onto.
To create a Virtual_PlacementGroup object, you will need to know the following:
- backendRouterId, from getAvailableRouters
- ruleId, from getAllObjects
- name, can be any string, but most be unique on your account
Once a placement group is created, you can create new virtual servers in that group. Existing VSIs cannot be moved into a placement group. When ordering a VSI in a placement group, make sure to set the placementGroupId for each guest in your order.
use the –placementgroup option with vs create to specify creating a VSI in a specific group.
$ slcli vs create -H testGroup001 -D test.com -f B1_1X2X25 -d mex01 -o DEBIAN_LATEST --placementgroup testGroup
Placement groups can only be deleted once all the virtual guests in the group have been reclaimed.
vs placementgroup create¶
This command will create a placement group.
$ slcli vs placementgroup create --name testGroup -b bcr02a.dal06 -r SPREAD
--name TEXT | Name for this new placement group. [required] |
-b, --backend_router TEXT | |
backendRouter, can be either the hostname or id. [required] | |
-r, --rule TEXT | |
The keyName or Id of the rule to govern this placement group. [required] |
vs placementgroup create-options¶
This command will print out the available routers and rule sets for use in creating a placement group.
$ slcli vs placementgroup create-options
:.................................................:
: Available Routers :
:..............:..............:...................:
: Datacenter : Hostname : Backend Router Id :
:..............:..............:...................:
: Washington 1 : bcr01.wdc01 : 16358 :
: Tokyo 5 : bcr01a.tok05 : 1587015 :
:..............:..............:...................:
:..............:
: Rules :
:....:.........:
: Id : KeyName :
:....:.........:
: 1 : SPREAD :
:....:.........:
vs placementgroup delete¶
This command will remove a placement group. The placement group needs to be empty for this command to succeed.
--purge | Delete all guests in this placement group. The group itself can be deleted once all VMs are fully reclaimed |
$ slcli vs placementgroup delete testGroup
You can use the flag –purge to auto-cancel all VSIs in a placement group. You will still need to wait for them to be reclaimed before proceeding to delete the group itself.
$ slcli vs placementgroup delete testGroup --purge
You are about to delete the following guests!
issues10691547768562.test.com, issues10691547768572.test.com, issues10691547768552.test.com, issues10691548718280.test.com
This action will cancel all guests! Continue? [y/N]: y
Deleting issues10691547768562.test.com...
Deleting issues10691547768572.test.com...
Deleting issues10691547768552.test.com...
Deleting issues10691548718280.test.com...
vs placementgroup list¶
This command will list all placement groups on your account.
$ slcli vs placementgroup list
:..........................................................................................:
: Placement Groups :
:.......:...................:................:........:........:...........................:
: Id : Name : Backend Router : Rule : Guests : Created :
:.......:...................:................:........:........:...........................:
: 31741 : fotest : bcr01a.tor01 : SPREAD : 1 : 2018-11-22T14:36:10-06:00 :
: 64535 : testGroup : bcr01a.mex01 : SPREAD : 3 : 2019-01-17T14:36:42-06:00 :
:.......:...................:................:........:........:...........................:
vs placementgroup detail¶
This command will provide some detailed information about a specific placement group
$ slcli vs placementgroup detail testGroup
:.......:............:................:........:...........................:
: Id : Name : Backend Router : Rule : Created :
:.......:............:................:........:...........................:
: 64535 : testGroup : bcr01a.mex01 : SPREAD : 2019-01-17T14:36:42-06:00 :
:.......:............:................:........:...........................:
:..........:........................:...............:..............:.....:........:...........................:.............:
: Id : FQDN : Primary IP : Backend IP : CPU : Memory : Provisioned : Transaction :
:..........:........................:...............:..............:.....:........:...........................:.............:
: 69134895 : testGroup62.test.com : 169.57.70.166 : 10.131.11.32 : 1 : 1024 : 2019-01-17T17:44:50-06:00 : - :
: 69134901 : testGroup72.test.com : 169.57.70.184 : 10.131.11.59 : 1 : 1024 : 2019-01-17T17:44:53-06:00 : - :
: 69134887 : testGroup52.test.com : 169.57.70.187 : 10.131.11.25 : 1 : 1024 : 2019-01-17T17:44:43-06:00 : - :
:..........:........................:...............:..............:.....:........:...........................:.............:
Configuration Setup¶
To update the configuration, you can use slcli setup.
$ slcli setup
Username []: username
API Key or Password []:
Endpoint (public|private|custom): public
:..............:..................................................................:
: Name : Value :
:..............:..................................................................:
: Username : username :
: API Key : oyVmeipYQCNrjVS4rF9bHWV7D75S6pa1fghFl384v7mwRCbHTfuJ8qRORIqoVnha :
: Endpoint URL : https://api.softlayer.com/xmlrpc/v3.1/ :
:..............:..................................................................:
Are you sure you want to write settings to "/home/me/.softlayer"? [y/N]: y
To check the configuration, you can use slcli config show.
$ slcli config show
:..............:..................................................................:
: Name : Value :
:..............:..................................................................:
: Username : username :
: API Key : oyVmeipYQCNrjVS4rF9bHWV7D75S6pa1fghFl384v7mwRCbHTfuJ8qRORIqoVnha :
: Endpoint URL : https://api.softlayer.com/xmlrpc/v3.1/ :
:..............:..................................................................:
If you are using an account created from the https://cloud.ibm.com portal, your username will be literally apikey, and use the key provided. How to create an IBM apikey
To see more about the config file format, see Configuration File.
Usage Examples¶
To discover the available commands, simply type slcli.
$ slcli
Usage: slcli [OPTIONS] COMMAND [ARGS]...
SoftLayer Command-line Client
Options:
--format [table|raw|json|jsonraw] Output format [default: raw]
-C, --config PATH Config file location [default: ~\.softlayer]
-v, --verbose Sets the debug noise level, specify multiple times for more verbosity.
--proxy TEXT HTTP[S] proxy to be use to make API calls
-y, --really / --not-really Confirm all prompt actions
--demo / --no-demo Use demo data instead of actually making API calls
--version Show the version and exit.
-h, --help Show this message and exit.
Commands:
block Block Storage.
call-api Call arbitrary API endpoints.
cdn Content Delivery Network.
config CLI configuration.
dedicatedhost Dedicated Host.
dns Domain Name System.
event-log Event Logs.
file File Storage.
firewall Firewalls.
globalip Global IP addresses.
hardware Hardware servers.
image Compute images.
ipsec IPSEC VPN
loadbal Load balancers.
metadata Find details about this machine.
nas Network Attached Storage.
object-storage Object Storage.
order View and order from the catalog.
report Reports.
rwhois Referral Whois.
securitygroup Network security groups.
setup Edit configuration.
shell Enters a shell for slcli.
sshkey SSH Keys.
ssl SSL Certificates.
subnet Network subnets.
summary Account summary.
ticket Support tickets.
user Manage Users.
virtual Virtual Servers.
vlan Network VLANs.
To use most commands your SoftLayer username and api_key need to be
configured. The easiest way to do that is to use: 'slcli setup'
As you can see, there are a number of commands/sections. To look at the list of subcommands for virtual servers type slcli vs. For example:
$ slcli vs
Usage: slcli vs [OPTIONS] COMMAND [ARGS]...
Virtual Servers.
Options:
--help Show this message and exit.
Commands:
cancel Cancel virtual servers.
capture Capture SoftLayer image.
create Order/create virtual servers.
create-options Virtual server order options.
credentials List virtual server credentials.
detail Get details for a virtual server.
dns-sync Sync DNS records.
edit Edit a virtual server's details.
list List virtual servers.
network Manage network settings.
pause Pauses an active virtual server.
power_off Power off an active virtual server.
power_on Power on a virtual server.
ready Check if a virtual server is ready.
reboot Reboot an active virtual server.
reload Reload operating system on a virtual server.
rescue Reboot into a rescue image.
resume Resumes a paused virtual server.
upgrade Upgrade a virtual server.
Finally, we can make an actual call. Let’s list out the virtual servers on our account by using slcli vs list.
$ slcli vs list
:.........:............:....................:.......:........:................:..............:....................:
: id : datacenter : host : cores : memory : primary_ip : backend_ip : active_transaction :
:.........:............:....................:.......:........:................:..............:....................:
: 1234567 : sjc01 : test.example.com : 4 : 4G : 12.34.56 : 65.43.21 : - :
:.........:............:....................:.......:........:................:..............:....................:
Most commands will take in additional options/arguments. To see all available actions, use –help.
$ slcli vs list --help
Usage: slcli vs list [OPTIONS]
List virtual servers.
Options:
--sortby [guid|hostname|primary_ip|backend_ip|datacenter]
Column to sort by
-c, --cpu INTEGER Number of CPU cores
-D, --domain TEXT Domain portion of the FQDN
-d, --datacenter TEXT Datacenter shortname
-H, --hostname TEXT Host portion of the FQDN
-m, --memory INTEGER Memory in mebibytes
-n, --network TEXT Network port speed in Mbps
--hourly Show only hourly instances
--monthly Show only monthly instances
--tags TEXT Show instances that have one of these comma-
separated tags
--help Show this message and exit.
Debugging¶
To see exactly what API call is being made by the SLCLI, you can use the verbose option.
A single -v will show a simple version of the API call, along with some statistics
slcli -v vs detail 74397127
Calling: SoftLayer_Virtual_Guest::getObject(id=74397127, mask='id,globalIdentifier,fullyQualifiedDomainName,hostname,domain', filter='None', args=(), limit=None, offset=None))
Calling: SoftLayer_Virtual_Guest::getReverseDomainRecords(id=77460683, mask='', filter='None', args=(), limit=None, offset=None))
:..................:..............................................................:
: name : value :
:..................:..............................................................:
: execution_time : 2.020334s :
: api_calls : SoftLayer_Virtual_Guest::getObject (1.515583s) :
: : SoftLayer_Virtual_Guest::getReverseDomainRecords (0.494480s) :
: version : softlayer-python/v5.7.2 :
: python_version : 3.7.3 (default, Mar 27 2019, 09:23:15) :
: : [Clang 10.0.1 (clang-1001.0.46.3)] :
: library_location : /Users/chris/Code/py3/lib/python3.7/site-packages/SoftLayer :
:..................:..............................................................:
Using -vv will print out some API call details in the summary as well.
slcli -vv account summary
Calling: SoftLayer_Account::getObject(id=None, mask='mask[ nextInvoiceTotalAmount, pendingInvoice[invoiceTotalAmount], blockDeviceTemplateGroupCount, dedicatedHostCount, domainCount, hardwareCount, networkStorageCount, openTicketCount, networkVlanCount, subnetCount, userCount, virtualGuestCount ]', filter='None', args=(), limit=None, offset=None))
:..................:.............................................................:
: name : value :
:..................:.............................................................:
: execution_time : 0.921271s :
: api_calls : SoftLayer_Account::getObject (0.911208s) :
: version : softlayer-python/v5.7.2 :
: python_version : 3.7.3 (default, Mar 27 2019, 09:23:15) :
: : [Clang 10.0.1 (clang-1001.0.46.3)] :
: library_location : /Users/chris/Code/py3/lib/python3.7/site-packages/SoftLayer :
:..................:.............................................................:
:........:.................................................:
: : SoftLayer_Account::getObject :
:........:.................................................:
: id : None :
: mask : mask[ :
: : nextInvoiceTotalAmount, :
: : pendingInvoice[invoiceTotalAmount], :
: : blockDeviceTemplateGroupCount, :
: : dedicatedHostCount, :
: : domainCount, :
: : hardwareCount, :
: : networkStorageCount, :
: : openTicketCount, :
: : networkVlanCount, :
: : subnetCount, :
: : userCount, :
: : virtualGuestCount :
: : ] :
: filter : None :
: limit : None :
: offset : None :
:........:.................................................:
Using -vvv will print out the exact API that can be used without the softlayer-python framework, A simple python code snippet for XML-RPC, a curl call for REST API calls. This is dependant on the endpoint you are using in the config file.
slcli -vvv account summary
curl -u $SL_USER:$SL_APIKEY -X GET -H "Accept: */*" -H "Accept-Encoding: gzip, deflate, compress" 'https://api.softlayer.com/rest/v3.1/SoftLayer_Account/getObject.json?objectMask=mask%5B%0A++++++++++++nextInvoiceTotalAmount%2C%0A++++++++++++pendingInvoice%5BinvoiceTotalAmount%5D%2C%0A++++++++++++blockDeviceTemplateGroupCount%2C%0A++++++++++++dedicatedHostCount%2C%0A++++++++++++domainCount%2C%0A++++++++++++hardwareCount%2C%0A++++++++++++networkStorageCount%2C%0A++++++++++++openTicketCount%2C%0A++++++++++++networkVlanCount%2C%0A++++++++++++subnetCount%2C%0A++++++++++++userCount%2C%0A++++++++++++virtualGuestCount%0A++++++++++++%5D'
Contributing¶
Contribution Guide¶
This page explains how to get started contributing code to the SoftLayer API Python Bindings project.
Code Organization¶
- docs - Where The source to this documentation lives.
- SoftLayer - All the source lives under here.
- API - Primary API client.
- CLI - Code for the command-line interface.
- managers - API Managers. Abstractions to help use the API.
Setting Up A Dev Environment¶
Before working with the SoftLayer Python API client source, we strongly recommend that you know how to use Python’s virtual environment, virtualenv. Virtualenv allows you to create isolated Python environments that are individually tailored to particular development projects. Each environment can have its own set of libraries and even its own Python interpreter. This keeps them fully isolated, reducing the possibility of library conflicts between different projects.
After you have virtualenv, you should set up a virtual environment and activate it whenever you are working on softlayer-python. The commands needed to setup an environment and activate it might look something like this:
virtualenv --no-site-packages softlayer_env
source softlayer_env/bin/activate
Please refer to the virtualenv documentation for more information about creating, and working with virtual environments.
Once you have an appropriate environment, you will then download the SoftLayer API Python Bindings source code by following the installation instructions. Change into softlayer-python source directory and run the following to install the pre-requisites that you’ll need in order to run the test suites:
pip install -r tools/test-requirements.txt
Testing¶
The project has a mix of functional and unit tests. Before submitting changes to be integrated into the project, you should validate your code using tox. Simply issue the tox command from the root of the source tree:
tox
In addition to testing different versions of Python, tox checks for common mistakes in the code using Flake8 and pylint. You should eliminate the linting errors that are reported before submitting your code. You can run only the linting checks by using this command:
tox -eanalysis
The project’s configuration instructs tox to test against many different versions of Python. A tox test will use as many of those as it can find on your local computer. Rather than installing all those versions, we recommend that you point the Travis continuous integration tool at your GitHub fork. Travis will run the test against the full suite of Python versions every time you push new code.
Using tox to run tests in multiple environments can be very time consuming. If you wish to quickly run the tests in your own environment, you may do so using py.test. The command to do that is:
py.test tests
Fixtures¶
Testing of this project relies quite heavily on fixtures to simulate API calls. When running the unit tests, we use the FixtureTransport class, which instead of making actual API calls, loads data from /fixtures/SoftLayer_Service_Name.py and tries to find a variable that matches the method you are calling.
When adding new Fixtures you should try to sanitize the data of any account identifiying results, such as account ids, username, and that sort of thing. It is ok to leave the id in place for things like datacenter ids, price ids.
To Overwrite a fixture, you can use a mock object to do so. Like either of these two methods:
# From tests/CLI/modules/vs_capacity_tests.py
from SoftLayer.fixtures import SoftLayer_Product_Package
def test_create_test(self):
item_mock = self.set_mock('SoftLayer_Product_Package', 'getItems')
item_mock.return_value = SoftLayer_Product_Package.getItems_RESERVED_CAPACITY
def test_detail_pending(self):
capacity_mock = self.set_mock('SoftLayer_Virtual_ReservedCapacityGroup', 'getObject')
get_object = {
'name': 'test-capacity',
'instances': []
}
capacity_mock.return_value = get_object
Documentation¶
The project is documented in reStructuredText and built using Sphinx. If you have fabric installed, you simply need to run the following to build the docs:
fab make_html
The documentation will be built in docs/_build/html. If you don’t have fabric, use the following commands.
cd docs
make html
sphinx-build -b html ./ ./html
The primary docs are built at Read the Docs.
Style¶
This project tries to follow PEP 8 and most of the style suggestions that pyflakes recommends. Run Flake8 regularly. Flake8, with project-specific exceptions, can be run by using tox:
tox -e analysis
Autopep8 can fix a lot of the simple flake8 errors about whitespace and indention.
autopep8 -r -a -v -i --max-line-length 119
Contributing¶
Contributing to the Python API bindings follows the fork-pull-request model on GitHub. The project uses GitHub’s issue tracker and pull requests to manage source control, bug fixes and new feature development regarding the API bindings and the CLI. In order to contribute, we require that you sign a contributer agreemenet:
Developer Resources¶
Command-Line Interface Developer Guide¶
The SoftLayer CLI can be used to manage many different SoftLayer services directly from the command line.
The command line parsing is currently based on click, which is a command parsing library along with some additions to dynamically load modules from a routes-like file and from entry points.
First Example¶
For the first example, we can create slcli table-example by creating the following file at SoftLayer/CLI/table_example.py:
"""A formatting table example."""
from SoftLayer.CLI import environment
from SoftLayer.CLI import formatting
import click
@click.command()
@environment.pass_env
def cli(env):
"""This returns an table that highlights how tables are output"""
# create a table with two columns: col1, col2
table = formatting.Table(['col1', 'col2'])
# align the data facing each other
# valid values are r, c, l for right, center, left
# note, these are suggestions based on the format chosen by the user
table.align['col1'] = 'r'
table.align['col2'] = 'l'
# add rows
table.add_row(['test', 'test'])
table.add_row(['test2', 'test2'])
env.fout(table)
Then we need to register it so that slcli table-example will know to route to this new module. We do that by adding ALL_ROUTES in SoftLayer/CLI/routes.py to include the following:
...
('table-example', 'SoftLayer.CLI.table_example:cli'),
...
Which gives us
$ slcli table-example
:.......:.......:
: col1 : col2 :
:.......:.......:
: test : test :
: test2 : test2 :
:.......:.......:
$ slcli --format=raw table-example
test test
test2 test2
Formatting of the data represented in the table is actually controlled upstream from the CLIRunnable’s making supporting more data formats in the future easier.
Arguments¶
A command usually isn’t very useful without context or arguments of some kind. With click, you have a large array of argument and option types at your disposal. Additionally, with the SoftLayer CLI, we have global options and context which is stored in SoftLayer.CLI.environment.Environment and is attainable through a decorator located at SoftLayer.CLI.environment.pass_env. An example of options and the environment is shown below. It also shows how output should be done using env.out instead of printing. This is used for testing and to have a consistent way to print things onto the screen.
from SoftLayer.CLI import environment
import click
@click.command()
@click.option("--number",
required=True,
type=click.INT,
help="print different output")
@click.option("--choice",
type=click.Choice(['this', 'that']),
help="print different output")
@click.option("--test", help="print different output")
@environment.pass_env
def cli(env, number, choice, test):
"""Argument parsing example"""
if test:
env.out("Just testing, move along...")
else:
env.out("This is fo'realz!")
if choice == 'this':
env.out("Selected this")
elif choice == 'that':
env.out("Selected that")
env.out("This is a number: %d" % number)
Refer to the click library documentation for more options.
Accessing the API¶
A SoftLayer client is stood up for every command and is available through SoftLayer.CLI.environment.Environment.client. The example below shows how to make a simple API call to the SoftLayer_Account::getObject.
from SoftLayer.CLI import environment
import click
@click.command()
@environment.pass_env
def cli(env):
"""Using the SoftLayer API client"""
account = env.client['Account'].getObject()
return account['companyName']
Aborting execution¶
When a confirmation fails, you probably want to stop execution and give a non-zero exit code. To do that, raise a SoftLayer.CLI.exceptions.CLIAbort exception with the message for the user as the first parameter. This will prevent any further execution and properly return the right error code.
raise CLIAbort("Aborting. Failed confirmation")