Beispiel #1
0
    def _register_services(self):
        common.services.register(ServiceName.AGENT_CONFIG, self._config)
        common.services.register(ServiceName.LOCKED_VMS, ExclusiveSet())

        threadpool = RequestIdExecutor(
            ThreadPoolExecutor(self._config.workers))
        common.services.register(ThreadPoolExecutor, threadpool)

        self._registrant = ChairmanRegistrant(self._config.chairman_list)
        self._config.on_config_change(self._config.CHAIRMAN,
                                      self._registrant.update_chairman_list)
        common.services.register(ServiceName.REGISTRANT, self._registrant)

        state_json_file = os.path.join(
            self._config.options.config_path,
            self._config.DEFAULT_STATE_FILE)
        state = State(state_json_file)

        mode = Mode(state)
        mode.on_change(self._registrant.trigger_chairman_update)
        common.services.register(ServiceName.MODE, mode)

        ds_tags = DatastoreTags(state)
        ds_tags.on_change(self._registrant.trigger_chairman_update)
        common.services.register(ServiceName.DATASTORE_TAGS, ds_tags)