{"id":31937138,"url":"https://github.com/allenrobel/nd-python","last_synced_at":"2025-10-14T08:00:03.194Z","repository":{"id":316162011,"uuid":"1062274596","full_name":"allenrobel/nd-python","owner":"allenrobel","description":"Set of Python classes and example scripts which interact with preliminary tech-preview Nexus Dashboard 4.1 REST API.  This API is subject to change in ND 4.2.","archived":false,"fork":false,"pushed_at":"2025-09-30T18:50:37.000Z","size":207,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-30T20:27:41.979Z","etag":null,"topics":["api","cisco","nd","nexus-dashboard","python","python3","rest","rest-api"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/allenrobel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-23T03:42:22.000Z","updated_at":"2025-09-30T18:49:15.000Z","dependencies_parsed_at":"2025-09-23T04:07:35.039Z","dependency_job_id":"f35bf786-ef6b-46b4-9413-689fb311c858","html_url":"https://github.com/allenrobel/nd-python","commit_stats":null,"previous_names":["allenrobel/nd-python"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/allenrobel/nd-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allenrobel%2Fnd-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allenrobel%2Fnd-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allenrobel%2Fnd-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allenrobel%2Fnd-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/allenrobel","download_url":"https://codeload.github.com/allenrobel/nd-python/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allenrobel%2Fnd-python/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018180,"owners_count":26086307,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","cisco","nd","nexus-dashboard","python","python3","rest","rest-api"],"created_at":"2025-10-14T07:59:59.404Z","updated_at":"2025-10-14T08:00:03.188Z","avatar_url":"https://github.com/allenrobel.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nd-python\n\nThis repository contains Python classes and example scripts for interacting\nwith Cisco's Nexus Dashboard 4.1 REST API.\n\nIf you are more interested in Nexus Dashboard 3.x REST API, see the following repository:\n\n[ndfc-python](https://github.com/allenrobel/ndfc-python)\n\nA basic quick start guide to this repository follows.\n\n## 1. Create a $HOME/repos directory into which we'll clone nd-python\n\n```bash\nmkdir $HOME/repos\n```\n\n## 2. Clone the nd-python repository\n\n```bash\ncd $HOME/repos\ngit clone https://github.com/allenrobel/nd-python.git\n```\n\n## 3. Install Python if it is not already installed\n\n[python.org Downloads](https://www.python.org/downloads/)\n\n## 4. Create a virtual environment\n\n```bash\ncd $HOME/repos/nd-python\n# If python is in your path\npython3 -m venv .venv --prompt nd-python\n# If python is NOT in your path, and it was installed on MacOS\n/Library/Frameworks/Python.framework/Versions/3.13/bin/python3 -m venv .venv --prompt nd-python\n```\n\n## 5. Source the virtual environment\n\n- `source .venv/bin/activate`\n\n```bash\nsource .venv/bin/activate\n```\n\n## 6. upgrade pip\n\n```bash\npip install --upgrade pip\n```\n\n## 7. Install uv\n\n```bash\npip install uv\n```\n\n## 8. Use uv to install the other dependencies\n\n```bash\nuv sync\n```\n\n## 9. Set required environment variables\n\n```bash\n# Edit $HOME/repos/nd-python/env/02-nd\n# Change the following to match your environment\n# ND_IP4=\u003cyour Nexus Dashboard IPv4 address\u003e\n# ND_USERNAME=\u003cyour Nexus Dashboard username, typically admin\u003e\n# ND_PASSWORD=\u003cyour Nexus Dashboard password for ND_USERNAME\u003e\n# NXOS_USERNAME=\u003cThe username of your Nexus switches, typically admin\u003e\n# NXOS_PASSWORD=\u003cThe password of your Nexus switches associated with NXOS_USERNAME\u003e\n#\n# NOTE: For better security, follow the steps at Github Pages link at the top of this file.\n#\n# Once 02-nd is edited, source the following file (it, in turn, sources the other files)\n```\n\n```bash\nsource $HOME/repos/nd-python/env/env\n```\n\n## 10. Optionally, enable logging\n\n```bash\nexport ND_LOGGING_CONFIG=$HOME/repos/nd-python/lib/nd_python/logging_config.json\n```\n\n## 11. Run a script that does not take any arguments\n\nLet's try the login script since it does not require any arguments.\n\n```bash\ncd $HOME/repos/nd-python\nsource .venv/bin/activate\nsource env/env\ncd examples\n./login.py\n```\n\n## 12. Potential Ansible locale error\n\nWe support the optional use of Ansible Vault for credentials. Because of this,\nyou may see the following error.\n\n```bash\nERROR: Ansible requires the locale encoding to be UTF-8; Detected ISO8859-1\n```\n\nYou can fix it by updating a couple environment variables.\n\nOn macOS\n\n```bash\nexport LC_ALL=en_US.UTF-8\nexport LANG=en_US.UTF-8\n```\n\nOn Ubuntu\n\nCheck if the locales are installed.\n\n```bash\nlocale -a | grep -i utf\n```\n\nExample\n\n```bash\n(nd-python) arobel@glide:~/repos/nd-python$ locale -a | grep -i utf\nC.utf8\nen_US.utf8\n(nd-python) arobel@glide:~/repos/nd-python$\n```\n\nIf not, generate them.\n\n```bash\nsudo locale-gen en_US.UTF-8\n```\n\nVerify your locale is set.  If any of the following environment variables are set to something else,\nchange them with `export VAR=\"en_US.UTF-8\"`\n\n```bash\nlocale\n```\n\nExample\n\n```bash\n(nd-python) arobel@glide:~/repos/nd-python$ locale\nLANG=en_US.UTF-8\nLANGUAGE=\nLC_CTYPE=\"en_US.UTF-8\"\nLC_NUMERIC=\"en_US.UTF-8\"\nLC_TIME=\"en_US.UTF-8\"\nLC_COLLATE=\"en_US.UTF-8\"\nLC_MONETARY=\"en_US.UTF-8\"\nLC_MESSAGES=\"en_US.UTF-8\"\nLC_PAPER=\"en_US.UTF-8\"\nLC_NAME=\"en_US.UTF-8\"\nLC_ADDRESS=\"en_US.UTF-8\"\nLC_TELEPHONE=\"en_US.UTF-8\"\nLC_MEASUREMENT=\"en_US.UTF-8\"\nLC_IDENTIFICATION=\"en_US.UTF-8\"\nLC_ALL=\n(nd-python) arobel@glide:~/repos/nd-python$\n```\n\n## 13. Run a script that requires a config file\n\nMany of the scripts take a config file.\n\nExample config files are located in `$HOME/repos/nd-python/examples/config/*.yaml`\n\nLet's edit a config that saves default switch credentials.\n\n```bash\ncd $HOME/repos/nd-python\nsource .venv/bin/activate\nsource env/env\ncd examples\nvi $HOME/repos/nd-python/examples/config/credentials_default_switch_save.yaml\n```\n\nBelow is the content of this file.\n\n```yaml\n---\nswitch_password: mySwitchPassword\nswitch_username: admin\n```\n\nModify this to match your environment by changing each item's parameters.\n\nSave the file and then execute the associated script.\n\nFirst, we'll have a look at the help facility that all scripts provide.\n\n```bash\ncd $HOME/repos/nd-python/examples\n./credentials_default_switch_save.py --help\n```\n\nExample\n\n```bash\ncd $HOME/repos/nd-python/examples\n(nd-python) arobel@Allen-M4 examples % ./credentials_default_switch_save.py --help\nusage: credentials_default_switch_save.py [-h] [-v ANSIBLE_VAULT] -c CONFIG [-l {INFO,WARNING,ERROR,DEBUG}] [--nd-domain ND_DOMAIN] [--nd-ip4 ND_IP4] [--nd-password ND_PASSWORD] [--nd-username ND_USERNAME]\n\nDESCRIPTION: Save default switch credentials to the controller.\n\noptions:\n  -h, --help            show this help message and exit\n\nOPTIONAL ARGS:\n  -v, --ansible-vault ANSIBLE_VAULT\n                        Absolute path to an Ansible Vault. e.g. /home/myself/.ansible/vault.\n  --nd-domain ND_DOMAIN\n                        Login domain for the Nexus Dashboard controller. If missing, the environment variable ND_DOMAIN or Ansible Vault is used.\n  --nd-ip4 ND_IP4       IPv4 address for the Nexus Dashboard controller. If missing, the environment variable ND_IP4 or Ansible Vault is used.\n  --nd-password ND_PASSWORD\n                        Password for the Nexus Dashboard controller. If missing, the environment variable ND_PASSWORD or Ansible Vault is used.\n  --nd-username ND_USERNAME\n                        Username for the Nexus Dashboard controller. If missing, the environment variable ND_USERNAME or Ansible Vault is used.\n\nMANDATORY ARGS:\n  -c, --config CONFIG   Absolute path to a YAML configuration file. e.g. /home/myself/myfile.yaml\n\nDEFAULT ARGS:\n  -l, --loglevel {INFO,WARNING,ERROR,DEBUG}\n                        Logging level\n(nd-python) arobel@Allen-M4 examples %\n```\n\nFrom above, we see that we can override, on a script-by-script basis, the environment variables we configured earlier.\n\nWe also see that the `--config` argument is mandatory.  This points to the config file we just edited.  Let's use our\nexisting environment variables and provide only the `--config` argument.\n\nLet's first disable debugging for shorter output.\n\n```bash\nunset ND_LOGGING_CONFIG\n```\n\nNow let's run the script.\n\n```bash\n./credentials_default_switch_save.py --config $HOME/repos/nd-python/examples/config/credentials_default_switch_save.yaml\n```\n\nExample\n\n```bash\n(nd-python) arobel@Allen-M4 examples % ./credentials_default_switch_save.py --config config/credentials_default_switch_save.yaml\nDefault switch credentials saved for user admin\n(nd-python) arobel@Allen-M4 examples %\n```\n\n## 14. Script Documentation\n\nDocumentation is currently under construction.  We'll add a link here once it's ready.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallenrobel%2Fnd-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fallenrobel%2Fnd-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallenrobel%2Fnd-python/lists"}