Exemple #1
0
    def _setup_chairman_registrants(self):
        """
        Setup the chairman registrant to register the host configuration.
        """

        for host_id, pseudoConfig in self._hosts.iteritems():
            registrant = ChairmanRegistrant(host_id, pseudoConfig,
                                            pseudoConfig.datastore_ids,
                                            pseudoConfig.networks)
            self._registrants.append(registrant)

        # Register the host with the chairman
        self._register_with_chairman()
    def setUp(self):
        self.hostname = "localhost"
        self.host_port = 1234
        self.availability_zone_id = "test"
        self.host_addr = ServerAddress(self.hostname, self.host_port)
        self.chairman_list = []
        self.agent_id = "foo"
        self.host_config = HostConfig(self.agent_id, self.availability_zone_id,
                                      [Datastore("bar")], self.host_addr,
                                      [Network("nw1")])
        self.registrant = ChairmanRegistrant(self.chairman_list)
        host_handler = MagicMock()
        host_handler.get_host_config_no_logging.return_value = \
            GetConfigResponse(hostConfig=self.host_config)
        common.services.register(Host.Iface, host_handler)
        self.request = RegisterHostRequest("foo", self.host_config)

        self.state_file = tempfile.mktemp()
        common.services.register(ServiceName.MODE,
                                 Mode(State(self.state_file)))