Search code examples
rubyibm-cloud-infrastructure

How to get order username and provisionDate for all SoftLayer machines using Ruby?


Using Ruby I'm making a call like:

client = SoftLayer::Client.new(:username => user, :api_key => api_key, :timeout => 999999)
client['Account'].object_mask("mask[id, hostname, fullyQualifiedDomainName, provisionDate, datacenter[name], billingItem[recurringFee, associatedChildren[recurringFee], orderItem[description, order[userRecord[username], id]]], tagReferences[tagId, tag[name]], primaryIpAddress, primaryBackendIpAddress]").getHardware

But only some machines return a provisionDate and only some return orderItem information. How can I consistently get this information for each machine? What would cause one machine to return this data and another machine to not?

Example output:

{"fullyQualifiedDomainName"=>"<removed_by_me>",
 "hostname"=>"<removed_by_me>",
 "id"=>167719,
 "provisionDate"=>"",
 "primaryBackendIpAddress"=>"<removed_by_me>",
 "primaryIpAddress"=>"<removed_by_me>",
 "billingItem"=>
  {"recurringFee"=>"506.78",
   "associatedChildren"=>
    [<removed_by_me>]},
 "datacenter"=>{"name"=>"dal09"},
  "tagReferences"=>
  [{"tagId"=>139415, "tag"=>{"name"=>"<removed_by_me>"}},
   {"tagId"=>139417, "tag"=>{"name"=>"<removed_by_me>"}},
   {"tagId"=>140549, "tag"=>{"name"=>"<removed_by_me>"}}]}

To be clear, most machines return this data so I'm trying to understand why some do not.


Solution

  • Please see the following provisioning steps, below is a little flow to consider:

    1.  Order a Server
    
    Result: 
    * An orderId is assigned to the server
    * The createDate has a new value
    * activeTransaction value is =  Null
    * provisionDate value is = Null
    
    2.  The order is approved
    
    Result: 
    * activeTransaction value is <> Null
    * provisionDate value = Null
    
    3.  Server  is already provisioned
    
    Result:
    * activeTransaction value is = Null
    * provisionDate value has a New value
    * billingItem property has a new value
    

    To see if your machines have still ”activeTransaction”, please execute:

    https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Hardware_Server/[server_id]/getActiveTransaction
    Method: GET
    

    Now, after reviewing your example response, this server had some problems when completing the provisioning; for that reason this step was completed manually but the provisionDate was not set for any reason(please open a ticket if you want that the provisionDate can be set) . This is a special case. I can see that another server has a similar behavior. But the other servers that don’t have provisionDate, have still ”activeTransaction<>null” (it means that these server are not provisioned yet).

    EDIT:

    Other property can help you to know that your machine has been already provisioned although other kind of transaction is being executed, is “hardwareStatus”, it should have “ACTIVE” value.

    https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Account/getHardware?objectMask=mask[id, hostname, fullyQualifiedDomainName, provisionDate,hardwareStatus]
    Method: GET
    

    The response should be something like this:

    {
    "fullyQualifiedDomainName": "myhostname.softlayer.com"
    "hostname": " myhostname"
    "id": 1234567
    "provisionDate": "2015-06-29T00:21:39-05:00"
    "hardwareStatus": {
    "id": 5
    "status": "ACTIVE"
    }