greyhoundforty
11/9/2017 - 5:15 PM

Trying to list members of an LBaaS Instance

Trying to list members of an LBaaS Instance

import os
import SoftLayer
from pprint import pprint as pp
import logging

config_file = os.path.expanduser('~/.slrest')
client = SoftLayer.create_client_from_env(config_file=config_file)
def main():
    
    logging.basicConfig(filename='slrestpython.log',level=logging.DEBUG)

    lbfilter = { 
        'name': {'operation': 'lbaasterraform'}
    }

    lbmask = "mask[uuid]"
    getlbuuid = client['SoftLayer_Network_LBaaS_LoadBalancer'].getAllObjects(filter=lbfilter,mask=lbmask)
    lbuuid = getlbuuid[0]['uuid']

    membermask = "mask[members]"
    getmembers = client['SoftLayer_Network_LBaaS_LoadBalancer'].getLoadBalancer(id=lbuuid,mask=membermask)
    pp(getmembers)

if __name__ == '__main__':
    main()

Debug Log

(softlayer) tycho ~/Repos/slapi (master ✗ ◼) ◎ cat slrestpython.log
DEBUG:SoftLayer.transports:=== REQUEST ===
INFO:SoftLayer.transports:https://api.softlayer.com/rest/v3.1/SoftLayer_Network_LBaaS_LoadBalancer/getAllObjects.json
DEBUG:SoftLayer.transports:{'Content-Type': 'application/json', 'Accept-Encoding': 'gzip, deflate, compress', 'Accept': '*/*', 'User-Agent': 'softlayer-python/v5.2.15'}
DEBUG:SoftLayer.transports:None
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.softlayer.com
DEBUG:urllib3.connectionpool:https://api.softlayer.com:443 "GET /rest/v3.1/SoftLayer_Network_LBaaS_LoadBalancer/getAllObjects.json?objectMask=mask%5Buuid%5D&objectFilter=%7B%22name%22%3A+%7B%22operation%22%3A+%22lbaasterraform%22%7D%7D HTTP/1.1" 200 49
DEBUG:SoftLayer.transports:=== RESPONSE ===
DEBUG:SoftLayer.transports:{'Content-Length': '49', 'Vary': 'Accept-Encoding', 'Server': 'Apache', 'SoftLayer-Total-Items': '1', 'Connection': 'close', 'Date': 'Thu, 09 Nov 2017 17:11:50 GMT', 'X-Frame-Options': 'SAMEORIGIN', 'Content-Type': 'application/json'}
DEBUG:SoftLayer.transports:[{"uuid":"5c258b31-4394-4b46-a271-68de9a630d1e"}]
DEBUG:SoftLayer.transports:=== REQUEST ===
INFO:SoftLayer.transports:https://api.softlayer.com/rest/v3.1/SoftLayer_Network_LBaaS_LoadBalancer/5c258b31-4394-4b46-a271-68de9a630d1e/getLoadBalancer.json
DEBUG:SoftLayer.transports:{'Content-Type': 'application/json', 'Accept-Encoding': 'gzip, deflate, compress', 'Accept': '*/*', 'User-Agent': 'softlayer-python/v5.2.15'}
DEBUG:SoftLayer.transports:None
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.softlayer.com
DEBUG:urllib3.connectionpool:https://api.softlayer.com:443 "GET /rest/v3.1/SoftLayer_Network_LBaaS_LoadBalancer/5c258b31-4394-4b46-a271-68de9a630d1e/getLoadBalancer.json?objectMask=mask%5Bmembers%5D HTTP/1.1" 500 143
DEBUG:SoftLayer.transports:=== RESPONSE ===
DEBUG:SoftLayer.transports:{'Content-Length': '143', 'Vary': 'Accept-Encoding', 'Server': 'Apache', 'Connection': 'close', 'Date': 'Thu, 09 Nov 2017 17:11:51 GMT', 'X-Frame-Options': 'SAMEORIGIN', 'Content-Type': 'application/json'}
DEBUG:SoftLayer.transports:{"error":"Unable to find object with global identifier of '5c258b31-4394-4b46-a271-68de9a630d1e'.","code":"SoftLayer_Exception_ObjectNotFound"}

Curl request

(softlayer) tycho ~/Repos/slapi (master ✗ ◼) ◎ curl -s "https://$SOFTLAYER_USERNAME:$SOFTLAYER_API_KEY@api.softlayer.com/rest/v3/SoftLayer_Network_LBaaS_LoadBalancer/getLoadBalancer/5c258b31-4394-4b46-a271-68de9a630d1e?objectMask=members" | pmj  | pbcopy
{
    "accountId": 78003,
    "address": "lbaasterraform-78003-dal13.lb.bluemix.net",
    "createDate": "2017-11-03T10:11:35-07:00",
    "datacenter": {
        "id": 1854895,
        "longName": "Dallas 13",
        "name": "dal13",
        "statusId": 2
    },
    "description": "Testing Terraform and LBaaS",
    "isPublic": 1,
    "locationId": 1854895,
    "members": [
        {
            "address": "10.186.21.175",
            "createDate": "2017-11-03T10:11:36-07:00",
            "modifyDate": "2017-11-03T10:18:21-07:00",
            "provisioningStatus": "ACTIVE",
            "uuid": "f8dd3e5b-52db-4d81-b068-56cb163aeb2c",
            "weight": null
        },
        {
            "address": "10.186.21.183",
            "createDate": "2017-11-03T10:11:35-07:00",
            "modifyDate": "2017-11-03T10:18:21-07:00",
            "provisioningStatus": "ACTIVE",
            "uuid": "02d9d843-0778-45df-ad2d-a0c0309911b8",
            "weight": null
        }
    ],
    "modifyDate": "2017-11-07T17:06:00-06:00",
    "name": "lbaasterraform",
    "operatingStatus": "ONLINE",
    "provisioningStatus": "ACTIVE",
    "useSystemPublicIpPool": 1,
    "uuid": "5c258b31-4394-4b46-a271-68de9a630d1e"
}