First working implementation

This commit is contained in:
Konstantinos Tsakalozos 2016-01-28 12:19:47 +02:00
commit 96fe1114d9
4 changed files with 95 additions and 0 deletions

37
README.md Normal file
View File

@ -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
- <bigdata@lists.ubuntu.com>

16
copyright Normal file
View File

@ -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.

4
interface.yaml Normal file
View File

@ -0,0 +1,4 @@
name: zookeeper-quorum
summary: Interface used by the Apache Zookeeper quorum members
version: 1
maintainer: "Big Data Team <bigdata@lists.ubuntu.com>"

38
peers.py Normal file
View File

@ -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')