~matsubara/charms/trusty/mongodb/bug-1410847

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/contrib/hahelpers/cluster.py

  • Committer: diogo.matsubara at canonical
  • Date: 2015-02-02 17:54:22 UTC
  • Revision ID: diogo.matsubara@canonical.com-20150202175422-u085bnvvb2rqvl1x
sync charm-helpers: add support for kilo cloud archive. LP: #1410847

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2014-2015 Canonical Limited.
 
2
#
 
3
# This file is part of charm-helpers.
 
4
#
 
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.
 
8
#
 
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.
 
13
#
 
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/>.
 
16
 
1
17
#
2
18
# Copyright 2012 Canonical Ltd.
3
19
#
205
221
    return public_port - (i * 10)
206
222
 
207
223
 
208
 
def get_hacluster_config():
 
224
def get_hacluster_config(exclude_keys=None):
209
225
    '''
210
226
    Obtains all relevant configuration from charm configuration required
211
227
    for initiating a relation to hacluster:
212
228
 
213
229
        ha-bindiface, ha-mcastport, vip
214
230
 
 
231
    param: exclude_keys: list of setting key(s) to be excluded.
215
232
    returns: dict: A dict containing settings keyed by setting name.
216
233
    raises: HAIncompleteConfig if settings are missing.
217
234
    '''
218
235
    settings = ['ha-bindiface', 'ha-mcastport', 'vip']
219
236
    conf = {}
220
237
    for setting in settings:
 
238
        if exclude_keys and setting in exclude_keys:
 
239
            continue
 
240
 
221
241
        conf[setting] = config_get(setting)
222
242
    missing = []
223
243
    [missing.append(s) for s, v in six.iteritems(conf) if v is None]