1
# Copyright 2014-2015 Canonical Limited.
3
# This file is part of charm-helpers.
5
# charm-helpers is free software: you can redistribute it and/or modify
6
# it under the terms of the GNU Lesser General Public License version 3 as
7
# published by the Free Software Foundation.
9
# charm-helpers is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU Lesser General Public License for more details.
14
# You should have received a copy of the GNU Lesser General Public License
15
# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
468
484
_unit = unit.replace('/', '-')
469
485
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
487
# NOTE(jamespage) add backend based on private address - this
488
# with either be the only backend or the fallback if no acls
489
# match in the frontend
490
cluster_hosts[addr] = {}
491
netmask = get_netmask_for_address(addr)
492
cluster_hosts[addr] = {'network': "{}/{}".format(addr, netmask),
493
'backends': {l_unit: addr}}
494
for rid in relation_ids('cluster'):
495
for unit in related_units(rid):
496
_laddr = relation_get('private-address',
499
_unit = unit.replace('/', '-')
500
cluster_hosts[addr]['backends'][_unit] = _laddr
485
ctxt = {'frontends': cluster_hosts}
503
'frontends': cluster_hosts,
504
'default_backend': addr
487
507
if config('haproxy-server-timeout'):
488
508
ctxt['haproxy_server_timeout'] = config('haproxy-server-timeout')