commit 96fe1114d9e66617550061f8c5c70926336d9f26 Author: Konstantinos Tsakalozos Date: Thu Jan 28 12:19:47 2016 +0200 First working implementation diff --git a/README.md b/README.md new file mode 100644 index 0000000..47f6472 --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +# Overview + +This interface layer handles the communication between the Flume Syslog and the rsyslog-forwarder service. + + +# Usage + +## Provides + +Charms providing this interface are able to recieve/consume system logs. + +This interface layer will set the following states, as appropriate: + + * `{relation_name}.available` The relation to a syslog producer has been established. + If you are providing a service, you can use the following methods to pass the port of the service to the + other end of the relation: + * `send_port(port)` + +For example, let's say that a charm recieves a connection from a syslog producer. +The charm providing the log ingestion service should use this interface in the following way: + +```python +@when('syslog.available') +@when_not('forwarding.ready') +def syslog_forward_connected(syslog): + syslog.send_port(hookenv.config()['source_port']) + set_state('forwarding.ready') +``` + + +## Requires + +This part of the relation has not been implemented yet. + +# Contact Information + +- diff --git a/copyright b/copyright new file mode 100644 index 0000000..e900b97 --- /dev/null +++ b/copyright @@ -0,0 +1,16 @@ +Format: http://dep.debian.net/deps/dep5/ + +Files: * +Copyright: Copyright 2015, Canonical Ltd., All Rights Reserved. +License: Apache License 2.0 + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + . + http://www.apache.org/licenses/LICENSE-2.0 + . + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/interface.yaml b/interface.yaml new file mode 100644 index 0000000..40b3913 --- /dev/null +++ b/interface.yaml @@ -0,0 +1,4 @@ +name: zookeeper-quorum +summary: Interface used by the Apache Zookeeper quorum members +version: 1 +maintainer: "Big Data Team " diff --git a/peers.py b/peers.py new file mode 100644 index 0000000..19bbf36 --- /dev/null +++ b/peers.py @@ -0,0 +1,38 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from charms.reactive import RelationBase, hook, scopes +from charmhelpers.core.hookenv import relation_get, related_units + +class QuorumPeers(RelationBase): + # Every unit connecting will get the same information + scope = scopes.GLOBAL + relation_name = 'zookeeper-quorum' + + @hook('{peers:zookeeper-quorum}-relation-{changed}') + def changed(self): + self.conversation().set_state('{relation_name}.increased') + + + @hook('{peers:zookeeper-quorum}-relation-{departed}') + def departed(self): + self.conversation().set_state('{relation_name}.decreased') + + + def get_nodes(self): + self.conversation().remove_state('{relation_name}.increased') + return related_units() + + + def get_departed(self): + self.conversation().remove_state('{relation_name}.decreased') + return relation_get('private-address')