Skip to content

Commit

Permalink
Updating docs for 51e1a5c
Browse files Browse the repository at this point in the history
  • Loading branch information
harrison-ahearn committed Jul 16, 2024
1 parent 392605d commit d5a25d5
Show file tree
Hide file tree
Showing 89 changed files with 5,644 additions and 17,972 deletions.
32 changes: 15 additions & 17 deletions pydoc/_sources/basicancapplyendpointpolicybyipexample.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ Prerequisites
this example. For an example on creating a simulated session for testing, see
the Cisco RADIUS Simulator command examples in
:doc:`basicidentitysessionnotificationexample`.
* An ANC policy named ``quarantine_policy`` has been configured. The policy
* An ANC policy named ``ANC_Shut`` has been configured. The policy
could be created by logging into the ISE web interface and performing the
following steps:

* Navigate to **Operations** |rarr| **Adaptive Network Control** |rarr|
**Policy List**.
* On the **List** screen, click on the **Add** button.
* On the **List** |rarr| **New** screen, enter ``quarantine_policy`` in the
**name** field, select ``QUARANTINE`` in the **Action** field, and press
* On the **List** |rarr| **New** screen, enter ``ANC_Shut`` in the
**name** field, select ``SHUT_DOWN`` in the **Action** field, and press
the **Submit** button.

Configuration
Expand All @@ -41,7 +41,7 @@ Update the following line in the sample:
HOST_IP = "<SPECIFY_IP_ADDRESS>"
To specify the IP address of an endpoint for which to apply the
``quarantine_policy``. For example:
``ANC_Shut``. For example:

.. code-block:: python
Expand All @@ -64,29 +64,30 @@ the following:
.. code-block:: json
{
"ancStatus": "success"
"ipAddress": "192.168.1.1",
"operationId": "cise.psarchlab.com:149",
"policyName": "ANC_Shut",
"status": "SUCCESS"
}
The received results are displayed.

If the ``quarantine_policy`` has already been associated with the endpoint
before the example is run, an ``Exception`` should be raised and output similar
If the ``ANC_Shut`` has already been associated with the endpoint
before the example is run, output similar
to the following should appear:

.. parsed-literal::
Error: mac address is already associated with this policy error associated with ip 192.168.1.1 (0)
If the ``quarantine_policy`` has not been defined before the example is run, an
``Exception`` should be raised and output similar to the following should
If the ``ANC_Shut`` has not been defined before the example is run, output similar to the following should
appear:

.. parsed-literal::
Error: Policy is not configured error associated with ip 192.168.1.1 (0)
If no session has been established for an endpoint which corresponds to the IP
address, an ``Exception`` should be raised and output similar to the following
If no session has been established for an endpoint which corresponds to the IP, output similar to the following
should appear:

.. parsed-literal::
Expand Down Expand Up @@ -117,16 +118,13 @@ The majority of the sample code is shown below:
try:
# Invoke 'apply endpoint policy by IP' method on service
resp_dict = client.anc.apply_endpoint_policy_by_ip(HOST_IP,
"quarantine_policy")
"ANC_Shut")
# 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 should be raised if the 'quarantine_policy' has already
# been applied to the endpoint, the 'quarantine_policy' has not been
# created, or if no session has been established for the endpoint.
print(str(ex))
Expand All @@ -136,8 +134,8 @@ will be used to communicate with Cisco pxGrid.

Next, the :meth:`dxlciscopxgridclient.client.AncClientCategory.apply_endpoint_policy_by_ip`
method is invoked with the IP address of the endpoint for which to apply the
``quarantine_policy``.
``ANC_Shut``.

The final step is to display the contents of the returned dictionary (``dict``)
which contains the results of the attempt to apply the ``quarantine_policy``
which contains the results of the attempt to apply the ``ANC_Shut``
to the endpoint.
32 changes: 17 additions & 15 deletions pydoc/_sources/basicancapplyendpointpolicybymacexample.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ Prerequisites
pxGrid.
* The Python client has been authorized to perform ``DXL Cisco pxGrid Queries``
(see :doc:`pxgridauth`).
* An ANC policy named ``quarantine_policy`` has been configured. The policy
* An ANC policy named ``ANC_Shut`` has been configured. The policy
could be created by logging into the Cisco Identity Services Engine (ISE) web
interface and performing the following steps:

* Navigate to **Operations** |rarr| **Adaptive Network Control** |rarr|
**Policy List**.
* On the **List** screen, click on the **Add** button.
* On the **List** |rarr| **New** screen, enter ``quarantine_policy`` in the
**name** field, select ``QUARANTINE`` in the **Action** field, and press
* On the **List** |rarr| **New** screen, enter ``ANC_Shut`` in the
**name** field, select ``SHUT_DOWN`` in the **Action** field, and press
the **Submit** button.

Configuration
Expand All @@ -36,7 +36,7 @@ Update the following line in the sample:
HOST_MAC = "<SPECIFY_MAC_ADDRESS>"
To specify the MAC address of an endpoint for which to apply the
``quarantine_policy``. For example:
``ANC_Shut``. For example:

.. code-block:: python
Expand All @@ -59,21 +59,23 @@ the following:
.. code-block:: json
{
"ancStatus": "success"
"macAddress": "00:11:22:33:44:55",
"operationId": "cise.psarchlab.com:149",
"policyName": "ANC_Shut",
"status": "SUCCESS"
}
The received results are displayed.

If the ``quarantine_policy`` has already been associated with the endpoint
before the example is run, an ``Exception`` is raised and output similar to the
If the ``ANC_Shut`` has already been associated with the endpoint
before the example is run, output similar to the
following should appear:

