Initial code drop
This commit is contained in:
commit
06f492983b
|
@ -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'
|
|
@ -0,0 +1,3 @@
|
|||
name: odl-controller-api
|
||||
summary: Interface for intergrating with an OpenDayLight Controller RESTful API
|
||||
maintainer: James Page <james.page@ubuntu.com>
|
|
@ -0,0 +1,38 @@
|
|||
from charmhelpers.core.reactive import hook
|
||||
from charmhelpers.core.reactive import RelationBase
|
||||
from charmhelpers.core.reactive import scopes
|
||||
|
||||
|
||||
class ControllerAPIRequires(RelationBase):
|
||||
scope = scopes.GLOBAL
|
||||
auto_accessors = ['private-address', 'host', 'port',
|
||||
'username', 'password']
|
||||
|
||||
@hook('{requires:odl-controller-api}-relation-{joined,changed,departed}')
|
||||
def changed(self):
|
||||
self.set_state('{relation_name}.connected')
|
||||
if self.connection():
|
||||
self.set_state('{relation_name}.access.available')
|
||||
else:
|
||||
self.remove_state('{relation_name}.access.available')
|
||||
|
||||
@hook('{requires:odl-controller-api}-relation-broken')
|
||||
def broken(self):
|
||||
self.remove_state('{relation_name}.connected')
|
||||
self.remove_state('{relation_name}.access.available')
|
||||
|
||||
def connection(self):
|
||||
"""OpenDayLight Controller Access Details
|
||||
|
||||
Returns a dict of key value pairs for accessing the ODL controller API.
|
||||
"""
|
||||
data = {
|
||||
'host': self.host() or self.private_address(),
|
||||
'port': self.port() or '8181',
|
||||
'username': self.username(),
|
||||
'password': self.password(),
|
||||
}
|
||||
if all(data.values()):
|
||||
return data
|
||||
else:
|
||||
return None
|
Loading…
Reference in New Issue