Merge lp:~thedac/charm-helpers/dnsha into lp:charm-helpers

Proposed by David Ames
Status: Merged
Merged at revision: 590
Proposed branch: lp:~thedac/charm-helpers/dnsha
Merge into: lp:charm-helpers
Diff against target: 194 lines (+51/-8)
4 files modified
charmhelpers/contrib/hahelpers/cluster.py (+3/-3)
charmhelpers/contrib/openstack/ha/utils.py (+20/-1)
tests/contrib/hahelpers/test_cluster_utils.py (+8/-1)
tests/contrib/openstack/ha/test_ha_utils.py (+20/-3)
To merge this branch: bzr merge lp:~thedac/charm-helpers/dnsha
Reviewer Review Type Date Requested Status
charmers Pending
Review via email: mp+297806@code.launchpad.net

Description of the change

More DNS HA helpers

Add assert DNS HA function to validate charm environment
Add os-access-hostname to DNS HA functions for percona-cluster

To post a comment you must log in.
lp:~thedac/charm-helpers/dnsha updated
590. By James Page

Updates for DNS-HA support in non-api OpenStack charms.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/contrib/hahelpers/cluster.py'
2--- charmhelpers/contrib/hahelpers/cluster.py 2016-06-14 16:27:30 +0000
3+++ charmhelpers/contrib/hahelpers/cluster.py 2016-06-17 20:11:41 +0000
4@@ -280,14 +280,14 @@
5 for initiating a relation to hacluster:
6
7 ha-bindiface, ha-mcastport, vip, os-internal-hostname,
8- os-admin-hostname, os-public-hostname
9+ os-admin-hostname, os-public-hostname, os-access-hostname
10
11 param: exclude_keys: list of setting key(s) to be excluded.
12 returns: dict: A dict containing settings keyed by setting name.
13 raises: HAIncompleteConfig if settings are missing or incorrect.
14 '''
15 settings = ['ha-bindiface', 'ha-mcastport', 'vip', 'os-internal-hostname',
16- 'os-admin-hostname', 'os-public-hostname']
17+ 'os-admin-hostname', 'os-public-hostname', 'os-access-hostname']
18 conf = {}
19 for setting in settings:
20 if exclude_keys and setting in exclude_keys:
21@@ -324,7 +324,7 @@
22 # If dns-ha then one of os-*-hostname must be set
23 if dns:
24 dns_settings = ['os-internal-hostname', 'os-admin-hostname',
25- 'os-public-hostname']
26+ 'os-public-hostname', 'os-access-hostname']
27 # At this point it is unknown if one or all of the possible
28 # network spaces are in HA. Validate at least one is set which is
29 # the minimum required.
30
31=== modified file 'charmhelpers/contrib/openstack/ha/utils.py'
32--- charmhelpers/contrib/openstack/ha/utils.py 2016-06-10 16:57:18 +0000
33+++ charmhelpers/contrib/openstack/ha/utils.py 2016-06-17 20:11:41 +0000
34@@ -36,6 +36,10 @@
35 DEBUG,
36 )
37
38+from charmhelpers.core.host import (
39+ lsb_release
40+)
41+
42 from charmhelpers.contrib.openstack.ip import (
43 resolve_address,
44 )
45@@ -63,8 +67,11 @@
46 DNS HA
47 """
48
49+ # Validate the charm environment for DNS HA
50+ assert_charm_supports_dns_ha()
51+
52 settings = ['os-admin-hostname', 'os-internal-hostname',
53- 'os-public-hostname']
54+ 'os-public-hostname', 'os-access-hostname']
55
56 # Check which DNS settings are set and update dictionaries
57 hostname_group = []
58@@ -109,3 +116,15 @@
59 msg = 'DNS HA: Hostname group has no members.'
60 status_set('blocked', msg)
61 raise DNSHAException(msg)
62+
63+
64+def assert_charm_supports_dns_ha():
65+ """Validate prerequisites for DNS HA
66+ The MAAS client is only available on Xenial or greater
67+ """
68+ if lsb_release().get('DISTRIB_RELEASE') < '16.04':
69+ msg = ('DNS HA is only supported on 16.04 and greater '
70+ 'versions of Ubuntu.')
71+ status_set('blocked', msg)
72+ raise DNSHAException(msg)
73+ return True
74
75=== modified file 'tests/contrib/hahelpers/test_cluster_utils.py'
76--- tests/contrib/hahelpers/test_cluster_utils.py 2016-06-14 16:27:30 +0000
77+++ tests/contrib/hahelpers/test_cluster_utils.py 2016-06-17 20:11:41 +0000
78@@ -328,6 +328,7 @@
79 'os-admin-hostname': None,
80 'os-public-hostname': None,
81 'os-internal-hostname': None,
82+ 'os-access-hostname': None,
83 }
84
85 valid_hacluster_config.return_value = True
86@@ -348,6 +349,7 @@
87 'os-admin-hostname': None,
88 'os-public-hostname': None,
89 'os-internal-hostname': None,
90+ 'os-access-hostname': None,
91 }
92
93 valid_hacluster_config.return_value = False
94@@ -373,7 +375,7 @@
95
96 self.config_get.side_effect = _fake_config_get
97 exclude_keys = ['vip', 'os-admin-hostname', 'os-internal-hostname',
98- 'os-public-hostname']
99+ 'os-public-hostname', 'os-access-hostname']
100 result = cluster_utils.get_hacluster_config(exclude_keys)
101 self.assertEquals(conf, result)
102
103@@ -430,6 +432,7 @@
104 'os-admin-hostname': None,
105 'os-public-hostname': None,
106 'os-internal-hostname': None,
107+ 'os-access-hostname': None,
108 'dns-ha': False,
109 }
110
111@@ -448,6 +451,7 @@
112 'os-admin-hostname': None,
113 'os-public-hostname': None,
114 'os-internal-hostname': None,
115+ 'os-access-hostname': None,
116 'dns-ha': True,
117 }
118
119@@ -466,6 +470,7 @@
120 'os-admin-hostname': None,
121 'os-public-hostname': None,
122 'os-internal-hostname': None,
123+ 'os-access-hostname': None,
124 'dns-ha': False,
125 }
126
127@@ -484,6 +489,7 @@
128 'os-admin-hostname': None,
129 'os-public-hostname': None,
130 'os-internal-hostname': None,
131+ 'os-access-hostname': None,
132 'dns-ha': True,
133 }
134
135@@ -502,6 +508,7 @@
136 'os-admin-hostname': 'somehostname',
137 'os-public-hostname': None,
138 'os-internal-hostname': None,
139+ 'os-access-hostname': None,
140 'dns-ha': True,
141 }
142
143
144=== modified file 'tests/contrib/openstack/ha/test_ha_utils.py'
145--- tests/contrib/openstack/ha/test_ha_utils.py 2016-06-10 17:47:08 +0000
146+++ tests/contrib/openstack/ha/test_ha_utils.py 2016-06-17 20:11:41 +0000
147@@ -25,7 +25,9 @@
148 self.addCleanup(_m.stop)
149 setattr(self, method, mock)
150
151- def test_update_dns_ha_resource_params_none(self):
152+ @patch.object(ha, 'assert_charm_supports_dns_ha')
153+ def test_update_dns_ha_resource_params_none(self,
154+ assert_charm_supports_dns_ha):
155 self.conf = {
156 'os-admin-hostname': None,
157 'os-internal-hostname': None,
158@@ -38,7 +40,9 @@
159 resources=self.resources,
160 resource_params=self.resource_params)
161
162- def test_update_dns_ha_resource_params_one(self):
163+ @patch.object(ha, 'assert_charm_supports_dns_ha')
164+ def test_update_dns_ha_resource_params_one(self,
165+ assert_charm_supports_dns_ha):
166 EXPECTED_RESOURCES = {'res_test_public_hostname': 'ocf:maas:dns',
167 'res_test_haproxy': 'lsb:haproxy'}
168 EXPECTED_RESOURCE_PARAMS = {
169@@ -63,7 +67,9 @@
170 groups={'grp_test_hostnames': 'res_test_public_hostname'},
171 relation_id='ha:1')
172
173- def test_update_dns_ha_resource_params_all(self):
174+ @patch.object(ha, 'assert_charm_supports_dns_ha')
175+ def test_update_dns_ha_resource_params_all(self,
176+ assert_charm_supports_dns_ha):
177 EXPECTED_RESOURCES = {'res_test_admin_hostname': 'ocf:maas:dns',
178 'res_test_internal_hostname': 'ocf:maas:dns',
179 'res_test_public_hostname': 'ocf:maas:dns',
180@@ -96,3 +102,14 @@
181 'res_test_internal_hostname '
182 'res_test_public_hostname')},
183 relation_id='ha:1')
184+
185+ @patch.object(ha, 'lsb_release')
186+ def test_assert_charm_supports_dns_ha(self, lsb_release):
187+ lsb_release.return_value = {'DISTRIB_RELEASE': '16.04'}
188+ self.assertTrue(ha.assert_charm_supports_dns_ha())
189+
190+ @patch.object(ha, 'lsb_release')
191+ def test_assert_charm_supports_dns_ha_exception(self, lsb_release):
192+ lsb_release.return_value = {'DISTRIB_RELEASE': '12.04'}
193+ self.assertRaises(ha.DNSHAException,
194+ lambda: ha.assert_charm_supports_dns_ha())

Subscribers

People subscribed via source and target branches