Create a SoftLayer virtual guest on a specific sub

2019-01-29 13:32发布

问题:

Recently I noticed the SoftLayer UI has changed and part of that change was the ability to specify a subnet on a VLAN when ordering a virtual guest.

Has this support been implemented in the REST API json payload when specifying primaryNetworkComponent and primaryBackendNetworkComponent parameters to create a virtual guest?

回答1:

Yes, Currently It's possible to set the subnets, you should define "primarySubnet" inside of "networkVlan" property, here a Rest example:

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

Method: Post

{  
   "parameters":[  
      {  
         "orderContainers":[  
            {  
               "hardware":[  
                  {  
                     "hostname":"testhost",
                     "domain":"softlayer.com",
                     "primaryBackendNetworkComponent":  
                        {  
                           "networkVlanId":971077,
                           "networkVlan":{  
                              "primarySubnet":{  
                                 "id":225652
                              }
                           }
                        }
                     ,
                     "primaryNetworkComponent":  
                        {  
                           "networkVlanId":971075,
                           "networkVlan":{  
                              "primarySubnet":{  
                                 "id":233232
                              }
                           }
                        }

                  }
               ],
               "location":"DALLAS05",
               "quantity":1,
               "packageId":46,
               "prices":[  
                  {  
                     "id":1640
                  },
                  {  
                     "id":1644
                  },
                  {  
                     "id":1857
                  },
                  {  
                     "id":1639
                  },
                  {  
                     "id":50367
                  },
                  {  
                     "id":273
                  },
                  {  
                     "id":2302
                  },
                  {  
                     "id":55
                  },
                  {  
                     "id":58
                  },
                  {  
                     "id":420
                  },
                  {  
                     "id":418
                  },
                  {  
                     "id":21
                  },
                  {  
                     "id":57
                  },
                  {  
                     "id":905
                  }
               ]
            }
         ]
      }
   ]
}

Replace: $user, $apiKey and the values for: networkVlanId and primarySubnet >> id with your own information