SoftLayer API Python Client Documentation

Transcription

SoftLayer API Python ClientDocumentationRelease latestSoftLayer Technologies, Inc.Nov 21, 2019

Contents1Installation1.1 What’s Included1.2 Using Pip . . . .1.3 Debian/Ubuntu .1.4 From Source . .2Configuration File3API Documentation3.1 Getting Started . . . . . . . . . . . .3.2 Managers . . . . . . . . . . . . . . .3.2.1SoftLayer.account . . . . . .3.2.2SoftLayer.autoscale . . . . .3.2.3SoftLayer.block . . . . . . .3.2.4SoftLayer.cdn . . . . . . . .3.2.5SoftLayer.dedicatedhost . .3.2.6SoftLayer.dns . . . . . . . .3.2.7SoftLayer.event log . . . . .3.2.8SoftLayer.file . . . . . . . .3.2.9SoftLayer.firewall . . . . . .3.2.10 SoftLayer.hardware . . . . .3.2.11 SoftLayer.image . . . . . . .3.2.12 SoftLayer.ipsec . . . . . . .3.2.13 SoftLayer.load balancer . .3.2.14 SoftLayer.metadata . . . . .3.2.15 SoftLayer.network . . . . .3.2.16 SoftLayer.ordering . . . . .3.2.17 SoftLayer.sshkey . . . . . .3.2.18 SoftLayer.ssl . . . . . . . .3.2.19 SoftLayer.ticket . . . . . . .3.2.20 SoftLayer.vs . . . . . . . . .3.2.21 SoftLayer.vs capacity . . .3.2.22 SoftLayer.vs placement . .3.3 Making API Calls . . . . . . . . . .3.4 Debugging . . . . . . . . . . . . . .3.5 API Reference . . . . . . . . . . . .3.5.1SoftLayer Python API 45557656768707070i

4iiCommand-line Interface4.1 Account Commands . . . . . .4.1.1account summary . . .4.1.2account events . . . . .4.1.3account event-detail . .4.1.4account invoices . . . .4.1.5account invoice-detail .4.2 Autoscale Commands . . . . .4.2.1autoscale list . . . . .4.2.2autoscale detail . . . .4.2.3autoscale scale . . . .4.2.4autoscale logs . . . . .4.2.5autoscale tag . . . . .4.2.6autoscale edit . . . . .4.3 Call API . . . . . . . . . . . .4.3.1call-api . . . . . . . .4.4 Interacting with CDN . . . . .4.4.1cdn detail . . . . . . .4.4.2cdn list . . . . . . . .4.4.3cdn origin-add . . . . .4.4.4cdn origin-list . . . . .4.4.5cdn origin-remove . . .4.4.6cdn purge . . . . . . .4.5 Config . . . . . . . . . . . . .4.5.1config setup . . . . . .4.5.2config show . . . . . .4.6 Event-Log Commands . . . . .4.6.1event-log get . . . . .4.6.2event-log types . . . .4.7 Interacting with Hardware . . .4.7.1hw bandwidth . . . . .4.7.2hw cancel-reasons . . .4.7.3hw cancel . . . . . . .4.7.4hw create-options . . .4.7.5hw create . . . . . . .4.7.6hw credentials . . . . .4.7.7hw detail . . . . . . .4.7.8hw edit . . . . . . . .4.7.9hw list . . . . . . . . .4.7.10 hw power-cycle . . . .4.7.11 hw power-off . . . . .4.7.12 hw power-on . . . . .4.7.13 hw reboot . . . . . . .4.7.14 hw reload . . . . . . .4.7.15 hw rescue . . . . . . .4.7.16 hw reflash-firmware . .4.7.17 hw update-firmware . .4.7.18 hw toggle-ipmi . . . .4.7.19 hw ready . . . . . . .4.8 Interacting with IPSEC Tunnels4.8.1ipsec list . . . . . . . .4.8.2ipsec detail . . . . . .4.8.3ipsec update . . . . . .4.8.4ipsec configure . . . 090909192

