Change SNMPv3 passwords for all monitored Brocade SAN switches in a script
This script is a Node.js utility designed to update SNMP authentication and privacy passwords for Brocade FC switch configurations using the public API. It interacts with a REST API to authenticate, retrieve host configurations, and update SNMP passwords for entries that match certain criteria. The script also provides an interactive prompt for bulk or per-entry confirmation before updating.
Detailed Workflow
Command-Line Arguments, the script expects four arguments:
- username: The username for authentication.
- password: The password for authentication.
- snmpPrivPassword: The new SNMP privacy password to set.
- snmpAuthPassword: The new SNMP authentication password to set.
Authentication:
The script sends a POST request to the server's /api/public/v1/auth endpoint to authenticate using the provided username and password.
Upon successful authentication, it retrieves an API key.
Fetching Host Configurations:
The script sends a GET request to the /api/public/v1/hostcfg endpoint to fetch host configurations of the storage class.
It filters the configurations to include only entries that:
Match the provided SSH username.
hw_type is
sanbrcd (Brocade SAN switches)
The device field contains
BROADCOM
Interactive Password Update:
Before iterating, the script asks whether to update all matching entries at once or confirm each one individually:
- If the user chooses bulk mode (y), all matching entries are updated without further prompts.
- If the user chooses per-entry mode (n), the script prompts for confirmation on each switch individually — entering y updates it, n skips it.
- Both snmpPrivPassword and snmpAuthPassword are updated for each confirmed entry via a PUT request to /api/public/v1/hostcfg/.
Usage
Run the script with the following command:
node ./password_change.js <username> <password> <snmpPrivPassword> <snmpAuthPassword>
Example:
node ./password_change.js xormon xormon newPrivPass123 newAuthPass123
Download
password_change-SNMPv3.js.gz