~corey.bryant/charms/trusty/quantum-gateway/amulet-updates

« back to all changes in this revision

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

  • Committer: Corey Bryant
  • Date: 2014-10-07 21:03:47 UTC
  • Revision ID: corey.bryant@canonical.com-20141007210347-ltczd6bjm0b0yj18
Sync charm-helpers.

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
71
78
    ('1.12.0', 'icehouse'),
72
79
    ('1.11.0', 'icehouse'),
73
80
    ('2.0.0', 'juno'),
 
81
    ('2.1.0', 'juno'),
 
82
    ('2.2.0', 'juno'),
74
83
])
75
84
 
76
85
DEFAULT_LOOPBACK_SIZE = '5G'
457
466
            return result
458
467
    else:
459
468
        return result.split('.')[0]
 
469
 
 
470
 
 
471
def sync_db_with_multi_ipv6_addresses(database, database_user,
 
472
                                      relation_prefix=None):
 
473
    hosts = get_ipv6_addr(dynamic_only=False)
 
474
 
 
475
    kwargs = {'database': database,
 
476
              'username': database_user,
 
477
              'hostname': json.dumps(hosts)}
 
478
 
 
479
    if relation_prefix:
 
480
        keys = kwargs.keys()
 
481
        for key in keys:
 
482
            kwargs["%s_%s" % (relation_prefix, key)] = kwargs[key]
 
483
            del kwargs[key]
 
484
 
 
485
    for rid in relation_ids('shared-db'):
 
486
        relation_set(relation_id=rid, **kwargs)