~anitanayak/interface-ibm-wxs/interface-ibm-wxs-branch

« back to all changes in this revision

Viewing changes to requires.py

  • Committer: Anita Nayak
  • Date: 2016-10-24 06:00:43 UTC
  • Revision ID: anitanayak@in.ibm.com-20161024060043-bomo3qiimyuc2fno
commiting after lint errors fixed

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Licensed under the Apache License, Version 2.0 (the "License");
 
2
# you may not use this file except in compliance with the License.
 
3
# You may obtain a copy of the License at
 
4
#
 
5
#     http://www.apache.org/licenses/LICENSE-2.0
 
6
#
 
7
# Unless required by applicable law or agreed to in writing, software
 
8
# distributed under the License is distributed on an "AS IS" BASIS,
 
9
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
10
# See the License for the specific language governing permissions and
 
11
# limitations under the License.
 
12
# from charmhelpers.core import hookenv
 
13
from charms.reactive import hook
 
14
from charms.reactive import RelationBase
 
15
from charms.reactive import scopes
 
16
 
 
17
 
 
18
class WXSRequires(RelationBase):
 
19
    scope = scopes.GLOBAL
 
20
 
 
21
    auto_accessors = ['wxs_catalog_ip', 'wxs_catalog_port']
 
22
 
 
23
    @hook('{requires:ibm-wxs}-relation-joined')
 
24
    def joined(self):
 
25
        self.set_state('{relation_name}.available')
 
26
 
 
27
    @hook('{requires:ibm-wxs}-relation-changed')
 
28
    def changed(self):
 
29
        print("Status is ibm-wxs.available in requires")
 
30
        if str(self.get_remote('wxs_catalog_port')) != "None":
 
31
            self.set_state('{relation_name}.ready')
 
32
            print("Status is relation_name.available in requires")
 
33
 
 
34
    @hook('{requires:ibm-wxs}-relation-departed')
 
35
    def departed(self):
 
36
        self.remove_state('{relation_name}.available')
 
37
        self.remove_state('{relation_name}.ready')
 
38
 
 
39
    def get_wxs_catalog_port(self):
 
40
        return self.get_remote('wxs_catalog_port')
 
41
 
 
42
    def get_wxs_catalog_ip(self):
 
43
        return self.get_remote('wxs_catalog_ip')