2016-11-29 67 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

該死,「類型」 - 這是簡單的,爲什麼我沒看到? :)無論如何,謝謝你 –