in VMBackup/main/WaagentLib.py [0:0]
def main():
"""
Instantiate MyDistro, exit if distro class is not defined.
Parse command-line arguments, exit with usage() on error.
Instantiate ConfigurationProvider.
Call appropriate non-daemon methods and exit.
If daemon mode, enter Agent.Run() loop.
"""
if GuestAgentVersion == "":
print("WARNING! This is a non-standard agent that does not include a valid version string.")
if len(sys.argv) == 1:
sys.exit(Usage())
LoggerInit('/var/log/waagent.log', '/dev/console')
global LinuxDistro
LinuxDistro = DistInfo()[0]
global MyDistro
MyDistro = GetMyDistro()
if MyDistro == None:
sys.exit(1)
args = []
conf_file = None
global force
force = False
for a in sys.argv[1:]:
if re.match("^([-/]*)(help|usage|\\?)", a):
sys.exit(Usage())
elif re.match("^([-/]*)version", a):
print(GuestAgentVersion + " running on " + LinuxDistro)
sys.exit(0)
elif re.match("^([-/]*)verbose", a):
myLogger.verbose = True
elif re.match("^([-/]*)force", a):
force = True
elif re.match("^(?:[-/]*)conf=.+", a):
conf_file = re.match("^(?:[-/]*)conf=(.+)", a).groups()[0]
elif re.match("^([-/]*)(setup|install)", a):
sys.exit(MyDistro.Install())
elif re.match("^([-/]*)(uninstall)", a):
sys.exit(Uninstall())
else:
args.append(a)
global Config
Config = ConfigurationProvider(conf_file)
logfile = Config.get("Logs.File")
if logfile is not None:
myLogger.file_path = logfile
logconsole = Config.get("Logs.Console")
if logconsole is not None and logconsole.lower().startswith("n"):
myLogger.con_path = None
verbose = Config.get("Logs.Verbose")
if verbose != None and verbose.lower().startswith("y"):
myLogger.verbose = True
global daemon
daemon = False
for a in args:
if re.match("^([-/]*)deprovision\\+user", a):
sys.exit(Deprovision(force, True))
elif re.match("^([-/]*)deprovision", a):
sys.exit(Deprovision(force, False))
elif re.match("^([-/]*)daemon", a):
daemon = True
elif re.match("^([-/]*)serialconsole", a):
AppendToLinuxKernelCmdline("console=ttyS0 earlyprintk=ttyS0")
Log("Configured kernel to use ttyS0 as the boot console.")
sys.exit(0)
else:
print("Invalid command line parameter:" + a)
sys.exit(1)
if daemon == False:
sys.exit(Usage())
global modloaded
modloaded = False
while True:
try:
SwitchCwd()
Log(GuestAgentLongName + " Version: " + GuestAgentVersion)
if IsLinux():
Log("Linux Distribution Detected : " + LinuxDistro)
except Exception as e:
Error(traceback.format_exc())
Error("Exception: " + str(e))
Log("Restart agent in 15 seconds")
time.sleep(15)