Ubuntu Pastebin

Paste from LSF Storage Requires.py at Mon, 28 Mar 2016 18:09:00 +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
27
28
29
30
31
32
33
34
35
36
37
38
from charms.reactive import hook
from charms.reactive import RelationBase
from charms.reactive import scopes


class nfsstorageRequires(RelationBase):
    scope = scopes.GLOBAL

    @hook('{requires:nfsstorage}-relation-joined')
    def joined(self):
        print("I am in relation joined state for requires")
        self.set_state('{relation_name}.joined')
        self.remove_state('{relation_name}.ready')
        self.set_remote(data={
            'hostname_storage': 'None',
    })


    @hook('{requires:nfsstorage}-relation-changed')
    def changed(self):
        print("I am in relation changed avaialble state for requires")
        self.set_state('{relation_name}.available')
        print(self.get_remote('hostname_storage'))
        if str(self.get_remote('hostname_storage')) != "None":
               self.set_state('{relation_name}.ready')
               
        
    @hook('{requires:nfsstorage}-relation-departed')
    def departed(self):
        # Remove the state that our relationship is now available to our principal layer(s)
        self.remove_state('{relation_name}.joined')
        self.remove_state('{relation_name}.ready')

    def private_address(self):
        return self.get_remote('private-address')

    def get_hostname(self):
        return self.get_remote('hostname_storage')
Download as text