Merge "Add support for using a vip for access"

This commit is contained in:
Zuul 2018-04-18 13:57:08 +00:00 committed by Gerrit Code Review
commit ef2e3655e4
10 changed files with 42 additions and 3 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ build/*
.stestr/* .stestr/*
__pycache__ __pycache__
.unit-state.db .unit-state.db
interfaces

View File

@ -42,3 +42,8 @@ options:
default: "" default: ""
description: >- description: >-
The SSL Root CA certificate, base64-encoded. The SSL Root CA certificate, base64-encoded.
vip:
type: string
default:
description: |
Virtual IP to use api traffic

View File

@ -5,10 +5,12 @@ includes:
- interface:pgsql - interface:pgsql
- interface:mysql-shared - interface:mysql-shared
- interface:etcd - interface:etcd
- interface:hacluster
options: options:
basic: basic:
packages: packages:
- python3-psycopg2 - python3-psycopg2
- libffi-dev
snap: snap:
vault: vault:
channel: stable channel: stable

View File

@ -23,6 +23,9 @@ requires:
interface: mysql-shared interface: mysql-shared
etcd: etcd:
interface: etcd interface: etcd
ha:
interface: hacluster
scope: container
provides: provides:
nrpe-external-master: nrpe-external-master:
interface: nrpe-external-master interface: nrpe-external-master

View File

@ -338,3 +338,11 @@ def _assess_status():
if service_running('vault'): if service_running('vault'):
health = get_vault_health() health = get_vault_health()
application_version_set(health.get('version')) application_version_set(health.get('version'))
@when('ha.connected')
def cluster_connected(hacluster):
"""Configure HA resources in corosync"""
vip = config('vip')
hacluster.add_vip('vault', vip)
hacluster.bind_resources()

View File

@ -0,0 +1,3 @@
applications:
vault:
charm: ../../../vault

View File

@ -0,0 +1,4 @@
applications:
vault:
options:
vip: '{{ OS_VIP00 }}'

View File

@ -3,7 +3,11 @@ services:
vault: vault:
num_units: 3 num_units: 3
series: xenial series: xenial
charm: ../../../vault charm: cs:vault
options:
vip: 'ADD YOUR VIP HERE'
hacluster:
charm: cs:hacluster
mysql: mysql:
charm: cs:mysql charm: cs:mysql
num_units: 1 num_units: 1
@ -12,7 +16,7 @@ services:
num_units: 1 num_units: 1
etcd: etcd:
charm: cs:etcd charm: cs:etcd
num_units: 2 num_units: 3
options: options:
channel: 3.1/stable channel: 3.1/stable
relations: relations:
@ -22,3 +26,5 @@ relations:
- easyrsa:client - easyrsa:client
- - etcd:db - - etcd:db
- vault:etcd - vault:etcd
- - vault:ha
- hacluster:ha

View File

@ -6,7 +6,7 @@ skipsdist = True
setenv = VIRTUAL_ENV={envdir} setenv = VIRTUAL_ENV={envdir}
PYTHONHASHSEED=0 PYTHONHASHSEED=0
whitelist_externals = juju whitelist_externals = juju
passenv = HOME TERM CS_API_* passenv = HOME TERM CS_API_* OS_*
deps = -r{toxinidir}/test-requirements.txt deps = -r{toxinidir}/test-requirements.txt
install_command = install_command =
pip install {opts} {packages} pip install {opts} {packages}

View File

@ -279,3 +279,10 @@ class TestHandlers(unittest.TestCase):
self.service_running.return_value = False self.service_running.return_value = False
handlers._assess_status() handlers._assess_status()
self.application_version_set.assert_not_called() self.application_version_set.assert_not_called()
def test_cluster_connected(self):
self.config.return_value = '10.1.1.1'
hacluster_mock = mock.MagicMock()
handlers.cluster_connected(hacluster_mock)
hacluster_mock.add_vip.assert_called_once_with('vault', '10.1.1.1')
hacluster_mock.bind_resources.assert_called_once_with()