def _start_remote_desktop(self, operation): logger.info('Starting remote desktop.') operation.urn_response = RaUrn.RdResults operation.request_method = RequestMethod.POST vine_running = False local_port = tunnels.get_available_port() if local_port: vine_running, error = vine.start(local_port) else: # No local port available!? operation.success = False operation.error = 'No local port available. How did this happen?!' if vine_running: if operation.tunnel_needed: operation.success, operation.error = ( tunnels.create_reverse_tunnel(local_port, operation.host_port, settings.ServerAddress, operation.ssh_port)) if not operation.success: vine.stop() operation.raw_result = formatter.rd_results(operation) # TODO: Fix ugly response hack. Formetter should go here... #operation.raw_result = json.dumps({ # 'plugin': 'ra', # 'host_port': operation.host_port, # 'agent_id': settings.AgentId, # 'operation': operation.type, # 'operation_id': operation.id, # 'error': error, #}) logger.info('Done.') return operation
def _start_remote_desktop(self, operation): logger.info("Starting remote desktop.") operation.urn_response = RaUrn.RdResults operation.request_method = RequestMethod.POST vine_running = False local_port = tunnels.get_available_port() if local_port: vine_running, error = vine.start(local_port) else: # No local port available!? operation.success = False operation.error = "No local port available. How did this happen?!" if vine_running: if operation.tunnel_needed: operation.success, operation.error = tunnels.create_reverse_tunnel( local_port, operation.host_port, settings.ServerAddress, operation.ssh_port ) if not operation.success: vine.stop() operation.raw_result = formatter.rd_results(operation) # TODO: Fix ugly response hack. Formetter should go here... # operation.raw_result = json.dumps({ # 'plugin': 'ra', # 'host_port': operation.host_port, # 'agent_id': settings.AgentId, # 'operation': operation.type, # 'operation_id': operation.id, # 'error': error, # }) logger.info("Done.") return operation
def _stop_remote_desktop(self, operation): logger.info('Stopping remote desktop') operation.urn_response = RaUrn.RdResults operation.request_method = RequestMethod.POST operation.success = True res, msg = vine.stop() if not res: operation.success = False operation.error = 'Unable to stop vine server.' operation.error += msg if not tunnels.stop_reverse_tunnel(): operation.success = False operation.error += 'Unable to stop revere tunnel.' operation.raw_result = formatter.rd_stop_results(operation) logger.info('Done.') return operation
def _stop_remote_desktop(self, operation): logger.info("Stopping remote desktop") operation.urn_response = RaUrn.RdResults operation.request_method = RequestMethod.POST operation.success = True res, msg = vine.stop() if not res: operation.success = False operation.error = "Unable to stop vine server." operation.error += msg if not tunnels.stop_reverse_tunnel(): operation.success = False operation.error += "Unable to stop revere tunnel." operation.raw_result = formatter.rd_stop_results(operation) logger.info("Done.") return operation