synced trunk

This commit is contained in:
Edward Hope-Morley
2014-10-22 11:34:07 +01:00
3 changed files with 27 additions and 12 deletions

View File

@@ -6,6 +6,7 @@
# Matthew Wedgwood <matthew.wedgwood@canonical.com>
import os
import re
import pwd
import grp
import random
@@ -317,7 +318,13 @@ def list_nics(nic_type):
ip_output = (line for line in ip_output if line)
for line in ip_output:
if line.split()[1].startswith(int_type):
interfaces.append(line.split()[1].replace(":", ""))
matched = re.search('.*: (bond[0-9]+\.[0-9]+)@.*', line)
if matched:
interface = matched.groups()[0]
else:
interface = line.split()[1].replace(":", "")
interfaces.append(interface)
return interfaces

View File

@@ -218,6 +218,7 @@ def add_source(source, key=None):
pocket for the release.
'cloud:' may be used to activate official cloud archive pockets,
such as 'cloud:icehouse'
'distro' may be used as a noop
@param key: A key to be added to the system's APT keyring and used
to verify the signatures on packages. Ideally, this should be an
@@ -251,6 +252,8 @@ def add_source(source, key=None):
release = lsb_release()['DISTRIB_CODENAME']
with open('/etc/apt/sources.list.d/proposed.list', 'w') as apt:
apt.write(PROPOSED_POCKET.format(release))
elif source == 'distro':
pass
else:
raise SourceConfigError("Unknown source: {!r}".format(source))

View File

@@ -65,10 +65,10 @@ from charmhelpers.contrib.hahelpers.cluster import (
from mysql import configure_db
from charmhelpers.payload.execd import execd_preinstall
from charmhelpers.contrib.network.ip import (
is_address_in_network,
get_address_in_network,
get_netmask_for_address,
get_ipv6_addr
get_ipv6_addr,
is_address_in_network
)
hooks = Hooks()
@@ -215,6 +215,17 @@ def db_changed(relation_id=None, unit=None, admin=None):
)
def get_db_host(client_hostname):
client_ip = get_host_ip(client_hostname)
if is_clustered():
return config('vip')
access_network = config('access-network')
if (access_network is not None and
is_address_in_network(access_network, client_ip)):
return get_address_in_network(access_network)
return unit_get('private-address')
# TODO: This could be a hook common between mysql and percona-cluster
@hooks.hook('shared-db-relation-changed')
def shared_db_changed(relation_id=None, unit=None):
@@ -275,10 +286,7 @@ def shared_db_changed(relation_id=None, unit=None):
settings['database'],
settings['username'])))
if (access_network is not None and
is_address_in_network(access_network,
get_host_ip(settings['hostname']))):
db_host = get_address_in_network(access_network)
db_host = get_db_host(settings['hostname'])
peer_store_and_set(relation_id=relation_id,
db_host=db_host,
password=password,
@@ -335,11 +343,8 @@ def shared_db_changed(relation_id=None, unit=None):
databases[db]['database'],
databases[db]['username'])))
if (access_network is not None and
is_address_in_network(
access_network,
get_host_ip(databases[db]['hostname']))):
db_host = get_address_in_network(access_network)
db_host = get_db_host(databases[db]['hostname'])
if len(return_data) > 0:
peer_store_and_set(relation_id=relation_id,
**return_data)