路由管理
创建关联关系
函数声明
def create_association(self, csn_rt_id, attach_id, description=None, client_token=None)
参数含义
请参考OpenAPI文档:https://cloud.baidu.com/doc/CSN/s/il13gbcn8
返回值
操作成功:
{}
操作失败:
返回错误,错误码列表参考:https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
代码示例
具体代码示例参考:example_create_association.py
删除关联关系
函数声明
def delete_association(self, csn_rt_id=None, attach_id=None, client_token=None)
参数含义
请参考OpenAPI文档:https://cloud.baidu.com/doc/CSN/s/kl13gcb4h
返回值
操作成功:
{}
操作失败:
返回错误,错误码列表参考:https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
代码示例
具体代码示例参考:example_delete_association.py
查询关联关系
函数声明
list_association(self, csn_rt_id=None)
参数含义
请参考OpenAPI文档:https://cloud.baidu.com/doc/CSN/s/zl13gcrny
返回值
操作成功:
{
"associations":[
{
"attachId":"tgwAttach-kfdccn8a6pip0qd1",
"description":"desc",
"instanceId":"vpc-v3ku2mhsyxvn",
"instanceName":"test-03",
"instanceRegion":"bj",
"instanceType":"vpc",
"status":"active"
}
]
}
操作失败:
返回错误,错误码列表参考:https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
代码示例
具体代码示例参考:example_list_association.py
查询路由表列表
函数声明
def list_route_table(self, csn_id, marker=None, max_keys=None)
参数含义
请参考OpenAPI文档:https://cloud.baidu.com/doc/CSN/s/hl13gm7x2
返回值
操作成功:
{
"marker": null,
"isTruncated": true,
"nextMarker": "csnBp-iuc756n5kkda",
"maxKeys": 1,
"csnRts": [
{
"csnRtId": "csn-rt-uezhhw306g5be3gb",
"name": "csnRtName",
"description": "desc",
"type": "default"
}
]
}
操作失败:
返回错误,错误码列表参考:https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
代码示例
具体代码示例参考:example_list_routetable.py
添加路由条目
函数声明
def create_route_rule(self, csn_rt_id, attach_id, destAddress, routeType="custom", client_token=None):
参数含义
请参考OpenApi文档: https://cloud.baidu.com/doc/CSN/s/Nl14d16n5
使用示例
csn_rt_id = "csnRt-abq04k8795z5n597" # 云智能网路由表ID
attach_id = "tgwAttach-n7yctm9zm605raig" # 网络实例在云智能网中的身份的ID
destAddress = "0.0.0.0/0" # 目的地址
try:
resp = csn_client.create_route_rule(csn_rt_id=csn_rt_id, attach_id=attach_id,
destAddress=destAddress, client_token=str(uuid.uuid4()))
print("Create csn route rule response: %s" % resp)
except BceHttpClientError as e:
print("Exception when calling api: %s" % e)
返回值
操作成功:
{
}
操作失败:
抛出异常,异常列表参考:https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
代码示例
具体代码示例参考: example_create_route_rule.py
查询路由条目
函数声明
def list_route_rule(self, csn_rt_id):
参数含义
请参考OpenApi文档: https://cloud.baidu.com/doc/CSN/s/sl14d3at6
使用示例
csn_rt_id = "csnRt-abq04k8795z5n597" # 云智能网路由表ID
try:
resp = csn_client.list_route_rule(csn_rt_id=csn_rt_id)
route_rules = resp.csnRtRules
print("List csn route rule response: %s" % resp)
except BceHttpClientError as e:
print("Exception when calling api: %s" % e)
返回值
操作成功:
{
"nextMarker": "csnrr-IyWRn123",
"marker": "csnrr-IyWRnII7",
"maxKeys": 1,
"isTruncated": true,
"csnRtRules": [
{
"ruleId": "cnrr-1db26d78-1781",
"routeType": "propagated",
"csnId": "csn-m3dwj6tfysnmxmcy",
"csnRtId": "csnRt-w3x16fk8nr5kpxkx",
"description": null,
"fromAttachId": "tgwAttach-wg3z1z5baq3ry1a6",
"status": "conflicted",
"sourceAddress": null,
"destAddress": "192.168.0.0/20",
"nextHopId": "vpc-fh43ygs8yp0d",
"nextHopName": "默认私有网络",
"nextHopRegion": "su",
"nextHopType": "vpc",
"asPath": "",
"community": "",
"blackHole": false
}
]
}
操作失败:
抛出异常,异常列表参考:https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
代码示例
具体代码示例参考: example_list_route_rule.py
删除路由条目
函数声明
func (c *Client) DeleteRouteRule(csnRtId string, csnRtRuleId string, clientToken string) error
参数含义
请参考OpenAPI文档:https://cloud.baidu.com/doc/CSN/s/Ll14d5a1d
返回值
操作成功:
{}
操作失败: 返回错误,错误码列表参考:https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
代码示例
具体代码示例参考:example_delete_route_rule.py
创建学习关系
函数声明
def create_propagation(self, csn_rt_id, attach_id, description=None, client_token=None):
参数含义
请参考OpenApi文档: https://cloud.baidu.com/doc/CSN/s/Dl14cf0h1
使用示例
csn_rt_id = "csnRt-abq04k8795z5n597" # 云智能网路由表ID
attach_id = "tgwAttach-n7yctm9zm605raig" # 网络实例在云智能网中的身份的ID
try:
resp = csn_client.create_propagation(csn_rt_id=csn_rt_id, attach_id=attach_id, client_token=str(uuid.uuid4()))
print("Create csn propagation response: %s" % resp)
except BceHttpClientError as e:
print("Exception when calling api: %s" % e)
返回值
操作成功:
{
}
操作失败:
抛出异常,异常列表参考:https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
代码示例
具体代码示例参考: example_create_propagation.py
删除学习关系
函数声明
def delete_propagation(self, csn_rt_id, attach_id, client_token=None):
参数含义
请参考OpenApi文档: https://cloud.baidu.com/doc/CSN/s/gl14cfnmj
使用示例
csn_rt_id = "csnRt-abq04k8795z5n597" # 云智能网路由表ID
attach_id = "tgwAttach-n7yctm9zm605raig" # 网络实例在云智能网中的身份ID
try:
resp = csn_client.delete_propagation(csn_rt_id=csn_rt_id, attach_id=attach_id, client_token=str(uuid.uuid4()))
print("Delete csn propagation response: %s" % resp)
except BceHttpClientError as e:
print("Exception when calling api: %s\n" % e)
返回值
操作成功:
{
}
操作失败:
抛出异常,异常列表参考:https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
代码示例
具体代码示例参考: example_delete_propagation.py
查询学习关系
函数声明
def list_propagation(self, csn_rt_id):
参数含义
请参考OpenApi文档: https://cloud.baidu.com/doc/CSN/s/8l14cgbsf
使用示例
csn_rt_id = "csnRt-abq04k8795z5n597" # 云智能网路由表ID
try:
resp = csn_client.list_propagation(csn_rt_id=csn_rt_id)
propagations = resp.propagations
print("List propagation response: %s" % propagations)
except BceHttpClientError as e:
print("Exception when calling api: %s" % e)
返回值
操作成功:
{
"propagations":[
{
"attachId":"tgwAttach-kfdccn8a6pip0qd1",
"description":"default",
"instanceName":"test-03",
"instanceRegion":"bj",
"instanceId":"vpc-v3ku2mhsyxvn",
"instanceType":"vpc",
"status":"enable"
}
]
}
操作失败:
抛出异常,异常列表参考:https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
代码示例
具体代码示例参考: example_list_propagation.py