首页 文章

如何识别SoftLayer的网关网关VLAN

提问于
浏览
0

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

我正在尝试找到所有私人华盛顿4数据中心,从API我可以获得4个vlans,但门户网站允许选择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会有所帮助,但它总是假的(见上文) . 这里可以使用其他任何 property 吗?

1 回答

  • 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' .

    问候

相关问题