1 # Copyright 2020 Canonical Ltd.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 from charms
.reactive
import Endpoint
15 from charms
.reactive
import when
16 from charms
.reactive
import set_flag
, clear_flag
19 class KeystoneRequires(Endpoint
):
20 @when("endpoint.{endpoint_name}.joined")
22 set_flag(self
.expand_name("{endpoint_name}.joined"))
24 @when("endpoint.{endpoint_name}.changed")
26 if len(self
.keystones()) > 0:
27 set_flag(self
.expand_name("{endpoint_name}.ready"))
29 clear_flag(self
.expand_name("{endpoint_name}.ready"))
31 @when("endpoint.{endpoint_name}.departed")
33 set_flag(self
.expand_name("{endpoint_name}.departed"))
34 clear_flag(self
.expand_name("{endpoint_name}.joined"))
35 clear_flag(self
.expand_name("{endpoint_name}.ready"))
43 'keystone_db_password: <keystone_db_password>,
44 'region_id: <region_id>,
45 'admin_username: <admin_username>,
46 'admin_password: <admin_password>,
47 'admin_project_name: <admin_project_name>,
48 'username: <username>,
49 'password: <password>,
54 for relation
in self
.relations
:
55 for unit
in relation
.units
:
57 "host": unit
.received
["host"],
58 "port": unit
.received
["port"],
59 "keystone_db_password": unit
.received
["keystone_db_password"],
60 "region_id": unit
.received
["region_id"],
61 "user_domain_name": unit
.received
["user_domain_name"],
62 "project_domain_name": unit
.received
["project_domain_name"],
63 "admin_username": unit
.received
["admin_username"],
64 "admin_password": unit
.received
["admin_password"],
65 "admin_project_name": unit
.received
["admin_project_name"],
66 "username": unit
.received
["username"],
67 "password": unit
.received
["password"],
68 "service": unit
.received
["service"],
70 if all(data
.values()):
71 keystones
.append(data
)