-
Notifications
You must be signed in to change notification settings - Fork 3
/
infrasim-pdusimd.py
executable file
·48 lines (40 loc) · 1.27 KB
/
infrasim-pdusimd.py
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
47
48
#!/usr/bin/python
'''
*********************************************************
Copyright @ 2015 EMC Corporation All Rights Reserved
*********************************************************
'''
import os
import sys
import getopt
import pdusim.common.logger as logger
import pdusim.pdusim
def usage():
print("Usage:{} [OPTIONS]".format(sys.argv[0]))
print("Options are:")
print("-d Run in daemon")
print("-h Help")
print("--logging-method=<file:file_name|stderr|stdout>")
if __name__ == '__main__':
pdu_device = ""
daemon = False
logger.initialize("pdusim", "stdout")
try:
opts, args = getopt.getopt(sys.argv[1:], "dh",
["daemonize", "help", "logging-method="])
for opt, arg in opts:
if opt in ("-h", "--help"):
usage()
sys.exit(1)
elif opt in ("-d", "--daemonize"):
daemon = True
elif opt == "--logging-method":
logger.initialize("pdusim", *arg.split(':'))
except getopt.GetoptError:
usage()
sys.exit(1)
if daemon:
pdusim.common.daemon.daemonize(vpdud_pid_file)
logger.info("vPDU started.")
pdu_sim = pdusim.pdusim.PDUSim()
pdu_sim.start()