Added workload status
This commit is contained in:
parent
592e691b31
commit
32ec1cb6a6
@ -22,6 +22,7 @@ from charmhelpers.core.host import (
|
|||||||
|
|
||||||
from charmhelpers.contrib.openstack.utils import (
|
from charmhelpers.contrib.openstack.utils import (
|
||||||
os_requires_version,
|
os_requires_version,
|
||||||
|
os_workload_status,
|
||||||
)
|
)
|
||||||
|
|
||||||
from neutron_ovs_utils import (
|
from neutron_ovs_utils import (
|
||||||
@ -38,6 +39,8 @@ from neutron_ovs_utils import (
|
|||||||
enable_local_dhcp,
|
enable_local_dhcp,
|
||||||
install_packages,
|
install_packages,
|
||||||
purge_packages,
|
purge_packages,
|
||||||
|
REQUIRED_INTERFACES,
|
||||||
|
check_optional_relations,
|
||||||
)
|
)
|
||||||
|
|
||||||
hooks = Hooks()
|
hooks = Hooks()
|
||||||
@ -52,6 +55,8 @@ def install():
|
|||||||
|
|
||||||
@hooks.hook('neutron-plugin-relation-changed')
|
@hooks.hook('neutron-plugin-relation-changed')
|
||||||
@hooks.hook('config-changed')
|
@hooks.hook('config-changed')
|
||||||
|
@os_workload_status(CONFIGS, REQUIRED_INTERFACES,
|
||||||
|
charm_func=check_optional_relations)
|
||||||
@restart_on_change(restart_map())
|
@restart_on_change(restart_map())
|
||||||
def config_changed():
|
def config_changed():
|
||||||
install_packages()
|
install_packages()
|
||||||
@ -68,6 +73,8 @@ def config_changed():
|
|||||||
|
|
||||||
|
|
||||||
@hooks.hook('neutron-plugin-api-relation-changed')
|
@hooks.hook('neutron-plugin-api-relation-changed')
|
||||||
|
@os_workload_status(CONFIGS, REQUIRED_INTERFACES,
|
||||||
|
charm_func=check_optional_relations)
|
||||||
@restart_on_change(restart_map())
|
@restart_on_change(restart_map())
|
||||||
def neutron_plugin_api_changed():
|
def neutron_plugin_api_changed():
|
||||||
if use_dvr():
|
if use_dvr():
|
||||||
@ -82,6 +89,8 @@ def neutron_plugin_api_changed():
|
|||||||
|
|
||||||
|
|
||||||
@hooks.hook('neutron-plugin-relation-joined')
|
@hooks.hook('neutron-plugin-relation-joined')
|
||||||
|
@os_workload_status(CONFIGS, REQUIRED_INTERFACES,
|
||||||
|
charm_func=check_optional_relations)
|
||||||
def neutron_plugin_joined(relation_id=None):
|
def neutron_plugin_joined(relation_id=None):
|
||||||
if enable_local_dhcp():
|
if enable_local_dhcp():
|
||||||
install_packages()
|
install_packages()
|
||||||
@ -95,6 +104,8 @@ def neutron_plugin_joined(relation_id=None):
|
|||||||
|
|
||||||
|
|
||||||
@hooks.hook('amqp-relation-joined')
|
@hooks.hook('amqp-relation-joined')
|
||||||
|
@os_workload_status(CONFIGS, REQUIRED_INTERFACES,
|
||||||
|
charm_func=check_optional_relations)
|
||||||
def amqp_joined(relation_id=None):
|
def amqp_joined(relation_id=None):
|
||||||
relation_set(relation_id=relation_id,
|
relation_set(relation_id=relation_id,
|
||||||
username=config('rabbit-user'),
|
username=config('rabbit-user'),
|
||||||
@ -103,6 +114,8 @@ def amqp_joined(relation_id=None):
|
|||||||
|
|
||||||
@hooks.hook('amqp-relation-changed')
|
@hooks.hook('amqp-relation-changed')
|
||||||
@hooks.hook('amqp-relation-departed')
|
@hooks.hook('amqp-relation-departed')
|
||||||
|
@os_workload_status(CONFIGS, REQUIRED_INTERFACES,
|
||||||
|
charm_func=check_optional_relations)
|
||||||
@restart_on_change(restart_map())
|
@restart_on_change(restart_map())
|
||||||
def amqp_changed():
|
def amqp_changed():
|
||||||
if 'amqp' not in CONFIGS.complete_contexts():
|
if 'amqp' not in CONFIGS.complete_contexts():
|
||||||
@ -112,6 +125,8 @@ def amqp_changed():
|
|||||||
|
|
||||||
|
|
||||||
@hooks.hook('zeromq-configuration-relation-joined')
|
@hooks.hook('zeromq-configuration-relation-joined')
|
||||||
|
@os_workload_status(CONFIGS, REQUIRED_INTERFACES,
|
||||||
|
charm_func=check_optional_relations)
|
||||||
@os_requires_version('kilo', 'neutron-common')
|
@os_requires_version('kilo', 'neutron-common')
|
||||||
def zeromq_configuration_relation_joined(relid=None):
|
def zeromq_configuration_relation_joined(relid=None):
|
||||||
relation_set(relation_id=relid,
|
relation_set(relation_id=relid,
|
||||||
@ -120,6 +135,8 @@ def zeromq_configuration_relation_joined(relid=None):
|
|||||||
|
|
||||||
|
|
||||||
@hooks.hook('zeromq-configuration-relation-changed')
|
@hooks.hook('zeromq-configuration-relation-changed')
|
||||||
|
@os_workload_status(CONFIGS, REQUIRED_INTERFACES,
|
||||||
|
charm_func=check_optional_relations)
|
||||||
@restart_on_change(restart_map(), stopstart=True)
|
@restart_on_change(restart_map(), stopstart=True)
|
||||||
def zeromq_configuration_relation_changed():
|
def zeromq_configuration_relation_changed():
|
||||||
CONFIGS.write_all()
|
CONFIGS.write_all()
|
||||||
|
@ -10,6 +10,7 @@ from charmhelpers.contrib.openstack.utils import (
|
|||||||
git_clone_and_install,
|
git_clone_and_install,
|
||||||
git_src_dir,
|
git_src_dir,
|
||||||
git_pip_venv_dir,
|
git_pip_venv_dir,
|
||||||
|
set_os_workload_status,
|
||||||
)
|
)
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from charmhelpers.contrib.openstack.utils import (
|
from charmhelpers.contrib.openstack.utils import (
|
||||||
@ -23,6 +24,8 @@ from charmhelpers.contrib.network.ovs import (
|
|||||||
)
|
)
|
||||||
from charmhelpers.core.hookenv import (
|
from charmhelpers.core.hookenv import (
|
||||||
config,
|
config,
|
||||||
|
status_set,
|
||||||
|
status_get,
|
||||||
)
|
)
|
||||||
from charmhelpers.contrib.openstack.neutron import (
|
from charmhelpers.contrib.openstack.neutron import (
|
||||||
parse_bridge_mappings,
|
parse_bridge_mappings,
|
||||||
@ -52,6 +55,15 @@ from charmhelpers.fetch import (
|
|||||||
filter_installed_packages,
|
filter_installed_packages,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# The interface is said to be satisfied if anyone of the interfaces in the
|
||||||
|
# list has a complete context.
|
||||||
|
# LY: Note the neutron-plugin is always present since that is the relation
|
||||||
|
# with the principle and no data currently flows down from the principle
|
||||||
|
# so there is no point in having it in REQUIRED_INTERFACES
|
||||||
|
REQUIRED_INTERFACES = {
|
||||||
|
'messaging': ['amqp', 'zeromq-configuration'],
|
||||||
|
}
|
||||||
|
|
||||||
BASE_GIT_PACKAGES = [
|
BASE_GIT_PACKAGES = [
|
||||||
'libffi-dev',
|
'libffi-dev',
|
||||||
'libssl-dev',
|
'libssl-dev',
|
||||||
@ -140,6 +152,7 @@ DATA_BRIDGE = 'br-data'
|
|||||||
|
|
||||||
|
|
||||||
def install_packages():
|
def install_packages():
|
||||||
|
status_set('maintenance', 'Installing apt packages')
|
||||||
apt_update()
|
apt_update()
|
||||||
# NOTE(jamespage): ensure early install of dkms related
|
# NOTE(jamespage): ensure early install of dkms related
|
||||||
# dependencies for kernels which need
|
# dependencies for kernels which need
|
||||||
@ -151,6 +164,7 @@ def install_packages():
|
|||||||
|
|
||||||
|
|
||||||
def purge_packages(pkg_list):
|
def purge_packages(pkg_list):
|
||||||
|
status_set('maintenance', 'Purging unused apt packages')
|
||||||
purge_pkgs = []
|
purge_pkgs = []
|
||||||
required_packages = determine_packages()
|
required_packages = determine_packages()
|
||||||
for pkg in pkg_list:
|
for pkg in pkg_list:
|
||||||
@ -229,6 +243,7 @@ def get_topics():
|
|||||||
|
|
||||||
|
|
||||||
def configure_ovs():
|
def configure_ovs():
|
||||||
|
status_set('maintenance', 'Configuring ovs')
|
||||||
if not service_running('openvswitch-switch'):
|
if not service_running('openvswitch-switch'):
|
||||||
full_restart()
|
full_restart()
|
||||||
add_bridge(INT_BRIDGE)
|
add_bridge(INT_BRIDGE)
|
||||||
@ -275,6 +290,7 @@ def enable_local_dhcp():
|
|||||||
|
|
||||||
def git_install(projects_yaml):
|
def git_install(projects_yaml):
|
||||||
"""Perform setup, and install git repos specified in yaml parameter."""
|
"""Perform setup, and install git repos specified in yaml parameter."""
|
||||||
|
status_set('maintenance', 'running git install')
|
||||||
if git_install_requested():
|
if git_install_requested():
|
||||||
git_pre_install()
|
git_pre_install()
|
||||||
git_clone_and_install(projects_yaml, core_project='neutron')
|
git_clone_and_install(projects_yaml, core_project='neutron')
|
||||||
@ -364,3 +380,14 @@ def git_post_install(projects_yaml):
|
|||||||
neutron_ovs_cleanup_context, perms=0o644)
|
neutron_ovs_cleanup_context, perms=0o644)
|
||||||
|
|
||||||
service_restart('neutron-plugin-openvswitch-agent')
|
service_restart('neutron-plugin-openvswitch-agent')
|
||||||
|
|
||||||
|
|
||||||
|
def check_optional_relations(configs):
|
||||||
|
required_interfaces = {}
|
||||||
|
if enable_nova_metadata():
|
||||||
|
required_interfaces['neutron-plugin-api'] = ['neutron-plugin-api']
|
||||||
|
if required_interfaces:
|
||||||
|
set_os_workload_status(configs, required_interfaces)
|
||||||
|
return status_get()
|
||||||
|
else:
|
||||||
|
return 'unknown', 'No optional relations'
|
||||||
|
@ -30,6 +30,7 @@ TO_PATCH = [
|
|||||||
'ExternalPortContext',
|
'ExternalPortContext',
|
||||||
'determine_dkms_package',
|
'determine_dkms_package',
|
||||||
'headers_package',
|
'headers_package',
|
||||||
|
'status_set',
|
||||||
]
|
]
|
||||||
|
|
||||||
head_pkg = 'linux-headers-3.15.0-5-generic'
|
head_pkg = 'linux-headers-3.15.0-5-generic'
|
||||||
|
@ -6,6 +6,9 @@ import yaml
|
|||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from mock import patch, MagicMock
|
from mock import patch, MagicMock
|
||||||
|
|
||||||
|
patch('charmhelpers.contrib.openstack.utils.set_os_workload_status').start()
|
||||||
|
patch('charmhelpers.core.hookenv.status_set').start()
|
||||||
|
|
||||||
|
|
||||||
def load_config():
|
def load_config():
|
||||||
'''
|
'''
|
||||||
|
Loading…
Reference in New Issue
Block a user