-
Notifications
You must be signed in to change notification settings - Fork 3
Basic Update ANC Policy Notification
This sample registers and outputs messages received for Cisco Adaptive Network
Control (ANC) update 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 MyAncUpdatePolicyCallback(AncUpdatePolicyCallback):
def on_update_policy(self, update_dict):
print("on_update_policy\n" +
MessageUtils.dict_to_json(update_dict, pretty_print=True))
# Attach callback for 'update policy' events
client.anc.add_update_policy_callback(MyAncUpdatePolicyCallback())
# Wait forever
print("Waiting for update 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_update_policy_callback() method is invoked to register
a callback for update policy event notifications.
When an update policy event occurs, the on_update_policy() method in the
MyAncUpdatePolicyCallback class is invoked. The update_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 update policy events...
To generate an update policy notification, update an ANC policy on the
server. The policy could be updated by logging into the ISE web interface and
performing the following steps:
- Navigate to Operations → Adaptive Network Control → Policy List.
- On the List screen, check the box next to the policy name -- for
example:
test_policy-- and press the Edit button. - On the List → policy screen, change the value in the
Action field. For example, if the current value were
QUARANTINE, the value could be changed toPORT_BOUNCE. Press the Save button to commit the change.
A message similar to the following should appear in the output of the notification example:
{
"newPolicy": {
"action": [
"PortBounce"
],
"name": "test_policy"
},
"oldPolicy": {
"action": [
"Quarantine"
],
"name": "test_policy"
}
}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)