mirror of
https://gitlab.sectorq.eu/jaydee/portainer.git
synced 2025-12-14 10:44:52 +01:00
build
This commit is contained in:
14
portainer.py
14
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)
|
||||
|
||||
Reference in New Issue
Block a user