-
Notifications
You must be signed in to change notification settings - Fork 3
Basic Create ANC Policy Notification
This sample registers and outputs messages received for Cisco Adaptive Network
Control (ANC) create 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 MyAncCreatePolicyCallback(AncCreatePolicyCallback):
def on_create_policy(self, create_dict):
print("on_create_policy\n" +
MessageUtils.dict_to_json(create_dict, pretty_print=True))
# Attach callback for 'create policy' events
client.anc.add_create_policy_callback(MyAncCreatePolicyCallback())
# Wait forever
print("Waiting for create 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_create_policy_callback()
method is invoked to register
a callback for create policy
event notifications.
When a create policy
event occurs, the on_create_policy()
method in the
MyAncCreatePolicyCallback
class is invoked. The create_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 create policy events...
To generate a create policy
notification, create an ANC policy on the
Cisco Identity Services Engine (ISE) server. The policy could be created by
logging into the ISE web interface and performing the following steps:
- Navigate to Operations → Adaptive Network Control → Policy List.
- On the List screen, click on the Add button.
- On the List → New screen, enter
quarantine_policy
in the name field, selectQUARANTINE
in the Action field, and press the Submit button.
A message similar to the following should appear in the output of the notification example:
{
"action": [
"Quarantine"
],
"name": "quarantine_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)