greyhoundforty
11/6/2017 - 8:14 PM

LBaaS API result testing

LBaaS API result testing

Get the members for a LBaaS instance

tycho ◎ 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 | jq -r '.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
}

Take the provided UUID and get the VSI details ... or so you would think

tycho ◎ curl -s "https://$SOFTLAYER_USERNAME:$SOFTLAYER_API_KEY@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/02d9d843-0778-45df-ad2d-a0c0309911b8/getObject" | pmj
{
    "code": "SoftLayer_Exception_ObjectNotFound",
    "error": "Unable to find object with global identifier of '02d9d843-0778-45df-ad2d-a0c0309911b8'."
}

Instead use the provided IP to pull VSI details

filter='\{"virtualGuests":\{"primaryBackendIpAddress":\{"operation":"10.186.21.183"\}\}\}'

tycho ◎ curl -s "https://$SOFTLAYER_USERNAME:$SOFTLAYER_API_KEY@api.softlayer.com/rest/v3/SoftLayer_Account/getVirtualGuests?objectFilter=$filter" | pmj
[
    {
        "accountId": 78003,
        "createDate": "2017-11-03T09:58:54-07:00",
        "dedicatedAccountHostOnlyFlag": false,
        "domain": "cde.services",
        "fullyQualifiedDomainName": "node2.cde.services",
        "globalIdentifier": "385f0804-87f0-45f6-b7c1-596a36200d2d",
        "hostname": "node2",
        "id": 43309513,
        "lastPowerStateId": null,
        "lastVerifiedDate": null,
        "maxCpu": 1,
        "maxCpuUnits": "CORE",
        "maxMemory": 2048,
        "metricPollDate": null,
        "modifyDate": "2017-11-03T10:02:16-07:00",
        "primaryBackendIpAddress": "10.186.21.183",
        "primaryIpAddress": "169.48.66.131",
        "provisionDate": "2017-11-03T10:02:16-07:00",
        "startCpus": 1,
        "status": {
            "keyName": "ACTIVE",
            "name": "Active"
        },
        "statusId": 1001,
        "typeId": 1,
        "uuid": "228238b2-78ff-fd9e-9c6d-dc78d7648c6c"
    }
]

Notice how even the UUID is different from what is returned from the LBaaS members call.