def setUp(self):
     self.agent_conf_dir = mkdtemp(delete=True)
     state = State(os.path.join(self.agent_conf_dir, "state.json"))
     common.services.register(ServiceName.MODE, Mode(state))
     common.services.register(ServiceName.DATASTORE_TAGS,
                              DatastoreTags(state))
     self.agent = AgentConfig(["--config-path", self.agent_conf_dir])
Beispiel #2
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)
    def setUp(self):
        self.agent_conf_dir = mkdtemp(delete=True)
        state = State(os.path.join(self.agent_conf_dir, "state.json"))
        common.services.register(ServiceName.MODE, Mode(state))
        common.services.register(ServiceName.DATASTORE_TAGS,
                                 DatastoreTags(state))
        self.multi_agent = MultiAgent(2200, AgentConfig.DEFAULT_CONFIG_PATH,
                                      AgentConfig.DEFAULT_CONFIG_FILE)

        self.agent = AgentConfig(["--config-path", self.agent_conf_dir])
 def setup(self):
     self._threadpool = ThreadPoolExecutor(16)
     self.state_file = tempfile.mktemp()
     common.services.register(ThreadPoolExecutor, self._threadpool)
     self._host_handler = MagicMock()
     common.services.register(Host.Iface, self._host_handler)
     common.services.register(ServiceName.MODE,
                              Mode(State(self.state_file)))
     common.services.register(ServiceName.AGENT_CONFIG, MagicMock())
     common.services.register(ServiceName.DATASTORE_TAGS,
                              DatastoreTags(State(self.state_file)))
    def test_persistent(self):
        t1 = {
            "datastore1": set(["tag1", "tag2"]),
            "datastore2": set(["tag3", "tag2"]),
        }
        self.tags.set(t1)

        # Load from new State and DatastoreTags object. Verify the same result.
        state = State(self.file_location)
        tags = DatastoreTags(state)
        t2 = tags.get()
        assert_that(t1, equal_to(t2))
Beispiel #6
0
 def setUp(self):
     self.file_location = tempfile.mktemp()
     self.state = State(self.file_location)
     self.tags = DatastoreTags(self.state)
     common.services.register(ServiceName.DATASTORE_TAGS, self.tags)
 def setUp(self):
     self.file_location = tempfile.mktemp()
     self.state = State(self.file_location)
     self.tags = DatastoreTags(self.state)