-
Notifications
You must be signed in to change notification settings - Fork 3
Basic Clear ANC Endpoint Policy Notification
This sample registers and outputs messages received for Cisco Adaptive
Network Control (ANC) clear endpoint policy
notifications via DXL and Cisco
pxGrid.
The majority of the sample code is shown below.
# Create the client
with DxlClient(config) as dxl_client:
# Connect to the fabric
dxl_client.connect()
logger.info("Connected to DXL fabric.")
# Create client wrapper
client = CiscoPxGridClient(dxl_client)
class MyAncClearEndpointPolicyCallback(AncClearEndpointPolicyCallback):
def on_clear_endpoint_policy(self, clear_dict):
print("on_clear_endpoint_policy\n" +
MessageUtils.dict_to_json(clear_dict, pretty_print=True))
# Attach callback for 'clear policy' events
client.anc.add_clear_endpoint_policy_callback(
MyAncClearEndpointPolicyCallback())
# Wait forever
print("Waiting for clear policy events...")
while True:
time.sleep(60)
Once a connection is established to the DXL fabric, a CiscoPxGridClient
instance is created which will be used to communicate with Cisco pxGrid.
Next, the add_clear_endpoint_policy_callback()
method is invoked to register
a callback for clear policy
event notifications.
When a clear endpoint policy
event occurs, the on_clear_endpoint_policy()
method in the MyAncClearEndpointPolicyCallback
class is invoked. The
clear_dict
parameter passed into the callback, a dictionary (dict
)
which contains the content of the event notification, is displayed.
After the example starts up, the initial output should appear similar to the following:
Waiting for clear policy events...
To generate a clear endpoint policy by IP address
notification, run
through the steps in the
Clear Endpoint Policy by IP Address
example in a separate terminal command window. Assuming that the policy is
successfully cleared, the following message should appear in the output of the
notification example:
{
"ipAddress": "192.168.1.1"
}
To generate a clear endpoint policy by MAC address
notification, run
through the steps in the
Clear Endpoint Policy by MAC Address
example in a separate terminal command window. Assuming that the policy is
successfully cleared, the following message should appear in the output of the
notification example:
{
"macAddress": "00:11:22:33:44:55"
}
Note that if the clear endpoint policy
calls encounter any errors -- for
example, due to no policy already having been applied -- no corresponding event
notification will be generated.
Cisco pxGrid DXL Client Library
SDK Modules
Examples
- Basic
- Cisco Adaptive Network Control (ANC)
- Apply Endpoint Policy by IP Address
- Apply Endpoint Policy by MAC Address
- Apply Endpoint Policy Notification
- Clear Endpoint Policy by IP Address
- Clear Endpoint Policy by MAC Address
- Clear Endpoint Policy Notification
- Get Endpoint Policy by IP Address
- Get Endpoint Policy by MAC Address
- Retrieve All Policies
- Retrieve Policy by Name
- Create Policy Notification
- Update Policy Notification
- Delete Policy Notification
- Cisco Endpoint Protection Service (EPS)
- Session Notification
- Cisco Adaptive Network Control (ANC)