04-15-2020 04:51 PM
Trying to put together a script to export list of all service profiles/ user labels associated with all servers in multiple UCS domains to an excel sheet.
Any input is appreciated !!
04-16-2020 02:41 AM
Based on your question, I made the following script:
https://github.com/msdaniluk/ucs_tools/tree/master/ucsmsdk_get_sp
1. Download the repository from github
2. Go to the downloaded directory and install requirements (important ones: pandas, ucsmsdk)
pip install -r requirements.txt
3. Edit the domains.py file with your domains information. The info is preserved in a list of dicts, where each element in the list is a domain. Note: the domain name can be anything you define, and it will be used as a name for the xls sheet. Each domain = different excel sheet.
ucs_domains_list = [ {'name': '', 'ip': '', 'username': '', 'password': ''} ]
4.1 (Optionally) In the service_profile.py, modify the name of the xls file to be generated:
def main(): for domain in ucs_domains_list: sp_list = get_sp_from_domain(domain) convert_sp_list_to_excel(sp_list=sp_list, xls_file_name='file.xls', sheet_name=domain['name'])
4.2 (Optionally) In the service_profile.py, uncomment (delete #) print line if you want to also print the SP:
def convert_sp_list_to_excel(sp_list, xls_file_name, sheet_name): # convert to Pandas DF and export to excel df = pd.DataFrame.from_records(sp_list, columns=['SP Name', 'Type', 'Assigned State', 'Associated State'],) # print(df) df.to_excel(xls_file_name, sheet_name=sheet_name)
5. Run the script. Note: this is how output looks like if you uncomment the print.
(venv) sd@ubuntu:~$ python service_profile.py SP Name Type Assigned State Associated State 0 C200-Local-Boot-Template initial-template unassigned unassociated 1 C200-Local-Boot-SRV1 instance assigned associated
...
6. File is generated.
Cheers,
Sergiu
04-17-2020 08:18 PM
Thats awesome ! thanks for your response.
Was wondering if this can be done using Cisco UCS Powertool , powershell as well ?
I just started learning programming languages
04-21-2020 08:12 AM
Hello @codejunkie19479
Welcome to the fascinating world of programmability ^_^
I did not used Powershell for automation so far, so I am not really sure about all of capabilities it has, but most likely there is a way to generate same result.
Regards,
Sergiu
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide