Skip to main content

PART 1: How to use SoftLayer Python library.

Install the SoftLayer's Python library. 

pip install softlayer

or clone the source code from the github and install from source code.

git clone https://github.com/softlayer/softlayer-python.git
python setup.py install

Once we have installed the SoftLayer Python library we are ready to use it as shown in the following example.

You need your username and api key to run the below example.
One can get both user name and api key at the following link once you login successfully.

https://control.softlayer.com/account/user/profile

Accounts username and API key








E.g. showing how to use SoftLayer Python library.

import SoftLayer
from SoftLayer.managers.image import ImageManager

client = SoftLayer.Client(username='', api_key='')
image_manager = ImageManager(client)

mask = "mask[id,name,note]"
imageTemplates = image_manager.list_private_images(mask='id,name,note')
print("ID - Name - Note")
for template in imageTemplates:
    try:
        print("%s - %s - %s" % (template['id'], template['name'], template['note']))
    except KeyError:
        print("%s - %s - %s" % (template['id'], template['name'], 'None'))


In the above example we are creating a SoftLayer client by giving the username and API key. Mask is used to get the exact information we want instead of getting a whole lot of information. In this example we are just interested in getting the id, name and note of any image template users have in their account.

Comments

Popular posts from this blog

Enable stats GUI on haproxy.

Add bottom snippet to the haproxy.conf below the defaults section. listen  stats         bind 19.41.259.10:1234         mode            http         log             global         maxconn 10         clitimeout      100s         srvtimeout      100s         contimeout      100s         timeout queue   100s         stats enable         stats hide-version         stats refresh 30s         stats show-node         stats auth admin:password         stats uri  /haproxy?stats Make sure you are updating the IP address on the bind to your VIP and if you want, you can change th...

atoi implementation in C

Algo for you own implementation of atoi :) :) int val = 0;    for each char in the string       val = val *10 + char-48 lets write some code for it :) int myatoi(char *convetIt) {      int val = 0;      while(*convetIt)      {           val = (val * 10) + *convetIt - 48;           convetIt++;      } } So how it works? lets see how it works take an example of string "123" formula : val = (val * 10 ) + *convetIt - 48                 val = (0 * 10 ) + '1' - 48      =>      0*10  + 49 - 48 =  0  + 1 = 1                 val = (1 * 10)  + '2' - 48      =>     1*10  + 50 - 48 = 10...