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

« back to all changes in this revision

Viewing changes to hooks/relations/ibm-mq/provides.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
8
7
    # Every unit connecting will get the same information
9
8
    scope = scopes.SERVICE
10
9
 
11
 
    # convenient way to provide accessor methods
12
 
    auto_accessors = ['QM_Name','QName','host', 'port']
13
 
 
14
10
    @hook('{provides:ibm-mq}-relation-joined')
15
11
    def joined(self):
16
12
        conversation = self.conversation()
23
19
        conversation.remove_state('{relation_name}.connected')
24
20
        conversation.set_state('{relation_name}.departed')
25
21
 
26
 
    def dismiss(self,service):
 
22
    def dismiss(self, service):
27
23
        conversation = self.conversation(service)
28
24
        conversation.remove_state('{relation_name}.departed')
29
25
 
30
 
    def reset_states(self,service):
 
26
    def reset_states(self, service):
31
27
        conversation = self.conversation(service)
32
28
        conversation.remove_state('{relation_name}.connected')
33
29
        conversation.remove_state('{relation_name}.departed')
34
30
 
35
 
    def set_mq_details(self,service,QM_Name,Qname,host,port):
 
31
    def set_mq_details(self, service, QM_Name, Qname, host, port):
36
32
        conversation = self.conversation(service)
37
33
        conversation.set_remote(data={
38
 
            'QM_Name':QM_Name,
39
 
            'Qname':Qname,
40
 
            'host':host,
41
 
            'port':port,
 
34
            'QM_Name': QM_Name,
 
35
            'Qname': Qname,
 
36
            'host': host,
 
37
            'port': port,
42
38
        })
 
39
 
43
40
    def get_consumer_hostname(self):
44
41
        return self.get_remote('host')
45
42