-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontrol.py
More file actions
38 lines (29 loc) · 1.01 KB
/
control.py
File metadata and controls
38 lines (29 loc) · 1.01 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
import sys
from datetime import datetime
from config import Config
from dao import DAO
from ipmi import lom_ipmi
cmd = sys.argv[1]
ip = sys.argv[2]
if cmd is None:
print "usage: control.py <command> <ip>"
sys.exit(0)
if ip is None or int(ip) > 255:
print "usage: control.py <command> <ip>"
sys.exit(0)
config = Config().get_config("business.json")
if not config:
print "Could not find config file"
sys.exit(0)
dao = DAO(config)
logline = " ".join(sys.argv)
dao.put_log(str(datetime.now()) + " " + logline )
if cmd == "install":
lom_ipmi().connection_auth(config["user"], config["pass"]).host(config, ip).command("pxe").run_command()
lom_ipmi().connection_auth(config["user"], config["pass"]).host(config, ip).command("cycle").run_command()
elif cmd == "on" or cmd == "off" or cmd == "cycle":
lom_ipmi().connection_auth(config["user"], config["pass"]).host(config, ip).command(cmd).run_command()
elif cmd == "images":
print(dao.get_images())
else:
print("Command not supported")