首页 文章

订购Softlayer Vlan对

提问于
浏览
0

我似乎特意找到答案 . 我'm creating some automation scripts in python and wondering if there'是一种获取 primaryNetworkComponentprimaryBackendNetworkComponent 对并基于位置的方法?有 getVlans() 方法,但不知道哪个vlans一起去,除非我去gui . vlan对上的机器数量没有限制吗?如果没有它只是可以接受 grab 路由器,只是采取前2个vlans?

3 回答

  • 0

    以下脚本可以帮助从特定位置检索vlan:

    """
    Retrieves vlans from specific location
    
    Important manual pages:
    http://sldn.softlayer.com/reference/services/SoftLayer_Account/getNetworkVlans
    http://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_Vlan/
    http://sldn.softlayer.com/article/object-Masks
    http://sldn.softlayer.com/article/object-filters
    
    License: http://sldn.softlayer.com/article/License
    Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
    """
    import SoftLayer
    
    # Your SoftLayer API username and key.
    USERNAME = 'set me'
    API_KEY = 'set me'
    
    # Define location
    datacenter = "Seoul 1"
    
    # Declare the API client
    client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
    
    # Declaring an object mask and object filter to get vlans from datacenter
    objectMask = "mask[primaryRouter[datacenter], networkSpace]"
    objectFilter = {"networkVlans": {"primaryRouter": {"datacenter": {"longName": {"operation": datacenter}}}}}
    
    try:
        # Getting the VLANs
        vlans = client['SoftLayer_Account'].getNetworkVlans(mask=objectMask, filter=objectFilter)
        # Print vlans
        print("PRIMARY NETWORK COMPONENT")
        for vlan in vlans:
            if vlan['networkSpace'] == 'PUBLIC':
                print("Id: %s     Vlan Number: %s      Primary Router: %s" % (vlan['id'], vlan['vlanNumber'], vlan['primaryRouter']['hostname']))
        print("\nPRIMARY BACKEND NETWORK COMPONENT")
        for vlan in vlans:
            if vlan['networkSpace'] == 'PRIVATE':
                print("Id: %s     Vlan Number: %s      Primary Router: %s" % (vlan['id'], vlan['vlanNumber'], vlan['primaryRouter']['hostname']))
    except SoftLayer.SoftLayerAPIError as e:
        print("Unable to get Vlans. faultCode=%s, faultString=%s"
              % (e.faultCode, e.faultString))
    

    public vlan中的服务器数量没有限制,但它取决于可用的ip地址,私有vlan的情况相同 . 在私有vlan的情况下有256个ip地址的限制 .

    如果vlan具有硬件防火墙,则它具有30个服务器(VSI或BMS)的限制 .

    从路由器检索第一个vlan是不可能的,因为这是受限制的,你只能检索你购买的vlan .

    References:

  • 0

    我有这个代码

    mask = 'id, hostname, domain, hardwareStatus, globalIdentifier, remoteManagementAccounts, primaryBackendIpAddress, primaryIpAddress'
        hardware_list = mgr.list_hardware(mask=mask)
        for hardware in hardware_list:
            if "someGLobalID" == hardware['globalIdentifier']:
    

    我正在尝试获取全局标识符,但我一直收到一个关键错误

    订单完成后和部署状态下是否生成全局标识符?

    我尝试搜索域名等不同的密钥,但它确实有用

  • 0

    我使用以下脚本取得了成功:

    """
    List Hardware
    
    Important manual pages:
    http://sldn.softlayer.com/reference/datatypes/SoftLayer_Hardware
    https://github.com/softlayer/softlayer-python/blob/master/SoftLayer/managers/hardware.py
    
    License: http://sldn.softlayer.com/article/License
    Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
    """
    import SoftLayer
    
    # Your SoftLayer API username and key.
    USERNAME = 'set me'
    API_KEY = 'set me'
    
    # Declare the API client
    client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
    mgr = SoftLayer.HardwareManager(client)
    
    globalIdentifier = '93e99548-bb97-4a18-b728-9c8ebba6s9e3'
    
    try:
        mask = 'id, hostname, domain, hardwareStatus, globalIdentifier, remoteManagementAccounts, primaryBackendIpAddress, primaryIpAddress'
        hardware_list = mgr.list_hardware(mask=mask)
        for hardware in hardware_list:
            if globalIdentifier == hardware['globalIdentifier']:
                print(hardware['globalIdentifier'])
    
    except SoftLayer.SoftLayerAPIError as e:
        print("Error. "
              % (e.faultCode, e.faultString))
    

    您是对的,全局标识符在订单收据中生成,但它们将附加到服务器,直到供应过程完成 . 因此,有必要等到服务器的配置过程结束,然后搜索 .

相关问题