Route management
Create affiliation
Function declaration
1def create_association(self, csn_rt_id, attach_id, description=None, client_token=None)
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/il13gbcn8
Response value
Operation succeeded:
1{}
Operation failed:
Return error. For the error code list, please refer to: https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
Code example
For specific code examples, please refer to: example_resize_csn_bp.py
Delete an association relationship
Function declaration
1def delete_association(self, csn_rt_id=None, attach_id=None, client_token=None)
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/kl13gcb4h
Response value
Operation succeeded:
1{}
Operation failed:
Return error. For the error code list, please refer to: https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
Code example
For specific code examples, please refer to: example_delete_association.py
Query association relationships
Function declaration
1list_association(self, csn_rt_id=None)
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/zl13gcrny
Response value
Operation succeeded:
1{
2 "associations":[
3 {
4 "attachId":"tgwAttach-kfdccn8a6pip0qd1",
5 "description":"desc",
6 "instanceId":"vpc-v3ku2mhsyxvn",
7 "instanceName":"test-03",
8 "instanceRegion":"bj",
9 "instanceType":"vpc",
10 "status":"active"
11 }
12 ]
13}
Operation failed:
Return error. For the error code list, please refer to: https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
Code example
For specific code examples, please refer to: example_list_association.py
Query route table list
Function declaration
1def list_route_table(self, csn_id, marker=None, max_keys=None)
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/hl13gm7x2
Response value
Operation succeeded:
1{
2 "marker": null,
3 "isTruncated": true,
4 "nextMarker": "csnBp-iuc756n5kkda",
5 "maxKeys": 1,
6 "csnRts": [
7 {
8 "csnRtId": "csn-rt-uezhhw306g5be3gb",
9 "name": "csnRtName",
10 "description": "desc",
11 "type": "default"
12 }
13 ]
14}
Operation failed:
Return error. For the error code list, please refer to: https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
Code example
For specific code examples, please refer to: example_list_routetable.py
Add a routing entry
Function declaration
1def create_route_rule(self, csn_rt_id, attach_id, destAddress, routeType="custom", client_token=None):
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/Nl14d16n5
Usage example
1csn_rt_id = "csnRt-abq04k8795z5n597" # Cloud Smart Network route table ID
2 attach_id = "tgwAttach-n7yctm9zm605raig” # Identity ID of the network instance in Cloud Smart Network
3 destAddress = "0.0.0.0/0" # Destination address
4try:
5 resp = csn_client.create_route_rule(csn_rt_id=csn_rt_id, attach_id=attach_id,
6 destAddress=destAddress, client_token=str(uuid.uuid4()))
7 print("Create csn route rule response: %s" % resp)
8except BceHttpClientError as e:
9 print("Exception when calling api: %s" % e)
Response value
Operation succeeded:
1{
2}
Operation failed:
Throw an exception. For the exception list, refer to: https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
Code example
For specific code examples, please refer to: example_create_route_rule.py
Query routing entries
Function declaration
1def list_route_rule(self, csn_rt_id):
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/sl14d3at6
Usage example
1csn_rt_id = "csnRt-abq04k8795z5n597" # Cloud Smart Network route table ID
2try:
3 resp = csn_client.list_route_rule(csn_rt_id=csn_rt_id)
4 route_rules = resp.csnRtRules
5 print("List csn route rule response: %s" % resp)
6except BceHttpClientError as e:
7 print("Exception when calling api: %s" % e)
Response value
Operation succeeded:
1{
2 "nextMarker": "csnrr-IyWRn123",
3 "marker": "csnrr-IyWRnII7",
4 "maxKeys": 1,
5 "isTruncated": true,
6 "csnRtRules": [
7 {
8 "ruleId": "cnrr-1db26d78-1781",
9 "routeType": "propagated",
10 "csnId": "csn-m3dwj6tfysnmxmcy",
11 "csnRtId": "csnRt-w3x16fk8nr5kpxkx",
12 "description": null,
13 "fromAttachId": "tgwAttach-wg3z1z5baq3ry1a6",
14 "status": "conflicted",
15 "sourceAddress": null,
16 "destAddress": "192.168.0.0/20",
17 "nextHopId": "vpc-fh43ygs8yp0d",
18 "nextHopName": "Default Virtual Private Cloud",
19 "nextHopRegion": "su",
20 "nextHopType": "vpc",
21 "asPath": "",
22 "community": "",
23 "blackHole": false
24 }
25 ]
26}
Operation failed:
Throw an exception. For the exception list, refer to: https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
Code example
For specific code examples, please refer to: example_list_route_rule.py
Delete a routing entry
Function declaration
1func (c *Client) DeleteRouteRule(csnRtId string, csnRtRuleId string, clientToken string) error
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/Ll14d5a1d
Response value
Operation succeeded:
1{}
Operation failed: Return error. For the error code list, please refer to: https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
Code example
For specific code examples, please refer to: example_delete_route_rule.py
Create learning relationship
Function declaration
1def create_propagation(self, csn_rt_id, attach_id, description=None, client_token=None):
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/Dl14cf0h1
Usage example
1csn_rt_id = "csnRt-abq04k8795z5n597" # Cloud Smart Network route table ID
2 attach_id = "tgwAttach-n7yctm9zm605raig” # Identity ID of the network instance in Cloud Smart Network
3try:
4 resp = csn_client.create_propagation(csn_rt_id=csn_rt_id, attach_id=attach_id, client_token=str(uuid.uuid4()))
5 print("Create csn propagation response: %s" % resp)
6except BceHttpClientError as e:
7 print("Exception when calling api: %s" % e)
Response value
Operation succeeded:
1{
2}
Operation failed:
Throw an exception. For the exception list, refer to: https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
Code example
For specific code examples, please refer to: example_create_propagation.py
Delete a learning relationship
Function declaration
1def delete_propagation(self, csn_rt_id, attach_id, client_token=None):
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/gl14cfnmj
Usage example
1csn_rt_id = "csnRt-abq04k8795z5n597" # Cloud Smart Network route table ID
2 attach_id = "tgwAttach-n7yctm9zm605raig” # Identity ID of the network instance in Cloud Smart Network
3try:
4 resp = csn_client.delete_propagation(csn_rt_id=csn_rt_id, attach_id=attach_id, client_token=str(uuid.uuid4()))
5 print("Delete csn propagation response: %s" % resp)
6except BceHttpClientError as e:
7 print("Exception when calling api: %s\n" % e)
Response value
Operation succeeded:
1{
2}
Operation failed:
Throw an exception. For the exception list, refer to: https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
Code example
For specific code examples, please refer to: example_delete_propagation.py
Query learning relationships
Function declaration
1def list_propagation(self, csn_rt_id):
Parameter meaning
Refer to the OpenAPI documentation: https://cloud.baidu.com/doc/CSN/s/8l14cgbsf
Usage example
1csn_rt_id = "csnRt-abq04k8795z5n597" # Cloud Smart Network route table ID
2try:
3 resp = csn_client.list_propagation(csn_rt_id=csn_rt_id)
4 propagations = resp.propagations
5 print("List propagation response: %s" % propagations)
6except BceHttpClientError as e:
7 print("Exception when calling api: %s" % e)
Response value
Operation succeeded:
1{
2 "propagations":[
3 {
4 "attachId":"tgwAttach-kfdccn8a6pip0qd1",
5 "description":"default",
6 "instanceName":"test-03",
7 "instanceRegion":"bj",
8 "instanceId":"vpc-v3ku2mhsyxvn",
9 "instanceType":"vpc",
10 "status":"enable"
11 }
12 ]
13}
Operation failed:
Throw an exception. For the exception list, refer to: https://cloud.baidu.com/doc/CSN/s/Tl56j65ym
Code example
For specific code examples, please refer to: example_list_propagation.py
