如何识别SoftLayer的网关网关VLAN

时间:2016-11-29 11:27:28

标签: ibm-cloud-infrastructure

我想要了解的是如何理解VLAN是网络网关。

我试图找到所有私人华盛顿4数据中心,并且从API我可以获得4个vlan,但门户网站允许选择3个vlan中的一个。 看来这个子网/ 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,门户网站会将其过滤掉。没关系,但问题是如何理解不应该使用这个vlan?

最初我认为attachNetworkGatewayFlag会有所帮助,但它总是假的(见上文)。可以在这里使用任何其他财产吗?

1 个答案:

答案 0 :(得分:0)

根据文档,有一个名为“type”的属性:

  

     

此VLAN的类型。
  键入: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]

上述请求将返回如下响应:

 {
        "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 Client的用户,可以尝试:

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

有关objectFilters的详细信息,请参阅:http://sldn.softlayer.com/article/object-filters

最后请记住,对于订单,只能使用“标准”类型的VLAN。 VLAN的有效类型为:

  

'GATEWAY','STANDARD','INTERCONNECT','SWITCH_MANAGEMENT',   'FIREWALL_HEARTBEAT','FIREWALL_CONTEXT'。

此致