|
| 1 | +# policy_info_switch.py |
| 2 | + |
| 3 | +## Description |
| 4 | + |
| 5 | +Retrieve all policies for one or more switches. |
| 6 | + |
| 7 | +## Example configuration file |
| 8 | + |
| 9 | +``` yaml title="config/policy_info_switch.yaml" |
| 10 | +--- |
| 11 | +config: |
| 12 | + - switch_name: LE1 |
| 13 | + fabric_name: SITE1 |
| 14 | + - switch_name: LE2 |
| 15 | + fabric_name: SITE2 |
| 16 | +``` |
| 17 | +
|
| 18 | +## Example Usage |
| 19 | +
|
| 20 | +The example below uses environment variables for credentials, so requires |
| 21 | +only the `--config` argument. See [Running the Example Scripts] |
| 22 | +for details around specifying credentials from the command line, from |
| 23 | +environment variables, from Ansible Vault, or a combination of these |
| 24 | +credentials sources. |
| 25 | + |
| 26 | +[Running the Example Scripts]: ../setup/running-the-example-scripts.md |
| 27 | + |
| 28 | +``` bash |
| 29 | +export ND_DOMAIN=local |
| 30 | +export ND_IP4=192.168.7.7 |
| 31 | +export ND_PASSWORD=MySecretPassword |
| 32 | +export ND_USERNAME=admin |
| 33 | +./policy_info_switch.py --config config/policy_info_switch.yaml |
| 34 | +# output not shown |
| 35 | +``` |
| 36 | + |
| 37 | +## Example output |
| 38 | + |
| 39 | +### Success |
| 40 | + |
| 41 | +``` bash title="Policies retrieved successfully" |
| 42 | +(ndfc-python) arobel@Allen-M4 examples % ./policy_info_switch.py --config config/s12/policy_info_switch.yaml |
| 43 | +SITE1, LE1, policies: |
| 44 | +``` |
| 45 | + |
| 46 | +``` json |
| 47 | +{ |
| 48 | + "autoGenerated": true, |
| 49 | + "deleted": false, |
| 50 | + "editable": true, |
| 51 | + "entityName": "SWITCH", |
| 52 | + "entityType": "SWITCH", |
| 53 | + "fabricName": "SITE1", |
| 54 | + "generatedConfig": "", |
| 55 | + "id": 21160, |
| 56 | + "ipAddress": "192.168.12.151", |
| 57 | + "modifiedOn": 1758053377477, |
| 58 | + "nvPairs": { |
| 59 | + "MARK_DELETED": "false", |
| 60 | + "POLICY_DESC": "", |
| 61 | + "POLICY_ID": "POLICY-21160", |
| 62 | + "PRIORITY": "10", |
| 63 | + "id": "0" |
| 64 | + }, |
| 65 | + "policyId": "POLICY-21160", |
| 66 | + "priority": 10, |
| 67 | + "resourcesLinked": "", |
| 68 | + "serialNumber": "9WPLALSNXK6", |
| 69 | + "source": "", |
| 70 | + "statusOn": 1758053377477, |
| 71 | + "switchName": "LE1", |
| 72 | + "templateContentType": "PYTHON", |
| 73 | + "templateName": "bgp_lb_id" |
| 74 | +} |
| 75 | +``` |
| 76 | + |
| 77 | +etc... |
| 78 | + |
| 79 | +```bash |
| 80 | +(ndfc-python) arobel@Allen-M4 examples % |
| 81 | +``` |
| 82 | + |
| 83 | +### Failure - Fabric does not exist |
| 84 | + |
| 85 | +``` bash title="Fabric does not exist" |
| 86 | +(ndfc-python) arobel@Allen-M4 examples % ./policy_info_switch.py --config config/s12/policy_info_switch.yaml |
| 87 | +Error retrieving fabric SITE3, switch LE1, policies. Error detail: PolicyInfoSwitch._final_verification: fabric_name SITE3 does not exist on the controller. |
| 88 | +Error retrieving fabric SITE4, switch LE2, policies. Error detail: PolicyInfoSwitch._final_verification: fabric_name SITE4 does not exist on the controller. |
| 89 | +(ndfc-python) arobel@Allen-M4 examples % |
| 90 | +``` |
| 91 | + |
| 92 | +### Failure - Switch does not exist in fabric |
| 93 | + |
| 94 | +``` bash title="Switch does not exist in fabric" |
| 95 | +(ndfc-python) arobel@Allen-M4 examples % ./policy_info_switch.py --config config/s12/policy_info_switch.yaml |
| 96 | +Error retrieving fabric SITE1, switch LE3, policies. Error detail: PolicyInfoSwitch._final_verification: switch_name LE3 not found in fabric SITE1. |
| 97 | +Error retrieving fabric SITE2, switch LE4, policies. Error detail: PolicyInfoSwitch._final_verification: switch_name LE4 not found in fabric SITE2. |
| 98 | +(ndfc-python) arobel@Allen-M4 examples % |
| 99 | +``` |
0 commit comments