From 23eb7e6fb285b0950b85486145c4c62fa8922f17 Mon Sep 17 00:00:00 2001 From: Liam Young Date: Mon, 25 Apr 2016 11:52:14 -0500 Subject: [PATCH] Add ha interface --- .gitignore | 2 ++ Makefile | 3 ++- charm/config.yaml | 20 ++++++++++++++++++++ charm/layer.yaml | 2 +- charm/metadata.yaml | 3 +++ charm/reactive/designate_handlers.py | 15 ++++++++++++++- tox.ini | 2 +- 7 files changed, 43 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 8dc993b..3f50ad6 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ build layers .tox interfaces +builds +deps diff --git a/Makefile b/Makefile index 417a556..10bd4fb 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,9 @@ #!/usr/bin/make LAYER_PATH := layers +INTERFACE_PATH := interfaces clean: rm -Rf build generate: clean - LAYER_PATH=$(LAYER_PATH) tox -e generate + LAYER_PATH=$(LAYER_PATH) INTERFACE_PATH=$(INTERFACE_PATH) tox -e generate diff --git a/charm/config.yaml b/charm/config.yaml index f359213..5d05546 100644 --- a/charm/config.yaml +++ b/charm/config.yaml @@ -23,3 +23,23 @@ options: default: 'email@example.com' type: string description: Email address of the person responsible for the domain. + vip: + type: string + default: + description: | + Virtual IP(s) to use to front API services in HA configuration. + + If multiple networks are being used, a VIP should be provided for each + network, separated by spaces. + vip_iface: + type: string + default: eth0 + description: | + Default network interface to use for HA vip when it cannot be + automatically determined. + vip_cidr: + type: int + default: 24 + description: | + Default CIDR netmask to use for HA vip when it cannot be automatically + determined. diff --git a/charm/layer.yaml b/charm/layer.yaml index 0ff2153..c5a97bb 100644 --- a/charm/layer.yaml +++ b/charm/layer.yaml @@ -1 +1 @@ -includes: ['layer:openstack-api', 'interface:bind-rndc'] +includes: ['layer:openstack-api', 'interface:bind-rndc', 'interface:hacluster'] diff --git a/charm/metadata.yaml b/charm/metadata.yaml index 7c81e85..8ea7ac9 100644 --- a/charm/metadata.yaml +++ b/charm/metadata.yaml @@ -21,3 +21,6 @@ provides: requires: dns-backend: interface: bind-rndc + ha: + interface: hacluster + scope: container diff --git a/charm/reactive/designate_handlers.py b/charm/reactive/designate_handlers.py index e058d1f..d881d24 100644 --- a/charm/reactive/designate_handlers.py +++ b/charm/reactive/designate_handlers.py @@ -1,10 +1,14 @@ -from charmhelpers.core.hookenv import unit_private_ip +from charmhelpers.core.hookenv import unit_private_ip, config from charms.reactive import ( hook, when, ) from charm.openstack.designate import DesignateCharmFactory +import ipaddress +from relations.hacluster.common import CRM +from relations.hacluster.common import ResourceDescriptor +from charm.openstack.charm import VirtualIP @hook('install') def install_packages(): @@ -51,3 +55,12 @@ def render_stuff(amqp_interface, identity_interface, db_interface, charm.db_sync() charm.create_domains() charm.render_full_config() + +@when('ha.connected') +def cluster_connected(hacluster): + user_config = config() + resources = CRM() + resources.add(VirtualIP(user_config['vip'])) + + hacluster.bind_on(iface=user_config['vip_iface'], mcastport=4440) + hacluster.manage_resources(resources) diff --git a/tox.ini b/tox.ini index fe8221d..0a4f6c4 100644 --- a/tox.ini +++ b/tox.ini @@ -18,7 +18,7 @@ deps = [testenv:generate] basepython = python2.7 commands = - charm generate --log-level DEBUG -o {toxinidir}/build charm + charm build --log-level DEBUG -o {toxinidir}/build charm [testenv:venv] commands = {posargs}