예제 #1
0
    def __init__(self, config_path):
        """Initialise node instance.

        Sets up signal handling to deal with interrupts. Loads configuration file, checks validity and creates
        sensible defaults if values missing. Starts loaded modules. Initialises logger to handle output durring
        running. Creates and binds socket for inter-process communications with server instances. Allocates
        potential ports for server instances. Starts continuous communication with controller. Starts JSON server
        ready to receive commands from the controller.

        """
        self._setup_signal_handling()
        self._option_check(config_path)
        parser = configparser.ConfigParser(delimiters='=')
        parser.read(config_path)
        self.config = self._create_config_defaults()
        self.config = lib.load_config(self.config, parser)
        lib.create_directory(self.config["cache_path"] + 'shared')
        self._logger = lib.setup_logger(self.config["log_path"], TAG,
                                        self.config["verbosity"])
        self.database = database.State(self)
        self._allocate_ports(self.config["port_range"])
        context = zmq.Context()
        self.ipc_socket = context.socket(zmq.PUB)
        self.ipc_socket.bind("ipc://oc")
        self._controller_communication = ControllerCommunication(self)
        self._json_server = JSONServer(self)
    def __init__(self, config_path):
        """Initialise node instance.

        Sets up signal handling to deal with interrupts. Loads configuration file, checks validity and creates
        sensible defaults if values missing. Starts loaded modules. Initialises logger to handle output durring
        running. Creates and binds socket for inter-process communications with server instances. Allocates
        potential ports for server instances. Starts continuous communication with controller. Starts JSON server
        ready to receive commands from the controller.

        """
        self._setup_signal_handling()
        self._option_check(config_path)
        parser = configparser.ConfigParser(delimiters='=')
        parser.read(config_path)
        self.config = self._create_config_defaults()
        self.config = lib.load_config(self.config, parser)
        lib.create_directory(self.config["cache_path"] + 'shared')
        self._logger = lib.setup_logger(self.config["log_path"], TAG, self.config["verbosity"])
        self.database = database.State(self)
        self._allocate_ports(self.config["port_range"])
        context = zmq.Context()
        self.ipc_socket = context.socket(zmq.PUB)
        self.ipc_socket.bind("ipc://oc")
        self._controller_communication = ControllerCommunication(self)
        self._json_server = JSONServer(self)
    def __init__(self, config_path):
        """Initialise controller instance.

        Sets up signal handling to deal with interrupts. Loads configuration file, checks validity and creates
        sensible defaults if values missing. Initialises logger to handle output during running. Starts JSON
        server ready to receive commands from clients and nodes. Starts database ready to store state.

        """
        self._setup_signal_handling()
        self._option_check(config_path)
        parser = configparser.ConfigParser(delimiters='=')
        parser.read(config_path)
        self.config = self._create_config_defaults()
        self.config = lib.load_config(self.config, parser)
        self._logger = lib.setup_logger(self.config["log_path"], TAG, self.config["verbosity"])
        self._state = state.State(self, self.config)
        self._request_handling = request_handling.Request(self)
        self._api = api.Api(self, self.config)
        self._notification = Notification(self)
        self._notification.listen()
    def __init__(self, config_path):
        """Initialise controller instance.

        Sets up signal handling to deal with interrupts. Loads configuration file, checks validity and creates
        sensible defaults if values missing. Initialises logger to handle output during running. Starts JSON
        server ready to receive commands from clients and nodes. Starts database ready to store state.

        """
        self._setup_signal_handling()
        self._option_check(config_path)
        parser = configparser.ConfigParser(delimiters='=')
        parser.read(config_path)
        self.config = self._create_config_defaults()
        self.config = lib.load_config(self.config, parser)
        self._logger = lib.setup_logger(self.config["log_path"], TAG,
                                        self.config["verbosity"])
        self._state = state.State(self, self.config)
        self._request_handling = request_handling.Request(self)
        self._api = api.Api(self, self.config)
        self._notification = Notification(self)
        self._notification.listen()