You can subscribe to IPv6 route change events. After you subscribe to IPv6 route change events and an IPv6 route change event is triggered, the system executes the ops_execute() function in the maintenance assistant script.
This API can only be used in the ops_condition() function of the maintenance assistant script.
opsObj.route.subscribe6(self, tag, network, maskLen, minLen=None, maxLen=None, vpnName="_public_", optype="all", protocol="all")
Method |
Description |
---|---|
opsObj |
Specifies an OPS object. It is obtained through ops.ops() instantiation. |
tag |
Specifies a condition ID. The value is a string of 1 to 8 case-sensitive characters that starts with a letter and contains letters, digits, and underscores (_). Enter double quotation marks ("") or None for the only one condition. tag cannot be set to and, or, or not. |
network |
Specifies an IPv6 route prefix. The value is in the IPv6 address format, such as 2001:db8:1::2. |
maskLen |
Specifies a mask length. The value is an integer ranging from 0 to 128. |
minLen |
Specifies the minimum mask length. The value must be greater than or equal to the value of maskLen. |
maxLen |
Specifies the maximum mask length. The value must be greater than or equal to the value of minLen. |
vpnName |
Specifies the name of the VPN instance in which route change events are to be subscribed to. The value is a string of 1 to 31 characters. This parameter is optional. If the parameter is not specified, change events of the corresponding public network routes are subscribed to by default. NOTE:
The specified VPN instance must be an existing one on the device, and the IPv6 address family must have been enabled in the VPN instance. If either condition is not met, the subscription rule does not take effect. |
type |
Specifies an IPv6 route change event type. The value can be add, remove, modify, or all. The value all indicates all route changes. |
protocol |
Specifies a routing protocol. After this parameter is set, change events of routes of the specified protocol are subscribed to. The value can be direct, static, isis, bgp, unr, or all. The default value is all, indicating that routes are not filtered by protocol type. |
test.py import ops def ops_condition(_ops): ret, reason = _ops.route.subscribe6("con0", "2001:db8:1::2", maskLen=64, vpnName="testVpn", optype="all", protocol="all") ret, reason = _ops.correlate("(con0 and con1)") return ret def ops_execute(_ops): a, des = _ops.context.save("test.py", 'Route event trigger') return 0
When a route with the prefix 2001:db8:1::2/64 is added to or deleted from the VPN instance testVpn, a route change event is triggered.