-1

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 Answers1

2

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

  • If I don't have a subnet specification, Can I code `"primaryNetworkComponent": { "networkVlanId":971075 – Gary Sutherland Jun 03 '16 at 02:03
  • Got caught in 5 minute timeout to edit comment. If I don't have a subnet specification, Can I code `"primaryNetworkComponent": { "networkVlanId":971075 },` or do I specify `"primaryNetworkComponent" : { "networkVlan" : { "id": 971075 } },` or does either work if no subnet is specified? – Gary Sutherland Jun 03 '16 at 02:10
  • Both cases should work, it is not necessary to specify the subnet, you can only define the vlan if you wish. – Ruber Cuellar Valenzuela Jun 03 '16 at 13:16
  • I tried to use virtualGuests instead of hardware and got error. '_content' => '{"error":"The property \'networkVlanId\' is not valid for \'SoftLayer_Virtual_Guest_Network_Component\'.","code":"SoftLayer_Exception_Public"}', Is networkVlanId only valid for hardwre? – Gary Sutherland Jun 05 '16 at 01:12
  • Went back to format `"networkVlan":{ "id" : 971075, "primarySubnet":{ "id":233232 } } – Gary Sutherland Jun 05 '16 at 22:12
  • The **networkVlanId** is not a property from [SoftLayer_Virtual_Guest_Network_Component](http://sldn.softlayer.com/reference/datatypes/SoftLayer_Virtual_Guest_Network_Component) object, in this case, I recommend to use hardware object to define vlans. – Ruber Cuellar Valenzuela Jun 06 '16 at 19:24