dxlciscopxgridclient.client module

class dxlciscopxgridclient.client.AncClientCategory(pxgrid_client)

Bases: _BaseClientCategory

A client class for interacting with Cisco Adaptive Network Control (ANC) functionality via pxGrid.

Constructor parameters:

Parameters:

pxgrid_client (CiscoPxGridClient) -- The pxGrid client object.

add_anc_status_callback(callback)

Register an object to called back upon when an ANC event is received.

Parameters:

callback (dxlciscopxgridclient.callbacks.AncCallback) -- The callback to register.

apply_endpoint_policy(policy: str, mac_address: str, nas_ip_address: str, session_id: str, nas_port_id: str, ip_address: str, username: str)

Apply a policy to the endpoint using MAC Address, NAS IP Address and other parameters If endpoint does not have an existing policy applied, the return status will be FAILURE with reason "mac address is not associated with a policy".

Parameters:
  • policy (str) -- policy name

  • mac_address (str) -- MAC address of endpoint

  • nas_ip_address (str) -- NAS Ip address of endpoint

  • (optional) (str username) -- id of session

  • (optional) -- port of NAS

  • (optional) -- ip address of endpoint

  • (optional) -- username

Returns:

status object

Return type:

dict

apply_endpoint_policy_by_ip(ip_address, policy_name)

Apply a policy to an endpoint by its IP address.

Parameters:
  • ip_address (str) -- IP address of the endpoint.

  • policy_name (str) -- Name of the policy to apply.

Returns:

Results of the attempt to apply the endpoint policy.

Return type:

dict

apply_endpoint_policy_by_mac(mac_address, policy_name)

Apply a policy to an endpoint by its MAC address.

Parameters:
  • mac_address (str) -- MAC address of the endpoint.

  • policy_name (str) -- Name of the policy to apply.

Returns:

Results of the attempt to apply the endpoint policy. On a successful application, the results should look similar to this:

{
    "macAddress": "00:11:22:33:44:55",
    "operationId": "cise.psarchlab.com:123",
    "policyName": "ANC_Shut",
    "status": "SUCCESS"
}

Return type:

dict

clear_endpoint_policy(mac_address: str, nas_ip_address: str)

Clear endpoint policy by MAC address and NAS IP address

Parameters:
  • mac_address (str) -- MAC address of endpoint

  • nas_ip_address (str) -- NAS IP address of endpoint

Returns:

staus object

Return type:

dict

clear_endpoint_policy_by_mac(mac_address)

Clear the policy for an endpoint by its MAC address.

Parameters:

mac_address (str) -- MAC address of the endpoint.

Returns:

Results of the attempt to clear the endpoint policy. On a successful clear attempt, the results should look similar to this:

{
    "macAddress": "00:11:22:33:44:55",
    "operationId": "cise.psarchlab.com:123",
    "policyName": "ANC_Shut",
    "status": "SUCCESS"
}

Return type:

dict

create_policy(name: str, actions: list)

Creates a policy object

Parameters:

name (str) -- name of the policy

Param:

str list actions: list of actions of the policy

Returns:

the created policy object

Return type:

dict

delete_policy_by_name(name)

Deletes a policy object with the name provided

Parameters:

name (str) -- name of the policy to be deleted

Returns:

{"200": "no content"} if successful, {"204": "no content"} otherwise

get_endpoint_by_mac(mac_address)

Get information for an endpoint by its MAC address.

Parameters:

mac_address (str) -- MAC address of the endpoint.

Returns:

The endpoint information, which should look similar to this:

{
    "macAddress": "00:11:22:33:44:55",
    "policyName": "ANC_Shut"
}

or no content if macAddress not found or has no policies

Return type:

dict

Raises:

Exception -- If no policy has been associated with the endpoint.

get_endpoint_by_nas_ip_address(mac_address: str, nas_ip_address: str)

Get endpoint with MAC address and NAS IP Address If endpoint does not exist, no content is returned

Parameters:
  • mac_address (str) -- MAC address of endpoint

  • nas_ip_address (str) -- nas_ip_address of endpoint

Returns:

The endpoint information

Return type:

dict

get_endpoint_policies()

Gets all endpoints with policies applied using both MAC address and NAS IP address

Returns:

{"endpoints" : list[str]}

get_endpoints()

Gets all endpoints with policies applied

Returns:

{"endpoints" : list[str]}

get_operation_status(operation_id: str)

If operation does not exist, HTTP status "204 No content" will be returned.

Parameters:

operationId (str) -- id of operation

Returns:

status object

Return type:

dict

retrieve_all_policies()

Retrieve information for all ANC policies.

Returns:

The policy information, which should look similar to this:

{
    "ancStatus": "success",
    "ancpolicy": [
        {
            "action": [
                "ShutDown"
            ],
            "name": "shutdown_policy"
        },
        {
            "action": [
                "Quarantine"
            ],
            "name": "quarantine_policy"
        }
    ]
}

Return type:

dict

retrieve_policy_by_name(policy_name)

Retrieve information for an ANC policy by name.

Parameters:

policy_name (str) -- Name of the policy.

Returns:

The policy information, which should look similar to this:

{
    "ancStatus": "success",
    "ancpolicy": [
        {
            "action": [
                "Quarantine"
            ],
            "name": "quarantine_policy"
        }
    ]
}

Return type:

dict

Raises:

Exception -- If the policy name has not been defined.

class dxlciscopxgridclient.client.CiscoPxGridClient(dxl_client)

Bases: Client

The "Cisco pxGrid DXL Client Library" client wrapper class.

Constructor parameters:

Parameters:

dxl_client -- The DXL client to use for communication with the fabric

property anc

Retrieves a client object for use in interacting with Cisco Adaptive Network Control (ANC) functionality via pxGrid.

Returns:

The ANC instance.

Return type:

AncClientCategory

property identity

Retrieves a client object for use in interacting with identity services in Cisco pxGrid.

Returns:

The identity client instance.

Return type:

IdentityClientCategory

class dxlciscopxgridclient.client.IdentityClientCategory(pxgrid_client)

Bases: _BaseClientCategory

A client class for interacting with identity services in Cisco pxGrid.

Constructor parameters:

Parameters:

pxgrid_client (CiscoPxGridClient) -- The pxGrid client object.

add_session_callback(callback)

Register an object to called back upon when a session event is received.

Parameters:

callback (dxlciscopxgridclient.callbacks.IdentitySessionCallback) -- The callback to register.