HPE Morpheus Enterprise
1849819 Members
2345 Online
104044 Solutions
New Discussion

Morpheus API Calls from Python

 
Not applicable

Morpheus API Calls from Python

I use Python to interact with Morpheus for internal and external clients and I wanted an easy way to make calls to the Morpheus API without dealing with Python requests. Enter pymorpheus, an easy Python module to act as a wrapper to the Morpheus API.

If I wanted to get a list of instances with a phrase matching “test”, it’s super easy:

from pymorpheus import MorpheusClient
morpheus = MorpheusClient("https://yoururl", username="youruser", password="yourpass")
results = morpheus.call("get", path="instances", options=[("phrase","testing")])
print(results)

Adding json payloads to POST calls is handled within the same call as well. You can also use a token to authenticate.

7 REPLIES 7
Not applicable

Re: Morpheus API Calls from Python

@jwheeler 's solution will work for user level. If using it in a Python task in Morpheus, you can put pymorpheus into the Additional Packages box of the task.

Not applicable

Re: Morpheus API Calls from Python

Absolutely. Those will be ephemeral for the duration of the task.

Not applicable

Re: Morpheus API Calls from Python

Thanks for sharing! Is the source available anywhere?

Not applicable

Re: Morpheus API Calls from Python

pip install pymorpheus

Not applicable

Re: Morpheus API Calls from Python

Instead of username, password and url, can we use morpheus[‘morpheus’][‘apiAccessToken’] and morpheus[‘morpheus’][‘applianceUrl’] ?

Not applicable

Re: Morpheus API Calls from Python

How do I install pymorpheus?

Not applicable

Re: Morpheus API Calls from Python

As a matter of fact, it is!

It’s just a wrapper to make requests easier to deal with. Not incredibly robust.