如何识别 SoftLayer 的网络网关 VLAN

How to recognize Network Gateway VLAN for SoftLayer

我想知道的是如何理解VLAN是网关。

我正在尝试查找所有私有 Washington 4 数据中心,并且从 API 我可以获得 4 个 vlan,但该门户允许 select 3 个 vlan 之一。 这个subnet/vlan好像不能用:

{"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}}

如果我通过此 vlan id 来请求订单,我会收到此错误:

The backend VLAN #1158237 is a Network Gateway VLAN. 

所以这个vlan不能用,portal过滤掉了。可以,问题是这个vlan不应该用怎么理解?

最初我认为 attachedNetworkGatewayFlag 会有所帮助,但它总是错误的(见上文)。这里可以使用其他 属性 吗?

根据文档,有一个 属性 称为 "type":

type

The type of this VLAN.
Type: SoftLayer_Network_Vlan_Type

有关详细信息,请参阅: http://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_Vlan

因此您可以使用对象掩码获取 VLAN 的此信息。有关对象掩码的更多信息,请参阅:http://sldn.softlayer.com/article/object-Masks

使用 RestFul 您可以获得所有 VLAN 并使用此请求显示类型:

GET https://$USERNAME:$APIKEY@api.softlayer.com/rest/v3/SoftLayer_Account/getNetworkVlans?objectMask=mask[type]

上面的请求将 return 像这样的响应:

 {
        "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"
        }
    }

如果您是 Ruby 客户端的用户,您可以试试这个:

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

此外,您可能对使用 objectFilters 获取非网关类型的数据中心的所有 VLAN 感兴趣,您可以使用此 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

有关对象过滤器的更多信息,请参阅:http://sldn.softlayer.com/article/object-filters

最后请记住,对于订单,只能使用 "Standard" 类型的 VLAN。 VLAN 的有效类型是:

‘GATEWAY’, ‘STANDARD’, ‘INTERCONNECT’, ‘SWITCH_MANAGEMENT’, ‘FIREWALL_HEARTBEAT’, ‘FIREWALL_CONTEXT’.

此致