{"id":21636123,"url":"https://github.com/bigevilbeard/dnac-device-info","last_synced_at":"2025-04-11T15:50:20.008Z","repository":{"id":50205761,"uuid":"139131173","full_name":"bigevilbeard/dnac-device-info","owner":"bigevilbeard","description":"Python script using DNAC APIs","archived":false,"fork":false,"pushed_at":"2021-06-01T22:22:28.000Z","size":7,"stargazers_count":13,"open_issues_count":1,"forks_count":18,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T11:52:24.422Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bigevilbeard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-29T09:40:00.000Z","updated_at":"2021-08-01T13:59:13.000Z","dependencies_parsed_at":"2022-09-24T08:00:22.294Z","dependency_job_id":null,"html_url":"https://github.com/bigevilbeard/dnac-device-info","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigevilbeard%2Fdnac-device-info","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigevilbeard%2Fdnac-device-info/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigevilbeard%2Fdnac-device-info/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigevilbeard%2Fdnac-device-info/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bigevilbeard","download_url":"https://codeload.github.com/bigevilbeard/dnac-device-info/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248434409,"owners_count":21102830,"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","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":[],"created_at":"2024-11-25T03:30:06.005Z","updated_at":"2025-04-11T15:50:19.987Z","avatar_url":"https://github.com/bigevilbeard.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Getting started\n\nThese instructions will get you a copy of the Python code for a Python script to gather information of of the network devices a DNAC controller knows about and their attributes.\n\n## Requirements\n\n- Python 3.6 or higher\n- \"git\" command line tools\n- Homebrew (Mac OS X)\n\n## For Mac OS X Installation\n\n```\ngit installation - https://git-scm.com/download/mac\n```\n```\nhomebrew installation - ruby -e \"$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)\"\n```\n```\nPython 3.6 installation - https://www.python.org/downloads/release/python-364/\nPython pip installation\ncurl -o get-pip.py https://bootstrap.pypa.io/get-pip.py\nsudo python get-pip.py\n```\nCommand Line Developer Tools Installation. After running command, complete installation using the GUI.\n```          \nxcode-select --install\n```\n\n## For Windows Installation\n```\ngit installation - https://git-scm.com/download/win\nPython 3.6 installation - https://www.python.org/downloads/release/python-364/\nBe sure to check box for \"Add Python to PATH\" during the installer\n```\n\n## 'GIT' this code\n\nAll of the code and examples for this lesson is located in the 'add me here' directory. Clone and access it with the following commands:\n\n```\ngit clone https://github.com/bigevilbeard/dnac-device-info\ncd dnac-device-info\n```\nUse pip to install the necessary requirements\n```\npip install -r requirements.txt\n```\n\n### Code features\n\nThe Python script uses the DNCA APIs to get device information. The APIs provides a list of all of the network devices the DNCA controller knows about and all of their attributes. For example hostname, serial platform type, software version, uptime etc.  You can either get all of the devices, or a subset. This is printed out using PrettyTable, this is a simple Python library designed to make it quick and easy to represent tabular data in visually appealing ASCII tables. It was inspired by the ASCII tables used in the PostgreSQL shell psql. PrettyTable allows for selection of which columns are to be printed, independent alignment of columns (left or right justified or centred) and printing of “sub-tables” by specifying a row range.\n\n## DNAC API reference\n\nIf you look at the Python code for our script, you will see the API calls used.\n\n- `https://{}/api/system/v1/auth/token` Gets and encapsulates user identity and role information as a single value that RBAC-governed APIs use to make access-control decisions. This returns a token as a response in a JSON object. You can re-use it for any request that may need it directly (such as the Python script here)\n- `https://{}/api/v1/network-device` Gets the list of first 500 network devices sorted lexicographically based on hostname. It can be filtered using management IP address, mac address, hostname and location name. If id param is provided, it will be returning the list of network-devices for the given id's and other request params will be ignored. In case of autocomplete request, returns the list of specified attributes.\n\n## Running the code\n```\npython get_dnac_devices.py\n+-------------------+----------------+---------------+------------------+-----------------------+\n|      Hostname     |  Platform Id   | Software Type | Software Version |        Up Time        |\n+-------------------+----------------+---------------+------------------+-----------------------+\n| asr1001-x.abc.inc |   ASR1001-X    |     IOS-XE    |      16.6.1      | 168 days, 18:22:47.35 |\n|  cat_9k_1.abc.inc |   C9300-24UX   |     IOS-XE    |      16.6.1      | 168 days, 19:31:10.69 |\n|  cat_9k_2.abc.inc |   C9300-24UX   |     IOS-XE    |      16.6.1      | 168 days, 19:07:32.50 |\n|   cs3850.abc.inc  | WS-C3850-48U-E |     IOS-XE    |     16.6.2s      |  165 days, 6:07:48.75 |\n+-------------------+----------------+---------------+------------------+-----------------------+\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigevilbeard%2Fdnac-device-info","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbigevilbeard%2Fdnac-device-info","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigevilbeard%2Fdnac-device-info/lists"}