How would you use Python to print out details of the orchestrator? hostname, ip, last update, etc

how would you use Python to print out details of the orchestrator? hostname, ip, last update, etc.

the print will not work, I thought why not try it…s is an object instance not a string that I want.

def run(params={}):
import socket
s = socket.gethostname()
ss = socket.getfqdn()
return {“s”:s}

You can’t print in a python step. The way that step works is we read from standard in / out to get the input/output of the step. Thus, print blows away that stream and breaks the plugin.

You’ll need to just return the objects, and include that output in a later Artifact step.

Now, with all that said, what you’re actually trying to do is interesting, and I’m not entirely sure it will work. That plugin is running in a docker container on the orchestrator. So I’m not sure it will actually return the host name of the host you’re running on. (I’m not sure, I’ve never tried something like that. But I just wanted to throw a word of caution out there that you may not get expect results with that code).

1 Like

I completely forgot about the docker part… it either returned a python object or a docker container name… it was something like ‘3ad28sjdsa’. ha thanks

One more thing here.

You can import logging, and debug using that. So something like:

def run(params={}):
    import logging
    log = logging.getLogger("test")"your object here")

That might come in handy as well.

I don’t believe that there is a way to return this information within a step since the step runs inside a container which would have its own IP address, host name, etc…It would not be those of the orchestrator.

You could perhaps use the SSH plugin and SSH to the orchestrator, then run the commands needed to retrieve this information.

@hayden_redd Out of curiosity what are you trying to accomplish by adding this step? Simply curious if there is something from the product functionality and orchestrator side of things we could look at add instead of using a plugin for this data. Thanks!

1 Like

do you return this or where do you see the data? I tried this.

a way to work in orchestrator health and other details into a workflow. :cowboy_hat_face:

So once you’ve done that, you can ssh into your orchestrator and pull the docker logs for your container with:
sudo docker logs -f <container id>

You get the container ID with:
sudo docker ps -a | grep python