示例#1
0
    def __configure(self, config_str):
        """
        This setups up the base manager configuration by combining
        the global configuration and config_str into a single configuration.
        """
        self.zk_conn.clear_watch_fn(self.update_config)
        global_config = self.zk_conn.watch_contents(paths.config(), self.update_config)
        # Load our given configuration.
        base_config = ManagerConfig(config_str)

        if global_config:
            base_config.reload(global_config)

        # NOTE: We may have multiple global IPs (especially in the case of
        # provisioning a cluster that could have floating IPs that move around.
        # We read in each of the configuration blocks in turn, and hope that
        # they are not somehow mutually incompatible.
        configured_ips = None
        if self.names:

            def load_ip_config(ip):
                # Reload our local config.
                local_config = self.zk_conn.watch_contents(
                                    paths.manager_config(ip),
                                    self.update_config)
                if local_config:
                    base_config.reload(local_config)

            # Read all configured IPs.
            for ip in self.names:
                load_ip_config(ip)
            configured_ips = base_config.ips()
            for ip in configured_ips:
                load_ip_config(ip)

        return base_config
示例#2
0
 def get_config(self):
     return self.zk_conn.read(paths.config())
示例#3
0
 def update_config(self, config):
     self.zk_conn.write(paths.config(), config)