def generate(self, clusters, version=None):
now = datetime.datetime.now()<EOL>sections = [<EOL>Section(<EOL>"<STR_LIT>" % now.strftime("<STR_LIT>"),<EOL>self.global_stanza,<EOL>self.defaults_stanza<EOL>)<EOL>]<EOL>meta_stanzas = [<EOL>MetaFrontendStanza(<EOL>name, self.meta_clusters[name]["<STR_LIT:port>"],<EOL>self.meta_clusters[name].get("<STR_LIT>", []), members,<EOL>self.bind_address<EOL>)<EOL>for name, members<EOL>in six.iteritems(self.get_meta_clusters(clusters))<EOL>]<EOL>frontend_stanzas = [<EOL>FrontendStanza(cluster, self.bind_address)<EOL>for cluster in clusters<EOL>if "<STR_LIT:port>" in cluster.haproxy<EOL>]<EOL>backend_stanzas = [BackendStanza(cluster) for cluster in clusters]<EOL>if version and version >= (<NUM_LIT:1>, <NUM_LIT:5>, <NUM_LIT:0>):<EOL><INDENT>peers_stanzas = [PeersStanza(cluster) for cluster in clusters]<EOL><DEDENT>else:<EOL><INDENT>peers_stanzas = []<EOL><DEDENT>sections.extend([<EOL>Section("<STR_LIT>", *meta_stanzas),<EOL>Section("<STR_LIT>", *frontend_stanzas),<EOL>Section("<STR_LIT>", *backend_stanzas),<EOL>Section("<STR_LIT>", *peers_stanzas),<EOL>Section("<STR_LIT>", *self.proxy_stanzas),<EOL>])<EOL>if self.stats_stanza:<EOL><INDENT>sections.append(<EOL>Section("<STR_LIT>", self.stats_stanza)<EOL>)<EOL><DEDENT>return "<STR_LIT>".join([str(section) for section in sections]) + "<STR_LIT:\n>"<EOL>
Generates HAProxy config file content based on a given list of
clusters.