policy_info_switch.py¶
Description¶
Retrieve all policies for one or more switches.
Example configuration file¶
config/policy_info_switch.yaml
---
config:
- switch_name: LE1
fabric_name: SITE1
- switch_name: LE2
fabric_name: SITE2
Example Usage¶
The example below uses environment variables for credentials, so requires
only the --config
argument. See Running the Example Scripts
for details around specifying credentials from the command line, from
environment variables, from Ansible Vault, or a combination of these
credentials sources.
export ND_DOMAIN=local
export ND_IP4=192.168.7.7
export ND_PASSWORD=MySecretPassword
export ND_USERNAME=admin
./policy_info_switch.py --config config/policy_info_switch.yaml
# output not shown
Example output¶
Success¶
Policies retrieved successfully
(ndfc-python) arobel@Allen-M4 examples % ./policy_info_switch.py --config config/s12/policy_info_switch.yaml
SITE1, LE1, policies:
{
"autoGenerated": true,
"deleted": false,
"editable": true,
"entityName": "SWITCH",
"entityType": "SWITCH",
"fabricName": "SITE1",
"generatedConfig": "",
"id": 21160,
"ipAddress": "192.168.12.151",
"modifiedOn": 1758053377477,
"nvPairs": {
"MARK_DELETED": "false",
"POLICY_DESC": "",
"POLICY_ID": "POLICY-21160",
"PRIORITY": "10",
"id": "0"
},
"policyId": "POLICY-21160",
"priority": 10,
"resourcesLinked": "",
"serialNumber": "9WPLALSNXK6",
"source": "",
"statusOn": 1758053377477,
"switchName": "LE1",
"templateContentType": "PYTHON",
"templateName": "bgp_lb_id"
}
etc...
Failure - Fabric does not exist¶
Fabric does not exist
(ndfc-python) arobel@Allen-M4 examples % ./policy_info_switch.py --config config/s12/policy_info_switch.yaml
Error retrieving fabric SITE3, switch LE1, policies. Error detail: PolicyInfoSwitch._final_verification: fabric_name SITE3 does not exist on the controller.
Error retrieving fabric SITE4, switch LE2, policies. Error detail: PolicyInfoSwitch._final_verification: fabric_name SITE4 does not exist on the controller.
(ndfc-python) arobel@Allen-M4 examples %
Failure - Switch does not exist in fabric¶
Switch does not exist in fabric
(ndfc-python) arobel@Allen-M4 examples % ./policy_info_switch.py --config config/s12/policy_info_switch.yaml
Error retrieving fabric SITE1, switch LE3, policies. Error detail: PolicyInfoSwitch._final_verification: switch_name LE3 not found in fabric SITE1.
Error retrieving fabric SITE2, switch LE4, policies. Error detail: PolicyInfoSwitch._final_verification: switch_name LE4 not found in fabric SITE2.
(ndfc-python) arobel@Allen-M4 examples %