Advertisement
Guest User

Untitled

a guest
Sep 9th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. from charmhelpers.core import hookenv
  2. from charms.reactive import hook
  3. from charms.reactive import RelationBase
  4. from charms.reactive import scopes
  5.  
  6.  
  7. class JDBCProvides(RelationBase):
  8. # Every unit connecting will get the same information
  9. scope = scopes.GLOBAL
  10.  
  11. # Use some template magic to declare our relation(s)
  12. @hook('{provides:dcos}-relation-{joined,changed}')
  13. def changed(self):
  14. # Signify that the relationship is now available to our principal layer(s)
  15. self.set_state('{relation_name}.available')
  16.  
  17. @hook('{provides:dcos}-relation-{broken,departed}')
  18. def broken(self):
  19. # Remove the state that our relationship is now available to our principal layer(s)
  20. self.remove_state('{relation_name}.available')
  21.  
  22. # call this method when passed into methods decorated with
  23. # @when('{relation}.available')
  24. # to configure the relation data
  25. def configure(self):
  26. relation_info = {
  27. 'hostname': hookenv.unit_get('private-address'),
  28. }
  29. self.set_remote(**relation_info)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement