-
Notifications
You must be signed in to change notification settings - Fork 3
Basic Clear ANC Endpoint Policy by MAC Address
This sample clears a Cisco Adaptive Network Control (ANC) policy from an endpoint via DXL and Cisco pxGrid. The sample identifies the endpoint by its MAC address.
The majority of the sample code is shown below.
# MAC address of the endpoint for which to clear the policy
HOST_MAC = "<SPECIFY_MAC_ADDRESS>"
# 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)
try:
# Invoke 'clear endpoint policy by MAC' method on service
resp_dict = client.anc.clear_endpoint_policy_by_mac(HOST_MAC)
# Print out the response (convert dictionary to JSON for pretty
# printing)
print("Response:\n{0}".format(
MessageUtils.dict_to_json(resp_dict, pretty_print=True)))
except Exception as ex:
# An exception would be raised if a policy has not already been
# associated with the endpoint.
print(str(ex))
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 clear_endpoint_policy_by_mac()
method is invoked with the MAC
address of the endpoint for which to clear the policy.
The final step is to display the contents of the returned dictionary (dict
)
which contains the results of the attempt to clear the policy from the
endpoint.
The output should appear similar to the following:
{
"ancStatus": "success"
}
If no policy has already been associated with the endpoint before the example
is run, an Exception
is raised and output similar to the following should
appear:
Error: mac address is already associated with this policy error associated with mac 00:11:22:33:44:55 (0)
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)