What I'm trying to get is how to understand that a VLAN is a network gateway one.
I'm trying to find all private Washington 4 datacenter and from the API I can get 4 vlans, but the portal allows to select one of 3 vlans. It seems this subnet/vlan cannot be used:
{"broadcastAddress"=>"10.170.23.127",
"cidr"=>26,
"gateway"=>"10.170.23.65",
"id"=>1087855,
"isCustomerOwned"=>false,
"isCustomerRoutable"=>false,
"modifyDate"=>"2016-02-03T14:51:45-05:00",
"netmask"=>"255.255.255.192",
"networkIdentifier"=>"10.170.23.64",
"networkVlanId"=>1158237,
"sortOrder"=>"4",
"subnetType"=>"PRIMARY",
"totalIpAddresses"=>"64",
"usableIpAddressCount"=>"61",
"version"=>4,
"addressSpace"=>"PRIVATE",
"datacenter"=>{"id"=>957095, "longName"=>"Washington 4", "name"=>"wdc04", "statusId"=>2},
"networkVlan"=>
{"accountId"=>872113,
"id"=>1158237,
"modifyDate"=>"2016-02-04T12:57:26-05:00",
"name"=>"RZ",
"primarySubnetId"=>1087855,
"attachedNetworkGatewayFlag"=>false,
"vlanNumber"=>844}}
If I pass this vlan id to request an order, I receive this error:
The backend VLAN #1158237 is a Network Gateway VLAN.
So this vlan cannot be used and the portal filters it out. That's ok, but the question is how to understand that this vlan should not be used?
Initially I thought attachedNetworkGatewayFlag will help, but it always false(see above). Any other property could be used here?
According to documentation there is a property called "type":
type
The type of this VLAN.
Type: SoftLayer_Network_Vlan_Type
For more information see: http://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_Vlan
So you can get this information of the VLAN using object mask. For more information about object masks see: http://sldn.softlayer.com/article/object-Masks
Using RestFul you could get all your VLANs and show the type using this request:
GET https://$USERNAME:$APIKEY@api.softlayer.com/rest/v3/SoftLayer_Account/getNetworkVlans?objectMask=mask[type]
The request above will return a response like this:
{
"accountId": XXXXX,
"id": XXXX,
"modifyDate": "2015-01-28T07:39:10-06:00",
"primarySubnetId": XXXX,
"vlanNumber": XXX,
"type": {
"description": "Network VLAN belonging to a network gateway",
"id": 2,
"keyName": "GATEWAY",
"name": "Gateway"
}
}
In case you are an user of the Ruby Client you can try this:
require 'rubygems'
require 'softlayer_api'
SL_API_USERNAME = 'set me'
SL_API_KEY = 'set me'
client = SoftLayer::Client.new(username: SL_API_USERNAME,
api_key: SL_API_KEY)
object_mask = 'mask[type]'
account_service = client['SoftLayer_Account']
vlans = account_service.object_mask(object_mask).getNetworkVlans()
print vlans
Also you may be interested in use objectFilters to get all the VLANS for a datacenter which are not Gateway type, you can achieve that using this RESTFUL:
https://$username:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Account/getPrivateNetworkVlans?objectFilter={"privateNetworkVlans":{"primaryRouter":{"datacenter":{"longName":{"operation":"Washington 4"}}},"type":{"keyName":{"operation":"!=GATEWAY"}}}}
Replace: $username, $apiKey and Washington 4 (You can replace this for other datacenter) with your own information
For more information about objectFilters see:http://sldn.softlayer.com/article/object-filters
And finally keep in mind that for orders only the VLANS of type "Standard" can be used. The valid types for VLANs are:
‘GATEWAY’, ‘STANDARD’, ‘INTERCONNECT’, ‘SWITCH_MANAGEMENT’, ‘FIREWALL_HEARTBEAT’, ‘FIREWALL_CONTEXT’.
Regards