-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebmain.py
More file actions
46 lines (38 loc) · 1.86 KB
/
Copy pathwebmain.py
File metadata and controls
46 lines (38 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python3
"""iLO2 remote console served over the web: a WebSocket streams JPEG frame
snapshots + logs and accepts keyboard/mouse/power commands, decoupled from
any particular renderer -- open web/index.html in a browser, or point any
other client (future HLS transcoder, diagnostics dashboard) at the same
WebSocket.
Credentials come from the environment (see .env / ilo2/dotenv.py):
ILO_HOST, ILO_USER, ILO_PASSWORD, ILO_PORT (optional, default 443 --
for reaching iLO2 through a NAT/port-forward that maps a different
external port to its real 443, e.g. an emergency access path that
doesn't depend on the same VPN/router infra iLO2 exists to recover)
"""
import argparse
import os
import sys
from pathlib import Path
from ilo2.dotenv import load_dotenv
from ilo2.webserver import main as run_webserver
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--host", default=os.environ.get("ILO_HOST"))
parser.add_argument("--user", default=os.environ.get("ILO_USER", "Administrator"))
parser.add_argument("--password", default=os.environ.get("ILO_PASSWORD"))
parser.add_argument("--ilo-port", type=int, default=int(os.environ.get("ILO_PORT", 443)))
parser.add_argument("--http-port", type=int, default=8080)
parser.add_argument("--ws-port", type=int, default=8765)
args = parser.parse_args()
if not args.host:
print("Missing host: set ILO_HOST in the environment, or pass --host.", file=sys.stderr)
sys.exit(1)
if not args.password:
print("Missing password: set ILO_PASSWORD in the environment, or pass --password.",
file=sys.stderr)
sys.exit(1)
run_webserver(args.host, args.user, args.password, args.http_port, args.ws_port, args.ilo_port)
if __name__ == "__main__":
load_dotenv(Path(__file__).resolve().parent / ".env")
main()