initial commit

This commit is contained in:
Chris Holcombe 2016-08-25 09:21:17 -07:00
commit a938732659
2 changed files with 48 additions and 0 deletions

3
interface.yaml Normal file
View File

@ -0,0 +1,3 @@
name: ceph-admin
summary: Ceph Admin Client Interface
version: 1

45
requires.py Normal file
View File

@ -0,0 +1,45 @@
from charms.reactive import hook
from charms.reactive import RelationBase
from charms.reactive import scopes
from charms.reactive import is_state
class CephClient(RelationBase):
scope = scopes.GLOBAL
auto_accessors = ['key', 'auth', 'public_address']
@hook('{requires:ceph-admin}-relation-{joined,changed}')
def changed(self):
self.set_state('{relation_name}.connected')
key = None
auth = None
public_addr = None
try:
key = self.key
except AttributeError:
pass
try:
auth = self.auth
except AttributeError:
pass
try:
public_addr = self.public_address
except AttributeError:
pass
data = {
'key': key,
'auth': auth,
'public_address': public_addr
}
if all(data.values()):
self.set_state('{relation_name}.available')
@hook('{requires:ceph-admin}-relation-{broken,departed}')
def broken(self):
if is_state('{relation_name}.available'):
self.remove_state('{relation_name}.available')