Require an IP when advertising remote unit

Require that a pacemaker remote unit specifies an IP address for
cluster traffic when joining with an existing cluster. This makes
sure the correct netowrk is used in a network space aware
deployment.

Change-Id: I92b3f2644c7bee4e55463ffaae2769c33458dd16
Closes-Bug: #1824514
This commit is contained in:
Liam Young
2019-04-12 10:25:21 +00:00
parent f1297f72a5
commit 2272b4f503
5 changed files with 56 additions and 6 deletions

4
.gitreview Normal file
View File

@@ -0,0 +1,4 @@
[gerrit]
host=review.openstack.org
port=29418
project=openstack/charm-interface-pacemaker-remote

4
.zuul.yaml Normal file
View File

@@ -0,0 +1,4 @@
- project:
templates:
- python35-charm-jobs
- openstack-cover-jobs

View File

@@ -4,14 +4,27 @@ from charms.reactive import Endpoint
class PacemakerRemoteProvides(Endpoint):
def publish_info(self, remote_hostname, stonith_hostname=None,
def publish_info(self, remote_hostname, remote_ip, stonith_hostname=None,
enable_resources=True):
"""
Publish the stonith info
"""Publish the stonith info.
:param remote_hostname: The hostname of this unit
:type remote_hostname: str
:param remote_ip: The IP address that the c;uster should contanct this
node on.
:type remote_ip: str
:param stonith_hostname: The name used by the stonith device to refer
to this node.
:type stonith_hostname: str
:param enable_resources: Whether this node should run resources from
the cluster.
:type enable_resources: bool
"""
for relation in self.relations:
relation.to_publish['stonith-hostname'] = stonith_hostname
relation.to_publish['remote-hostname'] = remote_hostname
relation.to_publish['remote-ip'] = remote_ip
relation.to_publish['enable-resources'] = enable_resources
def get_pacemaker_key(self):

33
tox.ini
View File

@@ -1,6 +1,6 @@
[tox]
skipsdist = True
envlist = pep8,py3
envlist = pep8,py35
skip_missing_interpreters = True
[testenv]
@@ -10,8 +10,8 @@ setenv = VIRTUAL_ENV={envdir}
install_command =
pip install {opts} {packages}
[testenv:py3]
basepython = python3
[testenv:py35]
basepython = python3.5
deps = -r{toxinidir}/test-requirements.txt
commands = stestr run {posargs}
@@ -20,6 +20,33 @@ basepython = python3
deps = -r{toxinidir}/test-requirements.txt
commands = flake8 {posargs} .
[testenv:cover]
# Technique based heavily upon
# https://github.com/openstack/nova/blob/master/tox.ini
basepython = python3
deps = -r{toxinidir}/test-requirements.txt
setenv =
{[testenv]setenv}
PYTHON=coverage run
commands =
coverage erase
stestr run {posargs}
coverage combine
coverage html -d cover
coverage xml -o cover/coverage.xml
coverage report
[coverage:run]
branch = True
concurrency = multiprocessing
parallel = True
source =
.
omit =
.tox/*
*/charmhelpers/*
unit_tests/*
[testenv:venv]
commands = {posargs}

View File

@@ -101,10 +101,12 @@ class TestPacemakerRemoteProvides(unittest.TestCase):
self.relation_obj._relations = [mock_rel]
self.relation_obj.publish_info(
'node1.az1.local',
'10.0.0.10',
stonith_hostname='node1.stonith',
enable_resources=True)
expect = {
'remote-hostname': 'node1.az1.local',
'remote-ip': '10.0.0.10',
'stonith-hostname': 'node1.stonith',
'enable-resources': True}
self.assertEqual(