468
468
_unit = unit.replace('/', '-')
469
469
cluster_hosts[laddr]['backends'][_unit] = _laddr
471
# NOTE(jamespage) no split configurations found, just use
473
if not cluster_hosts:
474
netmask = get_netmask_for_address(addr)
475
cluster_hosts[addr] = {'network': "{}/{}".format(addr, netmask),
476
'backends': {l_unit: addr}}
477
for rid in relation_ids('cluster'):
478
for unit in related_units(rid):
479
_laddr = relation_get('private-address',
482
_unit = unit.replace('/', '-')
483
cluster_hosts[addr]['backends'][_unit] = _laddr
471
# NOTE(jamespage) add backend based on private address - this
472
# with either be the only backend or the fallback if no acls
473
# match in the frontend
474
cluster_hosts[addr] = {}
475
netmask = get_netmask_for_address(addr)
476
cluster_hosts[addr] = {'network': "{}/{}".format(addr, netmask),
477
'backends': {l_unit: addr}}
478
for rid in relation_ids('cluster'):
479
for unit in related_units(rid):
480
_laddr = relation_get('private-address',
483
_unit = unit.replace('/', '-')
484
cluster_hosts[addr]['backends'][_unit] = _laddr
485
ctxt = {'frontends': cluster_hosts}
487
'frontends': cluster_hosts,
488
'default_backend': addr
487
491
if config('haproxy-server-timeout'):
488
492
ctxt['haproxy_server_timeout'] = config('haproxy-server-timeout')
491
495
ctxt['haproxy_client_timeout'] = config('haproxy-client-timeout')
493
497
if config('prefer-ipv6'):
494
499
ctxt['local_host'] = 'ip6-localhost'
495
500
ctxt['haproxy_host'] = '::'
496
501
ctxt['stat_port'] = ':::8888'
662
667
addresses = self.get_network_addresses()
663
668
for address, endpoint in sorted(set(addresses)):
664
669
for api_port in self.external_ports:
665
ext_port = determine_apache_port(api_port)
666
int_port = determine_api_port(api_port)
670
ext_port = determine_apache_port(api_port,
671
singlenode_mode=True)
672
int_port = determine_api_port(api_port, singlenode_mode=True)
667
673
portmap = (address, endpoint, int(ext_port), int(int_port))
668
674
ctxt['endpoints'].append(portmap)
669
675
ctxt['ext_ports'].append(int(ext_port))