def execute(vm, protocol, args): """ server side """ from AVMaster import vm_manager #logging.debug(" CS Execute") assert vm, "null vm" mq = protocol.mq timeout = 9 #9 = 90 sec; 30 = 300 sec if args: timeout = args / 10 mq.reset_connection(vm) cmd = "/Windows/System32/logoff.exe" ret = vm_manager.execute(vm, "executeCmd", cmd, [], 10, True, True) logging.debug("logoff ret: %s" % ret) started = False if ret: for i in range(6): if vm_manager.execute(vm, "is_powered_on"): logging.debug("%s: powered on" % vm) for i in range(timeout): if mq.check_connection(vm): logging.debug("got connection from %s" % vm) return True, "Login VM" sleep(10) logging.debug("%s: try to reboot" % vm) ret = vm_manager.execute(vm, "reboot") else: sleep(10) return False, "Cannot relogin"
def execute(vm, protocol, args): """ server side """ from AVMaster import vm_manager #logging.debug(" CS Execute") assert vm, "null vm" mq = protocol.mq check_avagent = (args == "AV_AGENT") mq.reset_connection(vm) ret = vm_manager.execute(vm, "startup") started = False if not ret: return False, "Not Started VM" max_install = 10 max_tries = 10 for i in range(3): sleep(10) if vm_manager.execute(vm, "is_powered_on"): for i in range(max_tries): if mq.check_connection(vm): logging.debug("got connection from %s" % vm) return True, "Started VM" for i in range(max_install): status = get_status(vm) logging.debug("%s, got status: %s" % (vm, status)) if status == "INSTALL": logging.debug("waiting for the install to finish: %s/%s" % (i, max_install)) sleep(60) else: break if status == "LOGGED-IN": logging.debug("%s, executing ipconfig, time: %s/%s" % (vm, i, max_tries)) started = vm_manager.execute(vm, "executeCmd", "c:\\windows\\system32\\ipconfig.exe") == 0 logging.debug("%s, executed ipconfig, ret: %s" % (vm, started)) if started and not check_avagent: return True, "Started VM" else: sleep(20) if not started: logging.debug("%s: reboot requested" % vm) vm_manager.execute(vm, "reboot") sleep(60) continue return False, "Not started VM" else: logging.debug("%s: not yet powered" % vm) return False, "Error Occurred: Timeout while starting VM"
def execute(vm, protocol, args): """ server side """ from AVMaster import vm_manager #logging.debug(" CS Execute") assert vm, "null vm" mq = protocol.mq timeout = 9 #9 = 90 sec; 30 = 300 sec if args: timeout = args / 10 mq.reset_connection(vm) cmd = "/Windows/System32/logoff.exe" ret = vm_manager.execute(vm, "executeCmd", cmd, [] , 10, True, True) logging.debug("logoff ret: %s" % ret) started = False if ret: for i in range(6): if vm_manager.execute(vm, "is_powered_on"): logging.debug("%s: powered on" % vm) for i in range(timeout): if mq.check_connection(vm): logging.debug("got connection from %s" % vm) return True, "Login VM" sleep(10) logging.debug("%s: try to reboot" % vm) ret = vm_manager.execute(vm, "reboot") else: sleep(10) return False, "Cannot relogin"
def execute(vm, protocol, args): """ server side """ from AVMaster import vm_manager #logging.debug(" CS Execute") assert vm, "null vm" mq = protocol.mq check_avagent = (args == "AV_AGENT") mq.reset_connection(vm) ret = vm_manager.execute(vm, "startup") started = False if not ret: return False, "Not Started VM" max_install = 10 max_tries = 10 for i in range(3): sleep(10) if vm_manager.execute(vm, "is_powered_on"): for i in range(max_tries): if mq.check_connection(vm): logging.debug("got connection from %s" % vm) return True, "Started VM" for i in range(max_install): status = get_status(vm) logging.debug("%s, got status: %s" % (vm, status)) if status == "INSTALL": logging.debug( "waiting for the install to finish: %s/%s" % (i, max_install)) sleep(60) else: break if status == "LOGGED-IN": logging.debug("%s, executing ipconfig, time: %s/%s" % (vm, i, max_tries)) started = vm_manager.execute( vm, "executeCmd", "c:\\windows\\system32\\ipconfig.exe") == 0 logging.debug("%s, executed ipconfig, ret: %s" % (vm, started)) if started and not check_avagent: return True, "Started VM" else: sleep(20) if not started: logging.debug("%s: reboot requested" % vm) vm_manager.execute(vm, "reboot") sleep(60) continue return False, "Not started VM" else: logging.debug("%s: not yet powered" % vm) return False, "Error Occurred: Timeout while starting VM"