~ibmcharmers/interface-ibm-nfsstorage/trunk

« back to all changes in this revision

Viewing changes to requires.py

  • Committer: Kevin W. Monroe
  • Date: 2016-10-19 16:37:29 UTC
  • Revision ID: kevin.monroe@canonical.com-20161019163729-p2ynu5hfhjrrk8w1
lint fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
from charms.reactive import hook
2
2
from charms.reactive import RelationBase
3
3
from charms.reactive import scopes
4
 
from charmhelpers.core import (
5
 
    hookenv,
6
 
)
 
4
 
7
5
 
8
6
class nfsstorageRequires(RelationBase):
9
7
    scope = scopes.GLOBAL
10
 
    
 
8
 
11
9
    @hook('{requires:nfsstorage}-relation-joined')
12
10
    def joined(self):
13
11
        self.remove_state('{relation_name}.departing')
14
12
        self.set_state('{relation_name}.joined')
15
 
               
16
13
 
17
14
    @hook('{requires:nfsstorage}-relation-changed')
18
15
    def changed(self):
19
16
        self.remove_state('{relation_name}.departing')
20
17
        if (str(self.get_remote('hostname_storage')) != "None"):
21
18
            self.set_state('{relation_name}.available')
22
 
               
23
 
        
 
19
 
24
20
    @hook('{requires:nfsstorage}-relation-departed')
25
21
    def departed(self):
26
 
        # Remove the state that our relationship is now available to our principal layer(s)
 
22
        # Remove the joined/available states on charm departure
27
23
        self.remove_state('{relation_name}.available')
28
24
        self.remove_state('{relation_name}.joined')
29
25
        self.set_state('{relation_name}.departing')
30
26
 
31
 
 
32
27
    def private_address(self):
33
28
        return self.get_remote('private-address')
34
29
 
35
 
    
36
30
    def get_hostname(self):
37
31
        return self.get_remote('hostname_storage')
38
 
 
39
 
 
40