2016-11-29 50 views
0

我想要得到的是如何理解一个VLAN是一个网关。如何识别SoftLayer的网络网关VLAN

我试图找到所有私人华盛顿4数据中心和API我可以得到4 vlans,但门户允许选择3 vlans之一。 看来这子网/ 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不应该被使用?

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

回答

0

根据文档有一个名为“类型”属性:

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

使用REST风格,你可以让所有的VLAN和使用该请求显示类型:

GET https://$USERNAME:[email protected]/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客户端的用户,你可以试试这个:

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:[email protected]/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’.

问候

+0

该死,“类型” - 这是简单的,为什么我没看到? :)无论如何,谢谢你 –