Merge lp:~freyes/charms/trusty/nova-cloud-controller/single-nova-consoleauth into lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/next

Proposed by Felipe Reyes
Status: Merged
Approved by: Billy Olsen
Approved revision: 158
Merged at revision: 163
Proposed branch: lp:~freyes/charms/trusty/nova-cloud-controller/single-nova-consoleauth
Merge into: lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/next
Diff against target: 369 lines (+234/-29)
4 files modified
config.yaml (+11/-0)
hooks/nova_cc_hooks.py (+88/-2)
unit_tests/test_nova_cc_hooks.py (+134/-26)
unit_tests/test_utils.py (+1/-1)
To merge this branch: bzr merge lp:~freyes/charms/trusty/nova-cloud-controller/single-nova-consoleauth
Reviewer Review Type Date Requested Status
Billy Olsen Approve
OpenStack Charmers Pending
Edward Hope-Morley Pending
Jorge Niedbalski Pending
Review via email: mp+259973@code.launchpad.net

This proposal supersedes a proposal from 2015-05-22.

Description of the change

Dear OpenStack Charmers,

This patch configures a new pacemaker resource that will allow to run a single instance of nova-consoleauth service when console-access-protocol is defined.

Specifically, nova-consoleauth is configured to run where the vip is allocated, with this patch this will be default behaviour. This is needed for environments where the memcached cannot (or doesn't want to) be related to nova-cloud-controller to share the authorization tokens across all the running instances.

Example output of 'sudo crm_mon -1' with this patch applied:

Last updated: Mon Mar 2 14:46:43 2015
Last change: Mon Mar 2 14:44:53 2015 via crm_resource on juju-freyes-machine-18
Stack: corosync
Current DC: juju-freyes-machine-18 (168103083) - partition with quorum
Version: 1.1.10-42f2063
3 Nodes configured
5 Resources configured

Online: [ juju-freyes-machine-16 juju-freyes-machine-17 juju-freyes-machine-18 ]

 Resource Group: grp_nova_vips
     res_nova_eth0_vip (ocf::heartbeat:IPaddr2): Started juju-freyes-machine-16
 Clone Set: cl_nova_haproxy [res_nova_haproxy]
     Started: [ juju-freyes-machine-16 juju-freyes-machine-17 juju-freyes-machine-18 ]
 res_nova_consoleauth (upstart:nova-consoleauth): Started juju-freyes-machine-16

$ python juju_rrun.py --service nova-cloud-controller 'sudo ps aux|grep nova-consoleauth'
---------- 16 nova-cloud-controller/0
---------- stdout ----------
nova 20773 1.2 7.0 312604 71312 ? Ss 14:44 0:02 /usr/bin/python /usr/bin/nova-consoleauth --config-file=/etc/nova/nova.conf
ubuntu 21188 0.0 0.6 134316 6836 ? Sl 14:47 0:00 juju-run nova-cloud-controller/0 sudo ps aux|grep nova-consoleauth
root 21195 0.0 0.0 8860 648 ? S 14:47 0:00 grep nova-consoleauth

---------- 17 nova-cloud-controller/1
---------- stdout ----------
ubuntu 20997 0.0 0.6 134316 6840 ? Sl 14:47 0:00 juju-run nova-cloud-controller/1 sudo ps aux|grep nova-consoleauth
root 21004 0.0 0.0 8860 648 ? S 14:47 0:00 grep nova-consoleauth

---------- 18 nova-cloud-controller/2
---------- stdout ----------
ubuntu 21325 0.0 0.8 134316 8888 ? Sl 14:47 0:00 juju-run nova-cloud-controller/2 sudo ps aux|grep nova-consoleauth
root 21332 0.0 0.0 8860 644 ? S 14:47 0:00 grep nova-consoleauth

Thanks,

To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_lint_check #2119 nova-cloud-controller-next for freyes mp250339
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/2119/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_unit_test #1909 nova-cloud-controller-next for freyes mp250339
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/1909/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_amulet_test #2028 nova-cloud-controller-next for freyes mp250339
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/2028/

Revision history for this message
Billy Olsen (billy-olsen) wrote : Posted in a previous version of this proposal

Felipe,

Thanks for the submission. I haven't deployed this yet to try it out, but my concerns are around the upstart resources. Since we'll have a difference between systemd and upstart between vivid and previous releases I think we should be using an ocf file instead. There's already one that exists in https://github.com/madkiss/openstack-resource-agents/tree/master/ocf. Looks like its been awhile since its been touched so its either stable or not supported anymore. I think the openstack-resource-agents package also includes this, but I'm not sure as to its status (I believe its in universe).

An amulet test is always nice :-) We don't have anything in the way of the hacluster relation in our amulet tests at this point so I don't think its strictly a requirement (e.g. I wouldn't hold up the mp for it), but improvements are always welcomed.

review: Needs Fixing
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_lint_check #2392 nova-cloud-controller-next for freyes mp251456
    LINT FAIL: lint-test failed

LINT Results (max last 2 lines):
  unit_tests/test_nova_cc_hooks.py:727:51: E502 the backslash is redundant between brackets
  make: *** [lint] Error 1

Full lint test output: http://paste.ubuntu.com/10520210/
Build: http://10.245.162.77:8080/job/charm_lint_check/2392/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_unit_test #2182 nova-cloud-controller-next for freyes mp251456
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/2182/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_amulet_test #2312 nova-cloud-controller-next for freyes mp251456
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/2312/

Revision history for this message
Billy Olsen (billy-olsen) wrote : Posted in a previous version of this proposal

Felipe, thanks for the submission! Things look good. Approved.

review: Approve
Revision history for this message
Billy Olsen (billy-olsen) wrote : Posted in a previous version of this proposal

Okay I spoke too soon. Everything looks good for enabling the single-nova-consoleauth and it works as expected while its running. However, if a user wishes to change from single-nova-consoleauth back to multi consoleauth then this patch doesn't actually:

1. remove the res_nova_consoleauth from the corosync/pacemaker configuration.
2. restart the services on nodes which the service is not running restoring the multi-consoleauth scenario.

Apologies for not chasing this scenario down sooner.

review: Needs Fixing
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_lint_check #2493 nova-cloud-controller-next for freyes mp252138
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/2493/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_unit_test #2283 nova-cloud-controller-next for freyes mp252138
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/2283/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_amulet_test #2365 nova-cloud-controller-next for freyes mp252138
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
  ERROR subprocess encountered error code 1
  make: *** [test] Error 1

Full amulet test output: http://paste.ubuntu.com/10553839/
Build: http://10.245.162.77:8080/job/charm_amulet_test/2365/

Revision history for this message
Felipe Reyes (freyes) wrote : Posted in a previous version of this proposal

The amulet failure is:

  juju-test.conductor.14-basic-precise-icehouse DEBUG : Running 14-basic-precise-icehouse (tests/14-basic-precise-icehouse)
  2015-03-07 01:22:16 Starting deployment of osci-sv00
  2015-03-07 01:22:49 Deploying services...
[...]
  2015-03-07 01:23:13 Deploying service rabbitmq-server using local:precise/rabbitmq-server
  2015-03-07 01:34:08 The following units had errors:
  unit: rabbitmq-server/0: machine: 7 agent-state: error details: hook failed: "config-changed"

This isn't related to my change

Revision history for this message
Felipe Reyes (freyes) wrote : Posted in a previous version of this proposal

> 1. remove the res_nova_consoleauth from the corosync/pacemaker configuration.
> 2. restart the services on nodes which the service is not running restoring
> the multi-consoleauth scenario.

Makes sense, I'll update the patch.

Thanks,

Revision history for this message
Felipe Reyes (freyes) wrote : Posted in a previous version of this proposal

@Billy, I pushed a new version of the patch to address your feedback, this can't be merged until bug 1433377 is fixed, but I'll appreciate if you could take a quick review to know if things look good.

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_lint_check #2747 nova-cloud-controller-next for freyes mp253309
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/2747/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_unit_test #2538 nova-cloud-controller-next for freyes mp253309
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/2538/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_amulet_test #2586 nova-cloud-controller-next for freyes mp253309
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
  ERROR subprocess encountered error code 1
  make: *** [test] Error 1

Full amulet test output: http://paste.ubuntu.com/10630161/
Build: http://10.245.162.77:8080/job/charm_amulet_test/2586/

Revision history for this message
Felipe Reyes (freyes) wrote : Posted in a previous version of this proposal

A couple of deployer configurations for testing this change were pushed to lp:~openstack-charm-testers/+junk/percona-mysql-agent

One of them is a complete openstack cloud (based in next.yaml from openstack-charm-testing repo) and the other one is a simple 3 node percona cluster + keystone.

Revision history for this message
Edward Hope-Morley (hopem) wrote : Posted in a previous version of this proposal

Felipe, i'm deploying this as we speak. The code looks fine although I have a few comments about how it could be slightly neater, see inline. One approach might be so pull the relation_settings, travers the settings dict and apply any default/missing entries then process the results.

review: Needs Fixing
Revision history for this message
Felipe Reyes (freyes) wrote : Posted in a previous version of this proposal

Ed, the bundle to test this MP is located at https://code.launchpad.net/~openstack-charm-testers/+junk/single-nova-consoleauth , sorry for the confusion.

Revision history for this message
Felipe Reyes (freyes) wrote : Posted in a previous version of this proposal

Ed, I'll push another MP that addresses your feedback, except one of them, please see my reply.

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_lint_check #2901 nova-cloud-controller-next for freyes mp254172
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/2901/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_unit_test #2692 nova-cloud-controller-next for freyes mp254172
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/2692/

Revision history for this message
Edward Hope-Morley (hopem) wrote : Posted in a previous version of this proposal

So i should have noticed before but, your code is living in config_changed() but relies on the ha relation to exist so it will never get called unless the ha relation exists prior to config_changed() being run...which will not be the case unless you modify charm config after the hacluster has completed installation and relations have been added. So, i suggest you move that code into the ha_joined() or ha_changed() hooks and call it from config_changed() assuming that is safe to do.

review: Needs Fixing
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_amulet_test #2699 nova-cloud-controller-next for freyes mp254172
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
  ERROR subprocess encountered error code 1
  make: *** [test] Error 1

Full amulet test output: http://paste.ubuntu.com/10681239/
Build: http://10.245.162.77:8080/job/charm_amulet_test/2699/

Revision history for this message
Edward Hope-Morley (hopem) wrote : Posted in a previous version of this proposal

Thanks for cleaning this up Felipe. As previously mentioned i think you need to move this code out of the config-changed hooks though since it depends on ha relations being extant and that might not be the case in the config-changed hook if it runs prior to the ha relation being joined. I think a more sensible approach would be to move this piece of code into its own function and call it from the config-changed and ha-relation-changed hooks that way you cover the case of (a) config changes after ha rels are joined and (b) config applied prior to ha-rels joined.

review: Needs Fixing
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_amulet_test #4272 nova-cloud-controller-next for freyes mp259951
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/4272/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_lint_check #4737 nova-cloud-controller-next for freyes mp259951
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/4737/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_unit_test #4417 nova-cloud-controller-next for freyes mp259951
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/4417/

Revision history for this message
Felipe Reyes (freyes) wrote :

All,

I tested this patch under the following scenarios:

* deploy from charm store and then juju-upgradecharm
* deploy directly from my branch
* deploy from my branch without relating to hacluster and check it does *not* configure consoleauth pcmkr resource

Thanks,

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #4739 nova-cloud-controller-next for freyes mp259973
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/4739/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #4419 nova-cloud-controller-next for freyes mp259973
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/4419/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : Posted in a previous version of this proposal

charm_amulet_test #4273 nova-cloud-controller-next for freyes mp259951
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/4273/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #4275 nova-cloud-controller-next for freyes mp259973
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/4275/

Revision history for this message
Billy Olsen (billy-olsen) wrote :

lgtm, thanks for the submission, patience, and work Felipe!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2015-04-20 10:21:36 +0000
3+++ config.yaml 2015-05-22 18:56:48 +0000
4@@ -326,3 +326,14 @@
5 description: |
6 A comma-separated list of nagios servicegroups.
7 If left empty, the nagios_context will be used as the servicegroup
8+ single-nova-consoleauth:
9+ type: boolean
10+ default: true
11+ description: |
12+ When this configuration is set to True, a single instance of
13+ nova-consoleauth service will be running, this allows users to always
14+ authenticate against the same instance and avoid authentications issues
15+ when the token used was stored in a different instance.
16+
17+ If memcached is being used to store the tokens, then it's recommended to
18+ change this configuration to False.
19
20=== modified file 'hooks/nova_cc_hooks.py'
21--- hooks/nova_cc_hooks.py 2015-04-22 14:39:04 +0000
22+++ hooks/nova_cc_hooks.py 2015-05-22 18:56:48 +0000
23@@ -124,8 +124,18 @@
24
25 from charmhelpers.contrib.charmsupport import nrpe
26
27+try:
28+ FileNotFoundError
29+except NameError:
30+ # python3 compatibility
31+ FileNotFoundError = IOError
32+
33 hooks = Hooks()
34 CONFIGS = register_configs()
35+COLO_CONSOLEAUTH = 'inf: res_nova_consoleauth grp_nova_vips'
36+AGENT_CONSOLEAUTH = 'ocf:openstack:nova-consoleauth'
37+AGENT_CA_PARAMS = 'op monitor interval="5s"'
38+NOVA_CONSOLEAUTH_OVERRIDE = '/etc/init/nova-consoleauth.override'
39
40
41 @hooks.hook()
42@@ -179,6 +189,8 @@
43 [cluster_joined(rid) for rid in relation_ids('cluster')]
44 update_nrpe_config()
45
46+ update_nova_consoleauth_config()
47+
48
49 @hooks.hook('amqp-relation-joined')
50 def amqp_joined(relation_id=None):
51@@ -648,7 +660,7 @@
52 'res_nova_haproxy': 'lsb:haproxy',
53 }
54 resource_params = {
55- 'res_nova_haproxy': 'op monitor interval="5s"'
56+ 'res_nova_haproxy': 'op monitor interval="5s"',
57 }
58
59 vip_group = []
60@@ -686,12 +698,21 @@
61 clones = {
62 'cl_nova_haproxy': 'res_nova_haproxy'
63 }
64+ colocations = {}
65+
66+ if config('single-nova-consoleauth') and console_attributes('protocol'):
67+ colocations['vip_consoleauth'] = COLO_CONSOLEAUTH
68+ init_services['res_nova_consoleauth'] = 'nova-consoleauth'
69+ resources['res_nova_consoleauth'] = AGENT_CONSOLEAUTH
70+ resource_params['res_nova_consoleauth'] = AGENT_CA_PARAMS
71+
72 relation_set(init_services=init_services,
73 corosync_bindiface=cluster_config['ha-bindiface'],
74 corosync_mcastport=cluster_config['ha-mcastport'],
75 resources=resources,
76 resource_params=resource_params,
77- clones=clones)
78+ clones=clones,
79+ colocations=colocations)
80
81
82 @hooks.hook('ha-relation-changed')
83@@ -713,6 +734,8 @@
84 for rid in relation_ids('identity-service'):
85 identity_joined(rid=rid)
86
87+ update_nova_consoleauth_config()
88+
89
90 @hooks.hook('shared-db-relation-broken',
91 'pgsql-nova-db-relation-broken')
92@@ -800,6 +823,7 @@
93 for unit in related_units(r_id):
94 compute_changed(r_id, unit)
95 update_nrpe_config()
96+ update_nova_consoleauth_config()
97
98
99 # remote_restart is defaulted to true as nova-cells may have started the
100@@ -911,6 +935,68 @@
101 CONFIGS.write(NOVA_CONF)
102
103
104+def update_nova_consoleauth_config():
105+ """
106+ Configure nova-consoleauth pacemaker resources
107+ """
108+ relids = relation_ids('ha')
109+ if len(relids) == 0:
110+ log('Related to {} ha services'.format(len(relids)), level='DEBUG')
111+ ha_relid = None
112+ data = {}
113+ else:
114+ ha_relid = relids[0]
115+ data = relation_get(rid=ha_relid) or {}
116+
117+ # initialize keys in case this is a new dict
118+ data.setdefault('delete_resources', [])
119+ for k in ['colocations', 'init_services', 'resources', 'resource_params']:
120+ data.setdefault(k, {})
121+
122+ if config('single-nova-consoleauth') and console_attributes('protocol'):
123+ for item in ['vip_consoleauth', 'res_nova_consoleauth']:
124+ try:
125+ data['delete_resources'].remove(item)
126+ except ValueError:
127+ pass # nothing to remove, we are good
128+
129+ # the new pcmkr resources have to be added to the existing ones
130+ data['colocations']['vip_consoleauth'] = COLO_CONSOLEAUTH
131+ data['init_services']['res_nova_consoleauth'] = 'nova-consoleauth'
132+ data['resources']['res_nova_consoleauth'] = AGENT_CONSOLEAUTH
133+ data['resource_params']['res_nova_consoleauth'] = AGENT_CA_PARAMS
134+
135+ for rid in relation_ids('ha'):
136+ relation_set(rid, **data)
137+
138+ # nova-consoleauth will be managed by pacemaker, so mark it as manual
139+ if relation_ids('ha'):
140+ with open(NOVA_CONSOLEAUTH_OVERRIDE, 'w') as fp:
141+ fp.write('manual\n')
142+ fp.flush()
143+
144+ elif (not config('single-nova-consoleauth')
145+ and console_attributes('protocol')):
146+ for item in ['vip_consoleauth', 'res_nova_consoleauth']:
147+ if item not in data['delete_resources']:
148+ data['delete_resources'].append(item)
149+
150+ # remove them from the rel, so they aren't recreated when the hook
151+ # is recreated
152+ data['colocations'].pop('vip_consoleauth', None)
153+ data['init_services'].pop('res_nova_consoleauth', None)
154+ data['resources'].pop('res_nova_consoleauth', None)
155+ data['resource_params'].pop('res_nova_consoleauth', None)
156+
157+ for rid in relation_ids('ha'):
158+ relation_set(rid, **data)
159+
160+ try:
161+ os.remove(NOVA_CONSOLEAUTH_OVERRIDE)
162+ except FileNotFoundError as e:
163+ log(str(e), level='DEBUG')
164+
165+
166 def main():
167 try:
168 hooks.execute(sys.argv)
169
170=== modified file 'unit_tests/test_nova_cc_hooks.py'
171--- unit_tests/test_nova_cc_hooks.py 2015-04-22 19:22:30 +0000
172+++ unit_tests/test_nova_cc_hooks.py 2015-05-22 18:56:48 +0000
173@@ -1,6 +1,7 @@
174 from mock import MagicMock, patch, call
175 from test_utils import CharmTestCase, patch_open
176 import os
177+import tempfile
178
179 with patch('charmhelpers.core.hookenv.config') as config:
180 config.return_value = 'neutron'
181@@ -90,11 +91,20 @@
182
183 def setUp(self):
184 super(NovaCCHooksTests, self).setUp(hooks, TO_PATCH)
185+ (tmpfd, hooks.NOVA_CONSOLEAUTH_OVERRIDE) = tempfile.mkstemp()
186
187 self.config.side_effect = self.test_config.get
188 self.relation_get.side_effect = self.test_relation.get
189 self.charm_dir.return_value = '/var/lib/juju/charms/nova/charm'
190
191+ def tearDown(self):
192+ try:
193+ os.remove(hooks.NOVA_CONSOLEAUTH_OVERRIDE)
194+ except OSError:
195+ pass
196+
197+ super(NovaCCHooksTests, self).tearDown()
198+
199 def test_install_hook(self):
200 self.determine_packages.return_value = [
201 'nova-scheduler', 'nova-api-ec2']
202@@ -622,30 +632,128 @@
203 'neutron-api charm.'
204 )
205
206- def test_ha_relation_joined_no_bound_ip(self):
207- self.get_hacluster_config.return_value = {
208- 'ha-bindiface': 'em0',
209- 'ha-mcastport': '8080',
210- 'vip': '10.10.10.10',
211- }
212- self.test_config.set('vip_iface', 'eth120')
213- self.test_config.set('vip_cidr', '21')
214- self.get_iface_for_address.return_value = None
215- self.get_netmask_for_address.return_value = None
216- hooks.ha_joined()
217- args = {
218- 'corosync_bindiface': 'em0',
219- 'corosync_mcastport': '8080',
220- 'init_services': {'res_nova_haproxy': 'haproxy'},
221- 'resources': {'res_nova_eth120_vip': 'ocf:heartbeat:IPaddr2',
222- 'res_nova_haproxy': 'lsb:haproxy'},
223- 'resource_params': {
224- 'res_nova_eth120_vip': 'params ip="10.10.10.10"'
225- ' cidr_netmask="21" nic="eth120"',
226- 'res_nova_haproxy': 'op monitor interval="5s"'},
227- 'clones': {'cl_nova_haproxy': 'res_nova_haproxy'}
228- }
229- self.relation_set.assert_has_calls([
230- call(groups={'grp_nova_vips': 'res_nova_eth120_vip'}),
231- call(**args),
232+ @patch('nova_cc_utils.config')
233+ def test_ha_relation_joined_no_bound_ip(self, config):
234+ self.get_hacluster_config.return_value = {
235+ 'ha-bindiface': 'em0',
236+ 'ha-mcastport': '8080',
237+ 'vip': '10.10.10.10',
238+ }
239+ self.test_config.set('vip_iface', 'eth120')
240+ self.test_config.set('vip_cidr', '21')
241+ config.return_value = None
242+ self.get_iface_for_address.return_value = None
243+ self.get_netmask_for_address.return_value = None
244+ hooks.ha_joined()
245+ args = {
246+ 'corosync_bindiface': 'em0',
247+ 'corosync_mcastport': '8080',
248+ 'init_services': {'res_nova_haproxy': 'haproxy'},
249+ 'resources': {'res_nova_eth120_vip': 'ocf:heartbeat:IPaddr2',
250+ 'res_nova_haproxy': 'lsb:haproxy'},
251+ 'resource_params': {
252+ 'res_nova_eth120_vip': 'params ip="10.10.10.10"'
253+ ' cidr_netmask="21" nic="eth120"',
254+ 'res_nova_haproxy': 'op monitor interval="5s"'},
255+ 'colocations': {},
256+ 'clones': {'cl_nova_haproxy': 'res_nova_haproxy'}
257+ }
258+ self.relation_set.assert_has_calls([
259+ call(groups={'grp_nova_vips': 'res_nova_eth120_vip'}),
260+ call(**args),
261+ ])
262+
263+ @patch('nova_cc_utils.config')
264+ def test_ha_relation_multi_consoleauth(self, config):
265+ self.get_hacluster_config.return_value = {
266+ 'ha-bindiface': 'em0',
267+ 'ha-mcastport': '8080',
268+ 'vip': '10.10.10.10',
269+ }
270+ self.test_config.set('vip_iface', 'eth120')
271+ self.test_config.set('vip_cidr', '21')
272+ self.test_config.set('single-nova-consoleauth', False)
273+ config.return_value = 'novnc'
274+ self.get_iface_for_address.return_value = None
275+ self.get_netmask_for_address.return_value = None
276+ hooks.ha_joined()
277+ args = {
278+ 'corosync_bindiface': 'em0',
279+ 'corosync_mcastport': '8080',
280+ 'init_services': {'res_nova_haproxy': 'haproxy'},
281+ 'resources': {'res_nova_eth120_vip': 'ocf:heartbeat:IPaddr2',
282+ 'res_nova_haproxy': 'lsb:haproxy'},
283+ 'resource_params': {
284+ 'res_nova_eth120_vip': 'params ip="10.10.10.10"'
285+ ' cidr_netmask="21" nic="eth120"',
286+ 'res_nova_haproxy': 'op monitor interval="5s"'},
287+ 'colocations': {},
288+ 'clones': {'cl_nova_haproxy': 'res_nova_haproxy'}
289+ }
290+ self.relation_set.assert_has_calls([
291+ call(groups={'grp_nova_vips': 'res_nova_eth120_vip'}),
292+ call(**args),
293+ ])
294+
295+ @patch('nova_cc_utils.config')
296+ def test_ha_relation_single_consoleauth(self, config):
297+ self.get_hacluster_config.return_value = {
298+ 'ha-bindiface': 'em0',
299+ 'ha-mcastport': '8080',
300+ 'vip': '10.10.10.10',
301+ }
302+ self.test_config.set('vip_iface', 'eth120')
303+ self.test_config.set('vip_cidr', '21')
304+ config.return_value = 'novnc'
305+ self.get_iface_for_address.return_value = None
306+ self.get_netmask_for_address.return_value = None
307+ hooks.ha_joined()
308+ args = {
309+ 'corosync_bindiface': 'em0',
310+ 'corosync_mcastport': '8080',
311+ 'init_services': {'res_nova_haproxy': 'haproxy',
312+ 'res_nova_consoleauth': 'nova-consoleauth'},
313+ 'resources': {'res_nova_eth120_vip': 'ocf:heartbeat:IPaddr2',
314+ 'res_nova_haproxy': 'lsb:haproxy',
315+ 'res_nova_consoleauth':
316+ 'ocf:openstack:nova-consoleauth'},
317+ 'resource_params': {
318+ 'res_nova_eth120_vip': 'params ip="10.10.10.10"'
319+ ' cidr_netmask="21" nic="eth120"',
320+ 'res_nova_haproxy': 'op monitor interval="5s"',
321+ 'res_nova_consoleauth': 'op monitor interval="5s"'},
322+ 'colocations': {
323+ 'vip_consoleauth': 'inf: res_nova_consoleauth grp_nova_vips'
324+ },
325+ 'clones': {'cl_nova_haproxy': 'res_nova_haproxy'}
326+ }
327+ self.relation_set.assert_has_calls([
328+ call(groups={'grp_nova_vips': 'res_nova_eth120_vip'}),
329+ call(**args),
330+ ])
331+
332+ @patch('nova_cc_hooks.configure_https')
333+ @patch('nova_cc_utils.config')
334+ def test_config_changed_single_consoleauth(self, config, *args):
335+ config.return_value = 'novnc'
336+ rids = {'ha': ['ha:1']}
337+
338+ def f(r):
339+ return rids.get(r, [])
340+
341+ self.relation_ids.side_effect = f
342+ hooks.config_changed()
343+ args = {
344+ 'delete_resources': [],
345+ 'init_services': {'res_nova_consoleauth': 'nova-consoleauth'},
346+ 'resources': {'res_nova_consoleauth':
347+ 'ocf:openstack:nova-consoleauth'},
348+ 'resource_params': {
349+ 'res_nova_consoleauth': 'op monitor interval="5s"'},
350+ 'colocations': {
351+ 'vip_consoleauth': 'inf: res_nova_consoleauth grp_nova_vips'
352+ }
353+ }
354+ self.relation_set.assert_has_calls([
355+ call(v, **args) for v in rids['ha']
356 ])
357
358=== modified file 'unit_tests/test_utils.py'
359--- unit_tests/test_utils.py 2014-07-29 12:23:46 +0000
360+++ unit_tests/test_utils.py 2015-05-22 18:56:48 +0000
361@@ -23,7 +23,7 @@
362
363 if not config:
364 logging.error('Could not find config.yaml in any parent directory '
365- 'of %s. ' % file)
366+ 'of %s. ' % f)
367 raise Exception
368
369 return yaml.safe_load(open(config).read())['options']

Subscribers

People subscribed via source and target branches