~brad-marshall/charms/trusty/thruk-external-agent/trunk

« back to all changes in this revision

Viewing changes to hooks/thruk_helpers.py

  • Committer: Brad Marshall
  • Date: 2015-04-10 07:55:20 UTC
  • Revision ID: brad.marshall@canonical.com-20150410075520-7vlibzeiq0wpa0nu
[bradm] Initial commit, untested

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
from charmhelpers.core import hookenv
 
4
from charmhelpers.core.services import helpers
 
5
 
 
6
import hashlib
 
7
 
 
8
 
 
9
class ThrukAgentRelation(helpers.RelationContext):
 
10
    """
 
11
    Relation context for the `thruk-agent` interface.
 
12
 
 
13
    :param str name: Override the relation :attr:`name`, since it can vary from charm to charm
 
14
    :param list additional_required_keys: Extend the list of :attr:`required_keys`
 
15
    """
 
16
    name = 'thruk-agent'
 
17
    interface = 'thruk-agent'
 
18
 
 
19
    def provide_data(self):
 
20
        m = hashlib.md5()
 
21
        m.update(hookenv.config('nagios_context'))
 
22
        thruk_id = m.hexdigest()
 
23
 
 
24
        return {
 
25
            'host': hookenv.config('host'),
 
26
            'port': hookenv.config('port'),
 
27
            'nagios_context': hookenv.config('nagios_context'),
 
28
            'thruk_key': hookenv.config('thruk_key'),
 
29
            'thruk_id': thruk_id,
 
30
        }