~charmers/charms/trusty/galera-cluster/trunk

« back to all changes in this revision

Viewing changes to hooks/percona_utils.py

  • Committer: Edward Hope-Morley
  • Date: 2015-02-04 17:47:15 UTC
  • mfrom: (42.1.5 percona-cluster.fix-1389670)
  • Revision ID: edward.hope-morley@canonical.com-20150204174715-p5dhe9pq021v0xom
[hopem,r=]

Don't put allowed units onto the cluster relation.

Also fixes support for non-prefixed db relation
settings.

Closes-Bug: 1389670

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
    local_unit,
17
17
    config,
18
18
    log,
19
 
    INFO
 
19
    DEBUG,
20
20
)
21
21
from charmhelpers.fetch import (
22
22
    apt_install,
104
104
                if not hostname or hostname in hosts:
105
105
                    log("(unit=%s) Ignoring hostname '%s' provided by cluster "
106
106
                        "relation for addr %s" %
107
 
                        (unit, hostname, private_address))
 
107
                        (unit, hostname, private_address), level=DEBUG)
108
108
                    continue
109
109
                else:
110
110
                    log("(unit=%s) hostname '%s' provided by cluster relation "
111
 
                        "for addr %s" % (unit, hostname, private_address))
 
111
                        "for addr %s" % (unit, hostname, private_address),
 
112
                        level=DEBUG)
112
113
 
113
114
                hosts_map[private_address] = hostname
114
115
                hosts.append(hostname)
175
176
    with open(HOSTS_FILE, 'r') as hosts:
176
177
        lines = hosts.readlines()
177
178
 
178
 
    log("Updating hosts file with: %s (current: %s)" % (map, lines),
179
 
        level=INFO)
 
179
    log("Updating %s with: %s (current: %s)" % (HOSTS_FILE, map, lines),
 
180
        level=DEBUG)
180
181
 
181
182
    newlines = []
182
183
    for ip, hostname in map.items():
189
190
            if len(line) < 2 or not (_line[0] == ip or hostname in _line[1:]):
190
191
                keepers.append(line)
191
192
            else:
192
 
                log("Removing line '%s' from hosts file" % (line))
 
193
                log("Marking line '%s' for update or removal" % (line.strip()),
 
194
                    level=DEBUG)
193
195
 
194
196
        lines = keepers
195
197
        newlines.append("%s %s\n" % (ip, hostname))