4.94.104.114.124.134.144.154.164.8.5ipsec subnet-add . . . . . .4.8.6ipsec subnet-remove . . . .4.8.7ipsec translation-add . . . .4.8.8ipsec translation-remove . .4.8.9ipsec translation-update . . .LoadBalancers . . . . . . . . . . . .4.9.1LBaaS Commands . . . . .4.9.2NetScaler Commands . . . .Ordering . . . . . . . . . . . . . . .4.10.1 order package-list . . . . . .4.10.2 order package-locations . . .4.10.3 order category-list . . . . . .4.10.4 order item-list . . . . . . . .4.10.5 order preset-list . . . . . . .4.10.6 order place . . . . . . . . .4.10.7 order place preset . . . .4.10.8 order place Virtual Server Quotes . . . . . . . . . . . . . . . .4.11.1 order quote . . . . . . . . .4.11.2 order quote-list . . . . . . .4.11.3 order quote-detail . . . . . .4.11.4 order place-quote . . . . . .Reports . . . . . . . . . . . . . . . .4.12.1 summary . . . . . . . . . .4.12.2 report bandwidth . . . . . .Users . . . . . . . . . . . . . . . . .4.13.1 user create . . . . . . . . . .4.13.2 user list . . . . . . . . . . .4.13.3 user detail user . . . . . .4.13.4 user edit-permissions . . . .4.13.5 user edit-details . . . . . . .Working with Virtual Servers . . . .4.14.1 vs bandwidth . . . . . . . .4.14.2 vs cancel . . . . . . . . . .4.14.3 vs capture . . . . . . . . . .4.14.4 vs create . . . . . . . . . . .4.14.5 vs create-options . . . . . .4.14.6 vs dns-sync . . . . . . . . .4.14.7 vs edit . . . . . . . . . . . .4.14.8 vs list . . . . . . . . . . . .4.14.9 vs pause . . . . . . . . . . .4.14.10 vs power-on . . . . . . . . .4.14.11 vs power-off . . . . . . . . .4.14.12 vs resume . . . . . . . . . .4.14.13 vs rescue . . . . . . . . . .4.14.14 vs reboot . . . . . . . . . .4.14.15 vs ready . . . . . . . . . . .4.14.16 vs upgrade . . . . . . . . . .4.14.17 vs usage . . . . . . . . . . .4.14.18 Reserved Capacity . . . . .4.14.19 Placement Groups . . . . . .Configuration Setup . . . . . . . . .Usage Examples . . . . . . . . . . 127iii

5Debugging6Contributing6.1 Contribution Guide . . . . . . . . . . . . .6.1.1Code Organization . . . . . . . .6.1.2Setting Up A Dev Environment . .6.1.3Testing . . . . . . . . . . . . . .6.1.4Documentation . . . . . . . . . .6.1.5Style . . . . . . . . . . . . . . . .6.1.6Contributing . . . . . . . . . . . .6.1.7Developer Resources . . . . . . .6.2 Command-Line Interface Developer Guide6.2.1First Example . . . . . . . . . . .6.2.2Arguments . . . . . . . . . . . .6.2.3Accessing the API . . . . . . . .6.2.4Aborting execution . . . . . . . ternal Links139Python Module Index141Index143iv

SoftLayer API Python Client Documentation, Release latestAPI Docs GitHub Issues Pull Requests PyPI This is the documentation to SoftLayer’s Python API Bindings. These bindings use SoftLayer’s XML-RPC interfacein order to manage SoftLayer services.Contents1

SoftLayer API Python Client Documentation, Release latest2Contents

CHAPTER1Installation1.1 What’s IncludedWhen 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’.1.2 Using PipInstall via pip: pip install softlayer1.3 Debian/UbuntuFor Debian “jessie” (currently testing) and Ubuntu 14.04, official system packages are available. These are typicallya couple versions behind so it is recommended to install from pypi if problems are encountered. sudo apt-get install python-softlayer1.4 From SourceThe project is developed on GitHub, at all from source via pip (requires git):3

SoftLayer API Python Client Documentation, Release latest pip install git git://github.com/softlayer/softlayer-python.gitYou can clone the public repository: git clone git@github.com:softlayer/softlayer-python.gitOr, Download the tarball: curl -OL all/masterOr, download the zipball: curl -OL all/masterOnce you have a copy of the source you can install it with one of the following commands: python setup.py installOr: pip install .For more information about working with the source, or contributing to the project, please see the Contribution Guide.4Chapter 1. Installation

CHAPTER2Configuration FileThe 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 areusername and api key. You can optionally supply the endpoint url as well. This file is created automatically by theslcli setup command detailed here: Configuration Setup.Config Example[softlayer]username usernameapi key uJ8qRORIqoVnhaendpoint url https://api.softlayer.com/xmlrpc/v3/timeout 40Cloud.ibm.com Config Example[softlayer]username apikeyapi key 123cNyhzg45Ab6789ADyzwR 2LAagNVbySgY73tAQOz1endpoint url https://api.softlayer.com/rest/v3.1/timeout 405

SoftLayer API Python Client Documentation, Release latest6Chapter 2. Configuration File

