~opnfv-team/charms/trusty/percona-cluster/power8

« back to all changes in this revision

Viewing changes to hooks/percona_hooks.py

  • Committer: David Ames
  • Date: 2016-01-15 00:04:57 UTC
  • mfrom: (73.1.11 trunk)
  • Revision ID: david.ames@canonical.com-20160115000457-dgfbrkcqw0m9zu5p
[jamespage, r=thedac] Fix Bug:1481362 Make datadir dynamic depending on ubuntu version

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
)
46
46
from percona_utils import (
47
47
    determine_packages,
48
 
    MY_CNF,
49
48
    setup_percona_repo,
50
49
    get_host_ip,
51
50
    get_cluster_hosts,
62
61
    is_bootstrapped,
63
62
    get_wsrep_value,
64
63
    assess_status,
 
64
    resolve_cnf_file,
65
65
)
66
66
from charmhelpers.contrib.database.mysql import (
67
67
    PerconaClusterHelper,
113
113
 
114
114
 
115
115
def render_config(clustered=False, hosts=[]):
116
 
    if not os.path.exists(os.path.dirname(MY_CNF)):
117
 
        os.makedirs(os.path.dirname(MY_CNF))
 
116
    if not os.path.exists(os.path.dirname(resolve_cnf_file())):
 
117
        os.makedirs(os.path.dirname(resolve_cnf_file()))
118
118
 
119
119
    context = {
120
120
        'cluster_name': 'juju_cluster',
125
125
        'sst_password': config('sst-password'),
126
126
        'innodb_file_per_table': config('innodb-file-per-table'),
127
127
        'table_open_cache': config('table-open-cache'),
128
 
        'lp1366997_workaround': config('lp1366997-workaround')
 
128
        'lp1366997_workaround': config('lp1366997-workaround'),
129
129
    }
130
130
 
131
131
    if config('prefer-ipv6'):
139
139
        context['ipv6'] = False
140
140
 
141
141
    context.update(PerconaClusterHelper().parse_config())
142
 
    render(os.path.basename(MY_CNF), MY_CNF, context, perms=0o444)
 
142
    render(os.path.basename(resolve_cnf_file()),
 
143
           resolve_cnf_file(), context, perms=0o444)
143
144
 
144
145
 
145
146
def render_config_restart_on_changed(clustered, hosts, bootstrap=False):
154
155
    it is started so long as the new node to be added is guaranteed to have
155
156
    been restarted so as to apply the new config.
156
157
    """
157
 
    pre_hash = file_hash(MY_CNF)
 
158
    pre_hash = file_hash(resolve_cnf_file())
158
159
    render_config(clustered, hosts)
159
160
    update_db_rels = False
160
 
    if file_hash(MY_CNF) != pre_hash or bootstrap:
 
161
    if file_hash(resolve_cnf_file()) != pre_hash or bootstrap:
161
162
        if bootstrap:
162
163
            service('bootstrap-pxc', 'mysql')
163
164
            # NOTE(dosaboy): this will not actually do anything if no cluster