def main():
parser = argparse.ArgumentParser()
parser.add_argument("vnic_address", help="Playground address of the VNIC")
parser.add_argument("switch_address", help="IP address of the Playground Switch")
parser.add_argument("switch_port", type=int, help="TCP port of the Playground Switch")
parser.add_argument("--port", type=int, default=0, help="TCP port for serving VNIC connections")
parser.add_argument("--statusfile", help="file to record status; useful for communications")
parser.add_argument("--pidfile", help="file to record pid; useful for communciations")
parser.add_argument("--no-daemon", action="store_true", default=False, help="do not launch VNIC in a daemon; remain in foreground")
args = parser.parse_args()
pidFileName = os.path.expanduser(os.path.expandvars(args.pidfile))
statusFileName = os.path.expanduser(os.path.expandvars(args.statusfile))
pidFileDir = os.path.dirname(pidFileName)
if args.no_daemon:
runVnic(args.vnic_address, args.port, statusFileName, args.switch_address, args.switch_port, False)
else:
with daemon.DaemonContext(
working_directory=pidFileDir,
umask=0o002,
pidfile=pidfile.TimeoutPIDLockFile(pidFileName),
) as context:
runVnic(args.vnic_address, args.port, statusFileName, args.switch_address, args.switch_port, True)
评论列表
文章目录