CHAPTER3API DocumentationThis is the primary API client to make API calls. It deals with constructing and executing XML-RPC calls against theSoftLayer API. Below are some links that will help to use the SoftLayer API. SoftLayer API Documentation Source on GitHub import SoftLayer client SoftLayer.create client from env(username "username", api key "api key") resp client.call('Account', 'getObject') resp['companyName']'Your Company'3.1 Getting StartedYou can pass in your username and api key when creating a SoftLayer client instance. However, you can also setthese in the environmental variables ‘SL USERNAME’ and ‘SL API KEY’.Creating a client instance by passing in the username/api key:import SoftLayerclient 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()7

SoftLayer API Python Client Documentation, Release latestBelow is an example of creating a client instance with more options. This will create a client with the private APIendpoint (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)3.2 ManagersFor day-to-day operation, most users will find the managers to be the most convenient means for interacting withthe API. Managers abstract a lot of the complexities of using the API into classes that provide a simpler interface tovarious services. These are higher-level interfaces to the SoftLayer API.from SoftLayer import VSManager, Clientclient Client(.)vs VSManager(client)vs.list instances()[.]Available managers:3.2.1 SoftLayer.accountAccount managerlicense MIT, see License for more details.class ommon functions for getting information from the Account serviceParameters client (SoftLayer.API.BaseClient) – the client instanceack event(event id)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 ackReturns True on success, Exception otherwise.get billing items(identifier)Gets all topLevelBillingItems from a specific invoiceParameters identifier (int) – Invoice IdReturns Billing Invoice Itemget event(event id)Gets details about a maintenance eventParameters event id (int) – Notification Occurrence Event IDReturns Notification Occurrence Eventget invoices(limit 50, closed False, get all False)Gets an accounts invoices.Parameters limit (int) – Number of invoices to get back in a single call.8Chapter 3. API Documentation

SoftLayer API Python Client Documentation, Release latest 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 Invoiceget summary()Gets some basic account informationReturns Account objectget upcoming events()Retreives a list of Notification Occurrence Events that have not ended yetReturns SoftLayer Notification Occurrence Eventresolve ids(identifier)Takes a string and tries to resolve to a list of matching ids.What exactly ‘identifier’ can be depends on the resolversParameters identifier (string) – identifying stringReturns list3.2.2 SoftLayer.autoscaleAutoscale managerlicense MIT, see LICENSE for more details.class nt)Manager for interacting with Autoscale instances.details(identifier, mask None)Calls SoftLayer Scale Group::getObject()Parameters identifier – SoftLayer Scale Group id mask – optional SoftLayer Scale Group objectMaskedit(identifier, template)Calls SoftLayer Scale Group::editObject()Parameters identifier – SoftLayer Scale Group id template – SoftLayer Scale Groupget logs(identifier, mask None, object filter None)Calls SoftLayer Scale Group::getLogs()Parameters identifier – SoftLayer Scale Group Id mask – optional SoftLayer Scale Group Log objectMask object filter – optional SoftLayer Scale Group Log objectFilterget policy(identifier, mask None)Calls SoftLayer Scale Policy::getObject()Parameters3.2. Managers9

SoftLayer API Python Client Documentation, Release latest identifier – SoftLayer Scale Policy id mask – optional SoftLayer Scale Policy objectMaskget virtual guests(identifier, mask None)Calls SoftLayer Scale Group::getVirtualGuestMembers()Parameters identifier – SoftLayer Scale Group Id mask – optional SoftLayer Scale Member objectMasklist(mask None)Calls SoftLayer Account::getScaleGroups()Parameters mask – optional SoftLayer Scale Group objectMaskscale(identifier, amount)Calls SoftLayer Scale Group::scale()Parameters identifier – SoftLayer Scale Group Id amount – positive or negative number to scale the group byscale to(identifier, amount)Calls SoftLayer Scale Group::scaleTo()Parameters identifier – SoftLayer Scale Group Id amount – number to scale the group to.3.2.3 SoftLayer.blockBlock Storage Managerlicense MIT, see LICENSE for more details.class t)Manages SoftLayer Block Storage volumes.See product information here: http://www.softlayer.com/block-storageParameters client (SoftLayer.API.BaseClient) – the client instanceauthorize host to volume(volume id,hardware ids None,ip address ids None, **kwargs)Authorizes hosts to Block Storage Volumesvirtual guest ids None,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 idsReturns Returns an array of SoftLayer Network Storage Allowed Host objects which nowhave access to the given Block volume10Chapter 3. API Documentation

SoftLayer API Python Client Documentation, Release latestcancel block volume(v

CHAPTER 1 Installation 1.1What’s Included When you install softlayer-python you you will get the following: a python package called ‘SoftLa