Move to using REQUIRED_INTERFACES and check for swift-hash.
This commit is contained in:
parent
5c1572f6ef
commit
e57d8793e5
|
@ -17,6 +17,7 @@ from lib.swift_storage_utils import (
|
||||||
setup_storage,
|
setup_storage,
|
||||||
assert_charm_supports_ipv6,
|
assert_charm_supports_ipv6,
|
||||||
setup_rsync,
|
setup_rsync,
|
||||||
|
REQUIRED_INTERFACES,
|
||||||
)
|
)
|
||||||
|
|
||||||
from lib.misc_utils import pause_aware_restart_on_change
|
from lib.misc_utils import pause_aware_restart_on_change
|
||||||
|
@ -42,6 +43,7 @@ from charmhelpers.payload.execd import execd_preinstall
|
||||||
from charmhelpers.contrib.openstack.utils import (
|
from charmhelpers.contrib.openstack.utils import (
|
||||||
configure_installation_source,
|
configure_installation_source,
|
||||||
openstack_upgrade_available,
|
openstack_upgrade_available,
|
||||||
|
set_os_workload_status,
|
||||||
)
|
)
|
||||||
from charmhelpers.contrib.network.ip import (
|
from charmhelpers.contrib.network.ip import (
|
||||||
get_ipv6_addr
|
get_ipv6_addr
|
||||||
|
@ -165,7 +167,8 @@ def main():
|
||||||
hooks.execute(sys.argv)
|
hooks.execute(sys.argv)
|
||||||
except UnregisteredHookError as e:
|
except UnregisteredHookError as e:
|
||||||
log('Unknown hook {} - skipping.'.format(e))
|
log('Unknown hook {} - skipping.'.format(e))
|
||||||
assess_status()
|
set_os_workload_status(CONFIGS, REQUIRED_INTERFACES,
|
||||||
|
charm_func=assess_status)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -39,7 +39,6 @@ from charmhelpers.core.hookenv import (
|
||||||
ERROR,
|
ERROR,
|
||||||
unit_private_ip,
|
unit_private_ip,
|
||||||
relation_ids,
|
relation_ids,
|
||||||
status_set,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from charmhelpers.contrib.storage.linux.utils import (
|
from charmhelpers.contrib.storage.linux.utils import (
|
||||||
|
@ -70,6 +69,10 @@ PACKAGES = [
|
||||||
|
|
||||||
TEMPLATES = 'templates/'
|
TEMPLATES = 'templates/'
|
||||||
|
|
||||||
|
REQUIRED_INTERFACES = {
|
||||||
|
'proxy': ['swift-storage'],
|
||||||
|
}
|
||||||
|
|
||||||
ACCOUNT_SVCS = [
|
ACCOUNT_SVCS = [
|
||||||
'swift-account', 'swift-account-auditor',
|
'swift-account', 'swift-account-auditor',
|
||||||
'swift-account-reaper', 'swift-account-replicator'
|
'swift-account-reaper', 'swift-account-replicator'
|
||||||
|
@ -343,10 +346,13 @@ socket options = SO_KEEPALIVE
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
def assess_status():
|
def assess_status(configs):
|
||||||
"""Assess status of current unit"""
|
"""Assess status of current unit"""
|
||||||
# Check for required swift-storage relation to swift-proxy
|
# Verify swift-hash received from swift-proxy
|
||||||
|
ctxt = SwiftStorageContext()()
|
||||||
if len(relation_ids('swift-storage')) < 1:
|
if len(relation_ids('swift-storage')) < 1:
|
||||||
status_set('blocked', 'Missing relation: proxy')
|
return '', ''
|
||||||
|
elif not ctxt or not ctxt['swift_hash']:
|
||||||
|
return 'blocked', 'Missing swift-hash from proxy relation'
|
||||||
else:
|
else:
|
||||||
status_set('active', 'Unit is ready')
|
return 'active', 'Unit is ready'
|
||||||
|
|
Loading…
Reference in New Issue