~ibmcharmers/charms/trusty/ibm-mq/devel

« back to all changes in this revision

Viewing changes to hooks/relations/ibm-mq/requires.py

  • Committer: anitanayak at ibm
  • Date: 2017-02-15 08:54:14 UTC
  • Revision ID: anitanayak@in.ibm.com-20170215085414-hdjj8hr2tssjolt2
checkin after review comment incorporation to interface interface-ibm-mq

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from charmhelpers.core import hookenv
2
1
from charms.reactive import hook
3
2
from charms.reactive import RelationBase
4
3
from charms.reactive import scopes
7
6
class mq1Requires(RelationBase):
8
7
    scope = scopes.GLOBAL
9
8
 
10
 
#    auto_accessors = ['QM_Name','Qname','host','port']
11
 
 
12
9
    @hook('{requires:ibm-mq}-relation-joined')
13
10
    def joined(self):
14
11
        self.remove_state('{relation_name}.departed')
16
13
 
17
14
    @hook('{requires:ibm-mq}-relation-changed')
18
15
    def changed(self):
19
 
        self.set_state('{relation_name}.available')
20
 
        print("Status is relation_name.available in requires")
21
16
        if str(self.get_remote('port')) != "None":
22
 
               self.set_state('{relation_name}.ready')
23
 
               print("Status is relation_name.ready in requires")
 
17
            self.set_state('{relation_name}.ready')
 
18
            print("Status is relation_name.ready in requires")
24
19
 
25
20
    @hook('{requires:ibm-mq}-relation-departed')
26
21
    def departed(self):
27
22
        self.remove_state('{relation_name}.connected')
28
 
        self.remove_state('{relation_name}.available')
29
23
        self.remove_state('{relation_name}.ready')
30
24
        self.set_state('{relation_name}.departed')
31
25
 
32
 
    def set_hostname(self,host):
 
26
    def set_hostname(self, host):
33
27
        conversation = self.conversation()
34
28
        conversation.set_remote(data={
35
 
            'host':host,
 
29
            'host': host,
36
30
        })
37
31
 
38
32
    def get_qm_name(self):
39
33
        return self.get_remote('QM_Name')
 
34
 
40
35
    def get_qname(self):
41
36
        return self.get_remote('Qname')
 
37
 
42
38
    def get_mq_hostname(self):
43
39
        return self.get_remote('host')
 
40
 
44
41
    def get_mq_port(self):
45
42
        return self.get_remote('port')
46