~openstack-charmers/charms/precise/openstack-dashboard/old-1410

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/contrib/openstack/utils.py

  • Committer: james.page at ubuntu
  • Date: 2014-10-06 14:42:25 UTC
  • mfrom: (37.2.1 openstack-dashboard)
  • Revision ID: james.page@ubuntu.com-20141006144225-ld3uuo06iynonc05
[gnuoy,r=james-page] Add support for revised hacluster charm.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
from collections import OrderedDict
5
5
 
6
6
import subprocess
 
7
import json
7
8
import os
8
9
import socket
9
10
import sys
13
14
    log as juju_log,
14
15
    charm_dir,
15
16
    ERROR,
16
 
    INFO
 
17
    INFO,
 
18
    relation_ids,
 
19
    relation_set
17
20
)
18
21
 
19
22
from charmhelpers.contrib.storage.linux.lvm import (
22
25
    remove_lvm_physical_volume,
23
26
)
24
27
 
 
28
from charmhelpers.contrib.network.ip import (
 
29
    get_ipv6_addr
 
30
)
 
31
 
25
32
from charmhelpers.core.host import lsb_release, mounts, umount
26
33
from charmhelpers.fetch import apt_install, apt_cache
27
34
from charmhelpers.contrib.storage.linux.utils import is_block_device, zap_disk
70
77
    ('1.13.0', 'icehouse'),
71
78
    ('1.12.0', 'icehouse'),
72
79
    ('1.11.0', 'icehouse'),
 
80
    ('2.0.0', 'juno'),
73
81
])
74
82
 
75
83
DEFAULT_LOOPBACK_SIZE = '5G'
456
464
            return result
457
465
    else:
458
466
        return result.split('.')[0]
 
467
 
 
468
 
 
469
def sync_db_with_multi_ipv6_addresses(database, database_user,
 
470
                                      relation_prefix=None):
 
471
    hosts = get_ipv6_addr(dynamic_only=False)
 
472
 
 
473
    kwargs = {'database': database,
 
474
              'username': database_user,
 
475
              'hostname': json.dumps(hosts)}
 
476
 
 
477
    if relation_prefix:
 
478
        keys = kwargs.keys()
 
479
        for key in keys:
 
480
            kwargs["%s_%s" % (relation_prefix, key)] = kwargs[key]
 
481
            del kwargs[key]
 
482
 
 
483
    for rid in relation_ids('shared-db'):
 
484
        relation_set(relation_id=rid, **kwargs)