Explorar el Código

Hold services down until config rendered

Change-Id: I1dc570a26bfa97f5612c7b82f06181b2f4e6a665
Closes-Bug: #1837379
changes/11/672011/2
Frode Nordahl hace 8 meses
padre
commit
871bcaaeb3
No se encontró ninguna clave conocida en la base de datos para esta firma ID de clave GPG: 6A5D59A3BA48373F
Se han modificado 3 ficheros con 35 adiciones y 0 borrados
  1. +13
    -0
      src/lib/charm/openstack/dragent.py
  2. +16
    -0
      src/reactive/dragent_handlers.py
  3. +6
    -0
      unit_tests/test_dragent_handlers.py

+ 13
- 0
src/lib/charm/openstack/dragent.py Ver fichero

@@ -19,6 +19,7 @@ from __future__ import absolute_import

import collections

import charmhelpers.core as ch_core
import charmhelpers.contrib.network.ip as ch_ip

import charms_openstack.charm
@@ -155,6 +156,18 @@ class DRAgentCharm(charms_openstack.charm.OpenStackCharm):
self.release_pkg,
self.package_codenames)

def disable_services(self):
"""Disble services, typically used awaiting required relations."""
for service in self.services:
ch_core.host.service('disable', service)
ch_core.host.service('stop', service)

def enable_services(self):
"""Enable services, typically used when required relations complete."""
for service in self.services:
ch_core.host.service('enable', service)
ch_core.host.service('start', service)


class RockyDRAgentCharm(DRAgentCharm):



+ 16
- 0
src/reactive/dragent_handlers.py Ver fichero

@@ -63,6 +63,21 @@ def configure_ssl(amqp):
instance.configure_ssl()


@reactive.when('charm.installed')
@reactive.when_not('config.rendered')
def disable_services():
with charm.provide_charm_instance() as instance:
instance.disable_services()
instance.assess_status()


@reactive.when('config.rendered')
def enable_services():
with charm.provide_charm_instance() as instance:
instance.enable_services()
instance.assess_status()


@reactive.when('amqp.available')
def render_configs(*args):
"""Render the configuration for dynamic routing when all the interfaces are
@@ -71,4 +86,5 @@ def render_configs(*args):
with charm.provide_charm_instance() as instance:
instance.upgrade_if_available(args)
instance.render_with_interfaces(args)
reactive.set_flag('config.rendered')
instance.assess_status()

+ 6
- 0
unit_tests/test_dragent_handlers.py Ver fichero

@@ -40,6 +40,11 @@ class TestDRAgentHooks(test_utils.TestRegisteredHooks):
'setup_amqp_req': ('amqp.connected', ),
'render_configs': ('amqp.available', ),
'configure_ssl': ('amqp.available.ssl', ),
'enable_services': ('config.rendered',),
'disable_services': ('charm.installed',),
},
'when_not': {
'disable_services': ('config.rendered',),
},
}
self.registered_hooks_test_helper(handlers, hook_set, defaults)
@@ -92,4 +97,5 @@ class TestDRAgentHandlers(test_utils.PatchHelper):
(amqp,))
self.dragent_charm.render_with_interfaces.assert_called_once_with(
(amqp,))
self.set_flag.assert_called_once_with('config.rendered')
self.dragent_charm.assess_status.assert_called_once()

Cargando…
Cancelar
Guardar