Multi-condition combination
Subscription phase
result1_value, result2_description = ops.correlate("expression")
Parameter |
Description |
Value |
---|---|---|
expression |
Indicates a combined condition expression. |
The value is a string of 1 to 128 characters. It consists of the tag name, brackets, and operators (and, or, andnot). A maximum of eight tag names can be combined. Priorities of operators and and andnot are the same and are greater than that of or. |
The result1_value and result2_description in the API prototype indicate return values.
The result1_value is the first return value, 0 indicates success, and 1 indicates failure.
The result2_description is the second return value, indicating the failure cause. It is returned only when the first return value is 1.
Typically, only one simple event can be subscribed to and one trigger condition can be registered in the subscription phase in a Python script. Using the multi-condition combination API, you can combine multiple simple events into a complex event to describe relationships between multiple simple events. The tags of the simple events must be different.
For example, ops.correlate("((tag1 or tag2) andnot (tag3 or tag4))") indicates that the corresponding action is triggered when event tag1 or tag2 occurs but event tag3 or tag4 does not occur.
In a Python script, a maximum of eight simple events can be subscribed to and then be combined through the multi-condition combination API.
When you run the arp learning multicast disable or arp broadcast disable command, the corresponding action is triggered.
value1, descri_str1 = ops.cli.subscribe("cli1", "arp learning multicast disable", enter=True, sync=True, sync_wait=60) value2, descri_str2 = ops.cli.subscribe("cli2", "arp broadcast disable", enter=True, sync=True, sync_wait=60) value3, descri_str3 = ops.correlate("cli1 or cli2")