Created
June 27, 2017 13:35
-
-
Save johnsca/af3e1b70084ca34b85ea493f1caaca77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from charms.reactive.context import relation_endpoint | |
@when('charm.installed', 'relation_endpoint.db.ready') | |
def handler(): | |
render_config(hostnames=relation_endpoint.user_db.hostnames) | |
relation_endpoint.admin_db.hostnames |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CassandraClient(RelationEndpoint): | |
@property | |
def _ready_units(self): | |
ready_units = [] | |
for relation in self.relations: | |
for unit in relation.units: | |
if unit.received_data.foo == 'foo': | |
ready_units.append(unit) | |
return ready_units | |
@property | |
def _unready_units(self): | |
return filter(lambda u: u.received_data.foo != 'foo', | |
(u for r in self.relations for u in r.units)) | |
@property | |
def hostnames(self): | |
return [u.received_data.hostname for u in self._ready_units] | |
@when('relation_endpoint.{relation_endpoint_name}.changed') | |
def changed(self): | |
if self._ready_units: | |
set_flag('relation_endpoint.{relation_endpoint_name}.ready') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Something we lost here is the docstrings for the flags. We'll need some convention for that again.