Example #1
0
File: node.py Project: Qoem/qoem
 def _stat_server(node, expr):
     """Instruct single server to return statistics to controller."""
     root, path = lib.expr_split(expr)
     try:
         RemoteProcedureCall._send_to_sniffer(node, root, 'stat')
         node.print_info(TAG, "Node stat'ed for stats for the destination: %s" %expr)
     except Exception as e:
         node.print_error(TAG, "Error occured with 'stat' command for expression '%s': %s" % (expr, e))
         raise lib.RemoteProcedureCallError(data={'exception' : str(e), 'node_id' : str(node.node_id), 'expr' : str(expr)}, code='-32603')
Example #2
0
File: node.py Project: Qoem/qoem
 def _pause_sniffer(node, expr):
     """Instruct single server to pause."""
     root, path = lib.expr_split(expr)
     try:
         RemoteProcedureCall._send_to_sniffer(node, root, 'pause')
         node.print_info(TAG, "Server paused with expr: %s" %expr)
     except Exception as e:
         node.print_error(TAG, "Error occured with 'pause' command for expression '%s': %s" % (expr, e))
         raise lib.RemoteProcedureCallError(data={'exception' : str(e), 'node_id' : str(node.node_id), 'expr' : str(expr)}, code='-32603')
Example #3
0
File: node.py Project: Qoem/qoem
 def _start_sniffer(node, expr):
     """Instruct a single (existing) server to start."""
     root, path = lib.expr_split(expr)
     try:
         RemoteProcedureCall._send_to_sniffer(node, root, 'start')
         node.print_info(TAG, "Start monitoring the server: %s" %expr)
     except Exception as e:
         node.print_error(TAG, "Error occured with 'start' command for monitoring '%s': %s" % (expr, e))
         raise lib.RemoteProcedureCallError(data={'exception' : str(e), 'node_id' : str(node.node_id), 'expr' : str(expr)}, code='-32603')
Example #4
0
File: node.py Project: Qoem/qoem
    def _stop_server(node, expr):
        """Instruct sniffer to stop.

        Send stop command and then terminate process.

        """
        root, path = lib.expr_split(expr)
        try:
            RemoteProcedureCall._send_to_sniffer(node, root, 'stop')
            time.sleep(0.1)
            server_dict[expr]["process"].terminate()
            port_number_lock.acquire()
            allocated_port_number.append(server_dict[expr]["port"])
            port_number_lock.release()
            node.print_info(TAG, "Server stopped with expr: %s" %expr)
        except Exception as e:
            node.print_error(TAG, "Error occured with 'stop' command for expression '%s': %s" % (expr, e))
            raise lib.RemoteProcedureCallError(data={'exception' : str(e), 'node_id' : str(node.node_id), 'expr' : str(expr)}, code='-32603')
Example #5
0
File: node.py Project: Qoem/qoem
 def _start_new_sniffer(node, expr):
     """
     Use next available port to start server process. Store server process and port.
     """
     root, path = lib.expr_split(expr)
     try:
         try:
             port_number_lock.acquire()
             port = allocated_port_number.popleft()
             port_number_lock.release()
         except IndexError:
             node.print_error(TAG, "No ports remaining in allocation, cannot start new server.")
             return False
         process = multiprocessing.Process(target=server.Server, args=(node, root, port))
         process.daemon = True
         process.start()
         server_dict[expr] = {"process" : process, "port" : port}
         node.print_info(TAG, "New server started with expr: %s" %expr)
     except Exception as e:
         node.print_error(TAG, "Error occured with 'start' (new server) for expression '%s': %s" % (expr, e))
         raise lib.RemoteProcedureCallError(data={'exception' : str(e), 'node_id' : str(node.node_id), 'expr' : str(expr)}, code='-32603')