Initial commit of ovsdb-manager interface

This commit is contained in:
James Page 2015-07-15 12:02:56 +01:00
commit 58cc18fe40
4 changed files with 52 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
bin
.settings

9
copyright Normal file
View File

@ -0,0 +1,9 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0
Files: *
Copyright: 2015, Canonical Ltd.
License: GPL-3
License: GPL-3
On Debian GNU/Linux system you can find the complete text of the
GPL-3 license in '/usr/share/common-licenses/GPL-3'

3
interface.yaml Normal file
View File

@ -0,0 +1,3 @@
name: ovsdb-manager
summary: Interface for relating to the OVSDB manager aspect of OpenDayLight SDN
maintainer: James Page <james.page@ubuntu.com>

38
requires.py Normal file
View File

@ -0,0 +1,38 @@
from charmhelpers.core.reactive import hook
from charmhelpers.core.reactive import RelationBase
from charmhelpers.core.reactive import scopes
class OVSDBManagerRequires(RelationBase):
scope = scopes.GLOBAL
auto_accessors = ['protocol', 'private-address', 'host', 'port']
@hook('{requires:ovsdb-manager}-relation-{joined,changed,departed}')
def changed(self):
self.set_state('{relation_name}.connected')
if self.connection_string():
self.set_state('{relation_name}.access.available')
else:
self.remove_state('{relation_name}.access.available')
@hook('{requires:ovsdb-manager}-relation-broken')
def broken(self):
self.remove_state('{relation_name}.connected')
self.remove_state('{relation_name}.access.available')
def connection_string(self):
"""Open vSwitch connection string
Returns the connection string to use for Open vSwitch or None
if the remote ODL controller has not presented this data
yet.
"""
data = {
'host': self.host() or self.private_address(),
'port': self.port() or '6640',
'protocol': self.protocol(),
}
if all(data.values()):
return "{protocol}:{host}:{port}".format(**data)
else:
return None