2 # Copyright 2020 Canonical Ltd.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 from charms
.reactive
import RelationBase
17 from charms
.reactive
import hook
18 from charms
.reactive
import scopes
21 class OsmROProvides(RelationBase
):
24 @hook("{provides:osm-ro}-relation-joined")
26 self
.set_state("{relation_name}.joined")
28 @hook("{provides:osm-ro}-relation-changed")
30 self
.set_state("{relation_name}.ready")
32 @hook("{provides:osm-ro}-relation-{broken,departed}")
33 def broken_departed(self
):
34 self
.remove_state("{relation_name}.ready")
35 self
.remove_state("{relation_name}.joined")
37 @hook("{provides:osm-ro}-relation-broken")
39 self
.set_state("{relation_name}.removed")
41 def send_connection(self
, host
, port
=9090):
42 conv
= self
.conversation()
43 conv
.set_remote("host", host
)
44 conv
.set_remote("port", port
)