summaryrefslogtreecommitdiff
path: root/charm/reactive/aodh_handlers.py
blob: 9c88b5b9efcb57006a6f31b98790e46058921b0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from charmhelpers.core.hookenv import (
    status_set,
)
from charms.reactive import (
    when,
    when_not,
    when_not_all,
    set_state,
    remove_state,
)
from charm.openstack.aodh import AodhCharmFactory


@when_not('charm.installed')
def install_packages():
    charm = AodhCharmFactory.charm()
    charm.configure_source()
    charm.install()
    set_state('charm.installed')


@when('amqp.connected')
def setup_amqp_req(amqp):
    amqp.request_access(username='aodh',
                        vhost='openstack')


@when('identity-service.connected')
def setup_endpoint(keystone):
    charm = AodhCharmFactory.charm()
    keystone.register_endpoints(charm.service_type,
                                charm.region,
                                charm.public_url,
                                charm.internal_url,
                                charm.admin_url)


@when('mongodb.database.available')
@when('identity-service.available')
@when('amqp.available')
def render_stuff(amqp_interface, identity_interface, db_interface):
    charm = AodhCharmFactory.charm(
        interfaces=[amqp_interface, identity_interface, db_interface]
    )
    charm.render_config()
    set_state('relations.complete')


@when_not_all('mongodb.database.available',
              'identity-service.available',
              'amqp.available')
def relations_incomplete():
    # TODO: put in some sort of evaluation to give details
    status_set('waiting', 'Waiting for relations')
    remove_state('relations.complete')


@when('relations.complete')
def assess_status():
    # TODO: actually determine services are running and active.
    status_set('active', 'Unit is ready')