I'm trying to restart a jail using the v2 websocket api

Status
Not open for further replies.

eivl

Cadet
Joined
Sep 5, 2016
Messages
6
So in case, this is an XY Problem, I will tell you first what I am trying to do.
I would like to do some jail management from a private discord bot.
The first iteration of this ran the bot directly on the FreeNAS machine and using subprocess call to run the `iocage restart jail` command, but it needed python 3.6 and only 3.7 was installed. so then I thought I could use the API to run the same command.
I am new to using WebSockets, but I am able to connect over the network, I am able to authenticate, I can run some other commands and get a valid response, as an example. `interfaces.websocket_local_ip` returns not authenticated, when I authenticate with the root user and password I get the correct local IP address.


<<<{"msg": "method", "id": "20", "method": "jail.stop", "params": "plex"}
>>>{"msg": "result", "id": "20", "error": {"error": 22, "type": null, "reason": "list index out of range", "trace": {"class": "IndexError",........

I might be using the `jail` commands wrong, method and params looks to my eyes correct based on what i can find on http://freenas.local/api/docs/


jail.stop
Arguments:
{ "title": "jail", "type": [ "string", "null" ] }

Takes a jail and stops it.


Any ideas on how I can solve my problem in another way or how to communicate with the jail part of the v 2.0 API using python and WebSockets? also open for v1.0 suggestions for that matter.
PS: It did feel a bit unsafe to run the python bot as root, so I would be more comfortable with something that I can run inside a jail or over the local network.
 
D

dlavigne

Guest
Were you able to resolve this? If not, it is worth creating a ticket at bugs.freenas.org to determine if it is an API issue or a usage issue.
 
Status
Not open for further replies.
Top