~ibmcharmers/interface-ibm-mq/devel

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
from charms.reactive import hook
from charms.reactive import RelationBase
from charms.reactive import scopes


class mq1Requires(RelationBase):
    scope = scopes.GLOBAL

    @hook('{requires:ibm-mq}-relation-joined')
    def joined(self):
        self.remove_state('{relation_name}.departed')
        self.set_state('{relation_name}.connected')

    @hook('{requires:ibm-mq}-relation-changed')
    def changed(self):
        if str(self.get_remote('port')) != "None":
            self.set_state('{relation_name}.ready')
            print("Status is relation_name.ready in requires")

    @hook('{requires:ibm-mq}-relation-departed')
    def departed(self):
        self.remove_state('{relation_name}.connected')
        self.remove_state('{relation_name}.ready')
        self.set_state('{relation_name}.departed')

    def set_hostname(self, host):
        conversation = self.conversation()
        conversation.set_remote(data={
            'host': host,
        })

    def get_qm_name(self):
        return self.get_remote('QM_Name')

    def get_qname(self):
        return self.get_remote('Qname')

    def get_mq_hostname(self):
        return self.get_remote('host')

    def get_mq_port(self):
        return self.get_remote('port')