You need to enable JavaScript to run this app.
导航
创建虚拟接口
最近更新时间:2023.07.05 15:24:48首次发布时间:2023.07.05 15:24:48

本文介绍如何创建虚拟接口。

示例代码

# Example Code generated by Beijing Volcanoengine Technology.
from __future__ import print_function
import volcenginesdkcore
import volcenginesdkdirectconnect
from pprint import pprint
from volcenginesdkcore.rest import ApiException

if __name__ == '__main__':
    configuration = volcenginesdkcore.Configuration()
    configuration.ak = "AK"
    configuration.sk = "SK"
    configuration.region = "cn-beijing"
    # 设置默认配置。
    volcenginesdkcore.Configuration.set_default(configuration)

    # 使用全局默认配置。
    api_instance = volcenginesdkdirectconnect.DIRECTCONNECTApi()
    # 配置待创建虚拟接口的参数。
    create_direct_connect_virtual_interface_request = volcenginesdkdirectconnect.CreateDirectConnectVirtualInterfaceRequest(
        description="test", # 设置虚拟接口的描述。
        direct_connect_connection_id="dcc-2fe3zsmkshs59g****", # 设置虚拟接口关联的物理专线的ID。
        direct_connect_gateway_id="dcg-7qthudw0ll6jmc****", # 设置虚拟接口关联的专线网关的ID。
        local_ip="192.XX.XX.10/24", # 设置虚拟接口的本端网关互联IP地址。
        peer_ip="192.XX.XX.20/24", # 设置虚拟接口的对端网关互联IP地址。
        virtual_interface_name="test", # 设置虚拟接口的名称。
        vlan_id=2000, # 设置用于连接本地IDC的VLAN ID,请确保此VLAN ID未被占用
    )

    # 发起请求并处理返回或异常。
    try:
        resp = api_instance.create_direct_connect_virtual_interface(create_direct_connect_virtual_interface_request)
        pprint(resp)
    except ApiException as e:
        print("Exception when calling api: %s\n" % e)

相关文档