from charmhelpers.core import hookenv
from charms.reactive import hook
from charms.reactive import RelationBase
from charms.reactive import scopes
class nfsstorageProvides(RelationBase):
# Every unit connecting will get the same information
scope = scopes.UNIT
# Use some template magic to declare our relation(s)
@hook('{provides:nfsstorage}-relation-joined')
def joined(self):
print("I am in relation joined state for provides")
self.set_state('{relation_name}.joined')
@hook('{provides:nfsstorage}-relation-changed')
def changed(self):
print("I am in relation changed avaialble state for provides")
self.set_state('{relation_name}.available')
@hook('{provides: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}.available')
def host_name(self, hostname_storage):
self.set_remote(data={
'hostname_storage': hostname_storage,
})
def nfsclient_ip(self):
return self.get_remote('private-address')