Resync to trunk helpers

This commit is contained in:
James Page 2014-07-24 11:27:48 +01:00
parent 95c68506f0
commit 35df07cf6d
4 changed files with 14 additions and 26 deletions

View File

@ -1,4 +1,4 @@
branch: lp:~james-page/charm-helpers/network-splits
branch: lp:charm-helpers
destination: hooks/charmhelpers
include:
- core

View File

@ -163,7 +163,7 @@ def get_hacluster_config():
return conf
def canonical_url(configs, vip_setting='vip', address=None):
def canonical_url(configs, vip_setting='vip'):
'''
Returns the correct HTTP URL to this host given the state of HTTPS
configuration and hacluster.
@ -180,5 +180,5 @@ def canonical_url(configs, vip_setting='vip', address=None):
if is_clustered():
addr = config_get(vip_setting)
else:
addr = address or unit_get('private-address')
addr = unit_get('private-address')
return '%s://%s' % (scheme, addr)

View File

@ -1,5 +1,7 @@
import sys
from functools import partial
from charmhelpers.fetch import apt_install
from charmhelpers.core.hookenv import (
ERROR, log,
@ -62,10 +64,9 @@ def get_address_in_network(network, fallback=None, fatal=False):
return str(cidr.ip)
if network.version == 6 and netifaces.AF_INET6 in addresses:
for addr in addresses[netifaces.AF_INET6]:
if 'fe80' not in addr['addr']:
netmask = addr['netmask']
if not addr['addr'].startswith('fe80'):
cidr = netaddr.IPNetwork("%s/%s" % (addr['addr'],
netmask))
addr['netmask']))
if cidr in network:
return str(cidr.ip)
@ -139,7 +140,7 @@ def _get_for_address(address, key):
return addresses[netifaces.AF_INET][0][key]
if address.version == 6 and netifaces.AF_INET6 in addresses:
for addr in addresses[netifaces.AF_INET6]:
if 'fe80' not in addr['addr']:
if not addr['addr'].startswith('fe80'):
cidr = netaddr.IPNetwork("%s/%s" % (addr['addr'],
addr['netmask']))
if address in cidr:
@ -150,23 +151,6 @@ def _get_for_address(address, key):
return None
def get_iface_for_address(address):
"""Determine the physical interface to which an IP address could be bound
get_iface_for_address = partial(_get_for_address, key='iface')
:param address (str): An individual IPv4 or IPv6 address without a net
mask or subnet prefix. For example, '192.168.1.1'.
:returns str: Interface name or None if address is not bindable.
"""
return _get_for_address(address, 'iface')
def get_netmask_for_address(address):
"""Determine the netmask of the physical interface to which and IP address
could be bound
:param address (str): An individual IPv4 or IPv6 address without a net
mask or subnet prefix. For example, '192.168.1.1'.
:returns str: Netmask of configured interface or None if address is
not bindable.
"""
return _get_for_address(address, 'netmask')
get_netmask_for_address = partial(_get_for_address, key='netmask')

View File

@ -322,6 +322,10 @@ def cmp_pkgrevno(package, revno, pkgcache=None):
import apt_pkg
if not pkgcache:
apt_pkg.init()
# Force Apt to build its cache in memory. That way we avoid race
# conditions with other applications building the cache in the same
# place.
apt_pkg.config.set("Dir::Cache::pkgcache", "")
pkgcache = apt_pkg.Cache()
pkg = pkgcache[package]
return apt_pkg.version_compare(pkg.current_ver.ver_str, revno)