diff --git a/portainer.py b/portainer.py index 3c86bb2..5b923f8 100755 --- a/portainer.py +++ b/portainer.py @@ -29,6 +29,9 @@ parser.add_argument("--start-containers", "-X", action="store_true", help="Stop parser.add_argument("--delete-stack", "-d", action="store_true", help="Delete stack") parser.add_argument("--update-status", "-S", action="store_true", help="Update status") parser.add_argument("--get-stack", metavar="NAME_OR_ID", help="Get stack by name or numeric id") +parser.add_argument("--action", "-a", type=str, default=None, help="Action to perform") + + parser.add_argument("--autostart", "-a", action="store_true", help="Auto-start created stacks") parser.add_argument("--start-stack", "-x", action='store_true') parser.add_argument("--stop-stack", "-o", action='store_true') @@ -44,6 +47,7 @@ parser.add_argument("--token-only", action="store_true", help="Print auth token parser.add_argument("--timeout", type=int, default=10, help="Request timeout seconds") parser.add_argument("--deploy-mode","-m", type=str, default="git", help="Deploy mode") parser.add_argument("--swarm","-w", action="store_true", help="Swarm mode") +print("Running version:", VERSION) args = parser.parse_args() _LOG_LEVEL = "INFO" LOG_FILE = "/tmp/portainer.log" @@ -104,6 +108,16 @@ def get_portainer_token(base_url, username=None, password=None, timeout=10): if __name__ == "__main__": # Example usage: set PORTAINER_USER and PORTAINER_PASS in env, or pass literals below. #token = get_portainer_token(base,"admin","l4c1j4yd33Du5lo") # or get_portainer_token(base, "admin", "secret") + if args.action == None: + actions = ["get-vms", "get-vms-all", "start", "stop", "delete", "rollback", "snapshot", "clone", "update_hosts"] + print("Possible actions: ") + i = 1 + for a in actions: + print(f" > {i}. {a}") + i += 1 + ans = input("\nSelect action to perform: ") + args.action = actions[int(ans)-1] + token = portainer_api_key # Example: list endpoints por = Portainer(base, token)