REST: use SoftLayer_Hardware::createObject instead

2019-09-14 18:19发布

问题:

I want to order two bare metal servers I did it via REST api: SoftLayer_Product_Order/placeOrder with the following payload.

 "useHourlyPricing": true,
          "quantity": 2,
          "location": 448994,
          "packageId": 200,
          "presetId": 95,
          "prices": [
            {
              "id": 36365
            },
            {
              "id": 52795
            },
            {
              "id": 1800
            },
            {
              "id": 21
            },
            {
              "id": 906
            },
            {
              "id": 420
            },
            {
              "id": 418
            }
          ]

However, the servers created with separate vLANs. How to make the order of multiple servers share the same vLANs?

回答1:

Unfortunately, it's not possible to define VLANS for package 200 (Fast Servers), it means that you will not be able to do this through SoftLayer_Hardware_Server::createObject

You will be able to set VLANS (even subnets), if you try with a different package for Bare Metal Servers.

Just in case, here an example to order a Server defining the vlans and subnets (This is for VSI, but the same idea should be applied for Bare Metal Servers)

  • Create a SoftLayer virtual guest on a specific subnet

Note: SoftLayer_Hardware_Server::createObject method allows to order packages 50 and 200 (package 200 when you set preset configuration), in case that you wish to order package 50 (without preset config), you will be able to set vlans and subnets.


Updated


Retrieve Vlans - Subnets available based on Package and Location

The vlans should belong in the same datacenter in which you wish to place the order, to get vlan and subnets (public/private) information available for the package and location, you can try the following request:

https://$user:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Product_Order/getVlans

Method: Post

{
  "parameters": 
   [
       448994, 50
   ]
}

Replace: $user and $apiKey with you own information. Also 448994 refers to locationId and 50 refers to packageId, replace them with the values that you wish

References: - SoftLayer_Product_Order::getVlans