def runOp(self, controllerPc, hostPc, testLog, opParams): port = controllerPc.configs.defaultConfContent['hostPcServerPort'] socket = operationWithSocket.createCommunication( self, controllerPc, hostPc, testLog) if not socket: #controllerPc.updateRunTimeState(hostPc, "\nhibernate could not being made as socket creating has failed") return False controllerPc.updateRunTimeStateInTerminal( hostPc, testLog, "\n communication has been created") messegeToServer = {"operation": "hibernate"} socket.sendall(json.dumps(messegeToServer).encode( 'utf-8')) # encode the dict to JSON controllerPc.updateRunTimeStateInTerminal( hostPc, testLog, "\n hibernate request has been sent to server") socket.close() controllerPc.updateRunTimeStateInTerminal( hostPc, testLog, "\n communication has been closed") hostPcIsOff = operation.waitForPcToTurnOff( self, controllerPc, hostPc, testLog) # Verify the host is down if hostPcIsOff: controllerPc.updateRunTimeStateInTerminal( hostPc, testLog, "\n hibernate done successfully") else: controllerPc.updateRunTimeStateInTerminal( hostPc, testLog, "\n hibernate operation has failed") return hostPcIsOff
def runOp(self, controllerPc, hostPc, testLog, opParams): controllerPc.updateRunTimeStateInTerminal( hostPc, testLog, "\n shutdown command has started") port = controllerPc.configs.defaultConfContent['hostPcServerPort'] socket = operationWithSocket.createCommunication( self, controllerPc, hostPc, testLog) if not socket: controllerPc.updateRunTimeStateInTerminal( hostPc, testLog, "\n shutdown could not being made as socket creating has failed" ) return False messegeToServer = {"operation": "shutdown"} socket.sendall(json.dumps(messegeToServer).encode( 'utf-8')) # encode the dict to JSON socket.close() # Verify the host is down hostPcIsOFf = operation.waitForPcToTurnOff(self, controllerPc, hostPc, testLog) if hostPcIsOFf: controllerPc.updateRunTimeStateInTerminal( hostPc, testLog, "\n shutdown command has ended successfully") else: controllerPc.updateRunTimeStateInTerminal( hostPc, testLog, "\n shutdown command has Failed") return hostPcIsOFf
def runOp(self,controllerPc,hostPc,opParams): port = controllerPc.configs.defaultConfContent['hostPcServerPort'] socket = operationWithSocket.createCommunication(self, hostPc["IP"], port) messegeToServer = {"operation": "sleep", "param": SLEEP_COMMAND} socket.sendall(json.dumps(messegeToServer).encode('utf-8')) # encode the dict to JSON socket.close() hostPcIsOn = operation.checkIfPcisOn(self, controllerPc, hostPc) # Verify the host is down return not hostPcIsOn
def runOp(self, controllerPc, hostPc, opParams): socket = operationWithSocket.createCommunication( self, hostPc["IP"], controllerPc.configs.defaultConfContent['hostPcServerPort']) if (socket == False): return False messegeToServer = {"operation": "runDM", "param": opParams[0]} socket.sendall(json.dumps(messegeToServer).encode( 'utf-8')) # encode the dict to JSON messegeFromServer = socket.recv( 1024).decode() # receive response from the server socket.close() print(messegeFromServer)