0

softlayer api: How to order Public Secondary IP Addresses when I ordering?

I have order a virtual machine with 8 secondary ip address. by using api, how can I retrive the 8 secondary ip address.

  • I have order the virutal machine with 8 secondary ip. But I want to list out the 8 secondary ip by using api, instead of find them at portal. – user2849822 Jun 29 '17 at 04:23
  • To order virtual machines with 8 secondary IP you must use the placeOrder method there is not antother way for examples of that you can see the answer posted for Luffy, once your Virtual Guest has been ordered you will able to list the associated IP addres, for that you need to list the associated subnets to your VM and then list the IP addresses of the subnet for examples of that you see the answered posted for Fernando. – Nelson Raul Cabero Mendoza Jul 04 '17 at 19:16

2 Answers2

0

An Answer Given on SO itself contains your answer :

Order Virtual Guest with a Secondary Public Ip Address

Below is an example in REST to order a virtual guest with a secondary ip address and two first questions in the form.

Note: Don't forget change [username], [apikey], prices, and other ids with your own data

https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Product_Order/verifyOrder

Method: POST

Body JSON:
{
  "parameters":[
      {
          "complexType": "SoftLayer_Container_Product_Order_Virtual_Guest",
          "packageId": 46,
          "location": "AMSTERDAM",
          "quantity": 1,
          "prices":[
              {"id":14640},
              {"id":11644},
              {"id":9205},
              {"id":22272},
              {"id":52231},
              {"id":21},
              {"id":2202},
              {"id":13945},
              {"id":55},
              {"id":57},
              {"id":58},
              {"id":420},
              {"id":418},
              {"id":22}
          ],
          "virtualGuests":[
              {
                  "hostname": "test",
                  "domain": "example.com"                 
              }
          ],
          "itemCategoryQuestionAnswers":[
              {
                  "answer": "2",
                  "categoryId": 14,
                  "questionId": 14
              },
              {
                  "answer": "4",
                  "categoryId": 14,
                  "questionId": 15
              }
          ]
      }

  ]
}

Note : Please Refer to this Question for more detailed answer.

LuFFy
  • 8,799
  • 10
  • 41
  • 59
-1

You may retrieve the list required by using Network_Subnet::getIpAddresses method. Please try the following REST request:

https://$username:$apiKey@api.softlayer.com/rest/v3.1/SoftLayer_Network_Subnet/$subnetId/getIpAddresses?objectMask=mask[ipAddress, note, id, subnetId]

The code above is using objectMasks to display only what portal shows you, as in this case, your 8 or any number of Ip Addresses on a specific subnet, remember to change the first $username:$apikey values for valid credentials, and also the $subnetId identifier.

UPDATE: You may search the subnet Id of of a VSI by using:

SoftLayer_Virtual_Guest::getObject

https://$username:$apiKey@api.softlayer.com/rest/v3.1/SoftLayer_Virtual_Guest/$virtualGuestId/getObject?objectMask=mask[accountId,fullyQualifiedDomainName,primaryIpAddress,hostname,domain,frontendNetworkComponents[guestId,primaryIpAddress,subnets[id]]]

Remember to change the $virtualGuestId for your VSI id value.

For more information please see below:

Object Masks

Get Subnet Capacity

Fernando Iquiza
  • 531
  • 3
  • 7