- Community Home
- >
- Networking
- >
- IMC
- >
- HP IMC - Restful API example
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2021 12:52 AM - last edited on 08-31-2021 12:36 AM by support_s
08-24-2021 12:52 AM - last edited on 08-31-2021 12:36 AM by support_s
HP IMC - Restful API example
Hello,
I'm trying to access HP's restful API via scripting and I havn't had any luck. I can access the real-time locate fuction if I use a browser manually; but I'm not going to do that 10,000 an hour - hence why I want to script it.
showbox So far I can't get it to work and HP support doesn't help. I was wondering if there was a working example of accessing the eAPI via CLI(curl/python) out there? I'm speed test hoping to copy/modify it.
Thank you
- Tags:
- imc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2021 02:19 AM
08-24-2021 02:19 AM
Re: HP IMC - Restful API example
Hello,
Please have a look at pyhpeimc, a native Python library for iMC that you can use to easily create your own scripts to interact with iMC via API. I've done this successfully with my lab installations numerous times and it's quite easy - the functions themselves that you can use all provide an example of how to implement them, and while far from all API features are covered by the libraries, it should be easy enough to use the existing ones as a kind of template to create others for your own needs.
https://github.com/HPENetworking/PYHPEIMC
Here is an extract of the comments on get_all_devs function that explains how you could make use of that function:
"""Takes string input of IP address to issue RESTUL call to HP IMC\n
:param auth: requests auth object #usually auth.creds from auth pyhpeimc.auth.class
:param url: base url of IMC RS interface #usually auth.url from pyhpeimc.auth.authclass
:param network_address: str IPv4 Network Address
:param category: str or int corresponding to device category (0=router, 1=switches, see API docs for other examples)
:return: dictionary of device details
:rtype: dict
>>> from pyhpeimc.auth import *
>>> from pyhpeimc.plat.device import *
>>> auth = IMCAuth("http://", "10.101.0.203", "8080", "admin", "admin")
>>> dev_list = get_all_devs( auth.creds, auth.url, network_address= '10.11.')
>>> assert type(dev_list) is list
>>> assert 'sysName' in dev_list[0]
"""
Hope that helps!
Justin
Working @ HPE