~ibmcharmers/interface-cinder-backend/trunk

« back to all changes in this revision

Viewing changes to provides.py

  • Committer: anitanayak at ibm
  • Date: 2017-02-10 06:53:22 UTC
  • Revision ID: anitanayak@in.ibm.com-20170210065322-3p1476r5zh8s2qhr
Initial checkin for interface cinder-backend

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from charms.reactive import hook
 
2
from charms.reactive import RelationBase
 
3
from charms.reactive import scopes
 
4
 
 
5
 
 
6
class driverProvides(RelationBase):
 
7
    # Every unit connecting will get the same information
 
8
    scope = scopes.GLOBAL
 
9
 
 
10
    @hook('{provides:cinder-backend}-relation-{joined,changed}')
 
11
    def changed(self):
 
12
        conversation = self.conversation()
 
13
        conversation.set_state('{relation_name}.available')
 
14
        conversation.remove_state('{relation_name}.departing')
 
15
 
 
16
    @hook('{provides:cinder-backend}-relation-{broken,departed}')
 
17
    def broken(self):
 
18
        conversation = self.conversation()
 
19
        conversation.remove_state('{relation_name}.available')
 
20
        conversation.set_state('{relation_name}.departing')