get last deps corect

This commit is contained in:
Chris MacNaughton 2016-05-31 11:04:47 -04:00
parent a17361c7fd
commit 47a802fbde
3 changed files with 49 additions and 23 deletions

View File

@ -41,6 +41,8 @@ from charmhelpers.core.hookenv import (
relation_ids,
related_units,
relation_get,
local_unit,
network_get_primary_address,
)
from charmhelpers.fetch import (
apt_cache,
@ -123,9 +125,35 @@ def get_host_ip(hostname=None):
return answers[0].address
@cached
def get_public_addr():
if config('ceph-public-network'):
return get_network_addrs('ceph-public-network')[0]
try:
return network_get_primary_address('public')
except NotImplementedError:
log("network-get not supported", DEBUG)
return get_host_ip()
@cached
def get_cluster_addr():
if config('ceph-cluster-network'):
return get_network_addrs('ceph-cluster-network')[0]
try:
return network_get_primary_address('cluster')
except NotImplementedError:
log("network-get not supported", DEBUG)
return get_host_ip()
def get_networks(config_opt='ceph-public-network'):
"""Get all configured networks from provided config option.
If public network(s) are provided, go through them and return those for
which we have an address configured.
"""
@ -137,13 +165,8 @@ def get_networks(config_opt='ceph-public-network'):
return []
def get_public_addr():
return get_network_addrs('ceph-public-network')[0]
def get_network_addrs(config_opt):
"""Get all configured public networks addresses.
If public network(s) are provided, go through them and return the
addresses we have configured on any of those networks.
"""
@ -173,6 +196,20 @@ def assert_charm_supports_ipv6():
"versions less than Trusty 14.04")
def get_peer_units():
"""
Returns a dictionary of unit names from the mon peer relation with
a flag indicating whether the unit has presented its address
"""
units = {}
units[local_unit()] = True
for relid in relation_ids('mon'):
for unit in related_units(relid):
addr = relation_get('ceph-public-address', unit, relid)
units[unit] = addr is not None
return units
LEADER = 'leader'
PEON = 'peon'
QUORUM = [LEADER, PEON]

View File

@ -5,6 +5,7 @@ import charms.apt
from charms.ceph_base import (
# get_networks,
# get_public_addr,
get_peer_units,
get_mon_hosts,
is_bootstrapped,
is_quorum,
@ -28,11 +29,11 @@ from charmhelpers.core.hookenv import (
from charmhelpers.core.sysctl import create as create_sysctl
# from charmhelpers.contrib.hardening.harden import harden
from charms_hardening.harden import harden
@when_not('ceph.installed')
# @harden()
@harden()
def install_ceph_base():
charms.apt.add_source(config('source'), key=config('key'))
charms.apt.queue_install(charms.ceph_base.PACKAGES)
@ -41,7 +42,7 @@ def install_ceph_base():
@when('config.changed', 'ceph.installed')
# @harden()
@harden()
def config_changed():
# # Check if an upgrade was requested
# check_for_upgrade()
@ -124,20 +125,6 @@ def log_monitor():
# reboot the ceph-mon process
def get_peer_units():
"""
Returns a dictionary of unit names from the mon peer relation with
a flag indicating whether the unit has presented its address
"""
units = {}
units[local_unit()] = True
for relid in relation_ids('mon'):
for unit in related_units(relid):
addr = relation_get('ceph-public-address', unit, relid)
units[unit] = addr is not None
return units
def log_osds():
if not is_state('ceph_mon.installed'):
# Check for mon relation

View File

@ -3,3 +3,5 @@ dnspython3
#charms_storage
#git+https://github.com/openstack-charmers/charms.storage.git#egg=charms.storage
git+https://github.com/chrismacnaughton/charms.storage.git#egg=charms.storage
#charms_hardening
git+https://github.com/ChrisMacNaughton/charms.hardening.git#egg=charms.hardening