Ubuntu Pastebin

Paste from shruthima at Thu, 6 Oct 2016 16:10:21 +0000

Download as text
 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
### provides.py

from charmhelpers.core import hookenv
from charms.reactive import hook
from charms.reactive import RelationBase
from charms.reactive import scopes


class HttpProvides(RelationBase):
    scope = scopes.GLOBAL

    @hook('{provides:http}-relation-{joined,changed}')
    def changed(self):
        self.set_state('{relation_name}.available')

    @hook('{provides:http}-relation-{broken,departed}')
    def broken(self):
        self.remove_state('{relation_name}.available')

    def configure(self, port, httpsport):
        relation_info = {
            'hostname': hookenv.unit_get('private-address'),
            'port': port,
            'httpsport': httpsport,
        }
        self.set_remote(**relation_info)
Download as text