forked from gabriel-samfira/interface-trustee
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b5abfee
Showing
4 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Trustee interface | ||
|
||
This interface implements the trustee domain interface. You will need a version of the keystone charm that implements the trustee interface. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0 | ||
|
||
Files: * | ||
Copyright: 2018, Cloudbase Solutions SRL | ||
License: Proprietary | ||
|
||
License: Proprietary |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: trustee | ||
summary: Interface for requesting the creation of trustee domains | ||
maintainer: Gabriel Adrian Samfira <[email protected]> | ||
ignore: | ||
- 'unit_tests' | ||
- 'Makefile' | ||
- '.testr.conf' | ||
- 'test-requirements.txt' | ||
- 'tox.ini' | ||
- '.gitignore' | ||
- '.gitreview' | ||
- '.unit-state.db' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/python | ||
# Copyright 2018 Cloudbase Solutions SRL | ||
|
||
from charms.reactive import RelationBase | ||
from charms.reactive import hook | ||
from charms.reactive import scopes | ||
|
||
|
||
class TrusteeRequires(RelationBase): | ||
scope = scopes.GLOBAL | ||
|
||
# These remote data fields will be automatically mapped to accessors | ||
# with a basic documentation string provided. | ||
|
||
auto_accessors = [ | ||
'domain_name', 'domain_admin_name', 'domain_admin_password'] | ||
|
||
@hook('{requires:trustee}-relation-joined') | ||
def joined(self): | ||
self.set_state('{relation_name}.connected') | ||
self.update_state() | ||
|
||
def update_state(self): | ||
if self.base_data_complete(): | ||
self.remove_state('{relation_name}.departed') | ||
self.set_state('{relation_name}.available') | ||
else: | ||
self.remove_state('{relation_name}.available') | ||
|
||
@hook('{requires:trustee}-relation-changed') | ||
def changed(self): | ||
self.update_state() | ||
|
||
@hook('{requires:trustee}-relation-{broken,departed}') | ||
def departed(self): | ||
self.remove_state('{relation_name}.available') | ||
self.set_state('{relation_name}.departed') | ||
|
||
def base_data_complete(self): | ||
data = { | ||
"domain_name": self.domain_name(), | ||
"domain_admin_password": self.domain_admin_password(), | ||
"domain_admin_name": self.domain_admin_name(), | ||
} | ||
return all(data.values()) | ||
|
||
def request_domain(self, domain_name, admin_user): | ||
relation_info = { | ||
'domain': domain_name, | ||
'username': admin_user, | ||
} | ||
self.set_local(**relation_info) | ||
self.set_remote(**relation_info) |