Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]Add servicies to start/stop/restart #30

Open
Rihan9 opened this issue Mar 3, 2024 · 4 comments
Open

[Feature]Add servicies to start/stop/restart #30

Rihan9 opened this issue Mar 3, 2024 · 4 comments
Labels
enhancement New feature or request planned To be implemented in future release

Comments

@Rihan9
Copy link

Rihan9 commented Mar 3, 2024

Is your feature request related to a problem? Please describe.

Hi, I would like to start/stop but mostly restart my containers.
This is because it sometimes happens, for example, that Zigbee2mqtt needs a restart when some devices stop responding correctly.

The best thing would be if the "recreate" function were also included, allowing updates to the containers directly from Home Assistant.

Describe the solution you'd like

a bunch of services:

  • portainer.start
  • portainer.stop
  • portainer.restart
  • portainer.recreate

all of them should accept the sensor entity created by this integration to know which container should be the target.

Additional context

portainer documentation: https://app.swaggerhub.com/apis/portainer/portainer-ce/2.19.4
the docker endpoints shold be wrapped in this portainer endpoint:
https://[[HOSTNAME]]/api/endpoints/2/docker/containers/

  • portainer.start documentation: https://docs.docker.com/engine/api/v1.41/#tag/Container/operation/ContainerStart
  • portainer.stop documentation: https://docs.docker.com/engine/api/v1.41/#tag/Container/operation/ContainerStop
  • portainer.restart documentation: https://docs.docker.com/engine/api/v1.41/#tag/Container/operation/ContainerRestart
  • portainer.start documentation: https://docs.docker.com/engine/api/v1.41/#tag/Container/operation/ContainerStart
  • portainer.recreate:
    this is not a direct api call but a pipeline of it. Following an example:
    • POST: https://[[HOSTNAME]]/api/endpoints/2/docker/images/create?fromImage=lscr.io%2Flinuxserver%2Fduckdns:latest
      payload: {"fromImage":"lscr.io/linuxserver/duckdns:latest"}
    • POST:
      https://[[HOSTNAME]]/api/endpoints/2/docker/containers/0c2e56f5a2541ef1a4967fdc98d10c5770779511b1e54edce2fe4ee85ba02a01/stop
      payload: empty
    • POST: https://[[HOSTNAME]]/api/endpoints/2/docker/containers/0c2e56f5a2541ef1a4967fdc98d10c5770779511b1e54edce2fe4ee85ba02a01/rename?name=%2FDuckDns-old
      payload: {}
    • POST: https://[[HOSTNAME]]/api/endpoints/2/docker/containers/create?name=DuckDns
      payload: way too long. I think is the dump of the current image. I think this payload can be derived from the "config" section of this service: https://docs.docker.com/engine/api/v1.41/#tag/Container/operation/ContainerInspect.
      response: { "Id": "54f592b3e7ce49afe649bb0cf7aafbb0a00113233e6eb0535b2abbc7e5c55305", "Portainer": { "ResourceControl": { "Id": 294, "ResourceId": "54f592b3e7ce49afe649bb0cf7aafbb0a00113233e6eb0535b2abbc7e5c55305", "SubResourceIds": [], "Type": 1, "UserAccesses": [ { "UserId": 1, "AccessLevel": 1 } ], "TeamAccesses": [], "Public": false, "AdministratorsOnly": false, "System": false } }, "Warnings": [] }
    • POST: https://[[HOSTNAME]]/api/endpoints/2/docker/networks/my-bridge/connect
      payload: {"Container":"54f592b3e7ce49afe649bb0cf7aafbb0a00113233e6eb0535b2abbc7e5c55305"}
    • POST: https://[[HOSTNAME]]/api/endpoints/2/docker/containers/54f592b3e7ce49afe649bb0cf7aafbb0a00113233e6eb0535b2abbc7e5c55305/start
      payload: {}
@Rihan9 Rihan9 added the enhancement New feature or request label Mar 3, 2024
@anktababa
Copy link

That would be amazing.
I was looking for a creating a script to restart a container and found this integration. Very good for monitoring but stop/start/restart can be perfect

Thanks

Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the stale label Mar 23, 2024
Copy link

This issue was closed because it has been stalled for 5 days with no activity.

@tomaae tomaae reopened this Mar 31, 2024
@tomaae tomaae added planned To be implemented in future release and removed stale labels Mar 31, 2024
@jghaanstra
Copy link

Hi, is this still a work in progress or has development stopped?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request planned To be implemented in future release
Projects
None yet
Development

No branches or pull requests

4 participants