.. parsed-literal::
Error: mac address is already associated with this policy error associated with mac 00:11:22:33:44:55 (0)
If the ``quarantine_policy`` has not been defined before the example is run, an
``Exception`` is raised and output similar to the following should appear:
If the ``ANC_Shut`` has not been defined before the example is run, output similar to the following should appear:

.. parsed-literal::
Expand Down Expand Up @@ -101,16 +103,16 @@ The majority of the sample code is shown below:
client = CiscoPxGridClient(dxl_client)
try:
# Invoke 'get endpoint by MAC' method on service
resp_dict = client.anc.get_endpoint_by_mac(HOST_MAC)
# Invoke 'apply endpoint policy by MAC' method on service
resp_dict = client.anc.apply_endpoint_policy_by_mac(
HOST_MAC,
"ANC_Shut")
# 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 should be raised if a policy has not already been
# associated with the endpoint.
print(str(ex))
Expand All @@ -120,8 +122,8 @@ will be used to communicate with Cisco pxGrid.

Next, the :meth:`dxlciscopxgridclient.client.AncClientCategory.apply_endpoint_policy_by_mac`
method is invoked with the MAC address of the endpoint for which to apply the
``quarantine_policy``.
``ANC_Shut``.

The final step is to display the contents of the returned dictionary (``dict``)
which contains the results of the attempt to apply the ``quarantine_policy``
which contains the results of the attempt to apply the ``ANC_Shut``
to the endpoint.
131 changes: 131 additions & 0 deletions pydoc/_sources/basicancapplyendpointpolicyexample.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
Basic Apply ANC Endpoint Policy Example
======================================================

.. include:: <isonum.txt>

This sample applies a Cisco Adaptive Network Control (ANC) policy to an
endpoint via DXL and Cisco pxGrid. The sample identifies the endpoint by its
MAC address, NAS IP address and other parameters.

Prerequisites
*************

* The samples configuration step has been completed (see :doc:`sampleconfig`).
* The DXL fabric to which the client will connect has been bridged to Cisco
pxGrid.
* The Python client has been authorized to perform ``DXL Cisco pxGrid Queries``
(see :doc:`pxgridauth`).
* An ANC policy named ``ANC_Shut`` has been configured. The policy
could be created by logging into the Cisco Identity Services Engine (ISE) web
interface and performing the following steps:

* Navigate to **Operations** |rarr| **Adaptive Network Control** |rarr|
**Policy List**.
* On the **List** screen, click on the **Add** button.
* On the **List** |rarr| **New** screen, enter ``ANC_Shut`` in the
**name** field, select ``SHUT_DOWN`` in the **Action** field, and press
the **Submit** button.

Configuration
*************

Update the following lines in the sample:

.. code-block:: python
MAC_ADDRESS = "<INSERT_MAC_HERE>"
NAS_IP_ADDRESS = "<INSERT_NAS_IP_HERE>"
SESSION_ID = "<INSERT_SESSIONID_HERE>"
NAS_PORT_ID = None # "<OPTIONAL INSERT HERE>"
IP_ADDRESS = None # "<OPTIONAL INSERT HERE>"
USERNAME = None # "<OPTIONAL INSERT HERE>"
Note that the last 3 lines are optional parameters.

Running
*******

To run this sample execute the
``sample/basic/basic_anc_apply_endpoint_policy.py`` script as
follows:

.. parsed-literal::
python sample/basic/basic_anc_apply_endpoint_policy.py
If the policy can be applied successfully, the output should appear similar to
the following:

.. code-block:: json
{
"macAddress": "00:11:22:33:44:55",
"operationId": "cise.psarchlab.com:149",
"policyName": "ANC_Shut",
"status": "SUCCESS"
}
The received results are displayed.

If the ``ANC_Shut`` has already been associated with the endpoint
before the example is run, output similar to the
following should appear:

.. parsed-literal::
Error: mac address is already associated with this policy error associated with mac 00:11:22:33:44:55 (0)
If the ``ANC_Shut`` has not been defined before the example is run, output similar to the following should appear:

.. parsed-literal::
Error: Policy is not configured error associated with mac 00:11:22:33:44:55 (0)
Details
*******

The majority of the sample code is shown below:

.. code-block:: python
MAC_ADDRESS = "<INSERT_MAC_HERE>"
NAS_IP_ADDRESS = "<INSERT_NAS_IP_HERE>"
SESSION_ID = "<INSERT_SESSIONID_HERE>"
NAS_PORT_ID = "<OPTIONAL INSERT HERE>"
IP_ADDRESS = "<OPTIONAL INSERT HERE>"
USERNAME = "<OPTIONAL INSERT HERE>"
# 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 'retrieve policy by name' method on service
resp_dict = client.anc.apply_endpoint_policy("ANC_Shut", MAC_ADDRESS, NAS_IP_ADDRESS, NAS_PORT_ID, IP_ADDRESS, USERNAME)
# 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:
print(str(ex))
Once a connection is established to the DXL fabric, a
:class:`dxlciscopxgridclient.client.CiscoPxGridClient` instance is created which
will be used to communicate with Cisco pxGrid.

Next, the :meth:`dxlciscopxgridclient.client.AncClientCategory.apply_endpoint_policy`
method is invoked with the endpoint information for which to apply the
``ANC_Shut``.

The final step is to display the contents of the returned dictionary (``dict``)
which contains the results of the attempt to apply the ``ANC_Shut``
to the endpoint.
Loading

0 comments on commit d5a25d5

Please sign in to comment.