Add method to decode Rabbit CA cert
If rabbit is running in SSL mode then it will present a base64 encoded CA cert down the relation. Add a methode to retrieve and decode the cert. Change-Id: I1806a5d1bcac6a7ac80f655d96f951f84e9db521
This commit is contained in:
parent
496cbe6dba
commit
adc61d2ff9
4
.gitreview
Normal file
4
.gitreview
Normal file
@ -0,0 +1,4 @@
|
||||
[gerrit]
|
||||
host=review.openstack.org
|
||||
port=29418
|
||||
project=openstack/charm-interface-rabbitmq.git
|
10
requires.py
10
requires.py
@ -11,6 +11,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import base64
|
||||
|
||||
from charms.reactive import RelationBase
|
||||
from charms.reactive import hook
|
||||
from charms.reactive import scopes
|
||||
@ -101,7 +103,7 @@ class RabbitMQRequires(RelationBase):
|
||||
self.request_access(username, vhost)
|
||||
|
||||
def get_remote_all(self, key, default=None):
|
||||
'''Return a list of all values presented by remote units for key'''
|
||||
"""Return a list of all values presented by remote units for key"""
|
||||
values = []
|
||||
for conversation in self.conversations():
|
||||
for relation_id in conversation.relation_ids:
|
||||
@ -115,3 +117,9 @@ class RabbitMQRequires(RelationBase):
|
||||
|
||||
def rabbitmq_hosts(self):
|
||||
return self.get_remote_all('private-address')
|
||||
|
||||
def get_ssl_cert(self):
|
||||
"""Return decoded CA cert from rabbit or None if no CA present"""
|
||||
if self.ssl_ca():
|
||||
return base64.b64decode(self.ssl_ca()).decode('utf-8')
|
||||
return None
|
||||
|
16
tox.ini
16
tox.ini
@ -12,8 +12,22 @@ commands = ostestr {posargs}
|
||||
[testenv:py27]
|
||||
basepython = python2.7
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
# TODO: Need to write unit tests then remove the following command.
|
||||
commands = /bin/true
|
||||
|
||||
[testenv:lint]
|
||||
[testenv:py34]
|
||||
basepython = python3.4
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
# TODO: Need to write unit tests then remove the following command.
|
||||
commands = /bin/true
|
||||
|
||||
[testenv:py35]
|
||||
basepython = python3.5
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
# TODO: Need to write unit tests then remove the following command.
|
||||
commands = /bin/true
|
||||
|
||||
[testenv:pep8]
|
||||
basepython = python2.7
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
commands = flake8 {posargs}
|
||||
|
Loading…
x
Reference in New Issue
Block a user