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: Superseded
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
OpenStack Charmers Pending
Edward Hope-Morley Pending
Billy Olsen Pending
Jorge Niedbalski Pending
Review via email: mp+259951@code.launchpad.net

This proposal supersedes a proposal from 2015-03-25.

This proposal has been superseded by 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 :

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/

158. By Felipe Reyes

nova-consoleauth set to manual only if there is a ha relation

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

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 :

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
uosci-testing-bot (uosci-testing-bot) wrote :

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/

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'config.yaml'
--- config.yaml 2015-04-20 10:21:36 +0000
+++ config.yaml 2015-05-22 18:20:03 +0000
@@ -326,3 +326,14 @@
326 description: |326 description: |
327 A comma-separated list of nagios servicegroups.327 A comma-separated list of nagios servicegroups.
328 If left empty, the nagios_context will be used as the servicegroup328 If left empty, the nagios_context will be used as the servicegroup
329 single-nova-consoleauth:
330 type: boolean
331 default: true
332 description: |
333 When this configuration is set to True, a single instance of
334 nova-consoleauth service will be running, this allows users to always
335 authenticate against the same instance and avoid authentications issues
336 when the token used was stored in a different instance.
337
338 If memcached is being used to store the tokens, then it's recommended to
339 change this configuration to False.
329340
=== modified file 'hooks/nova_cc_hooks.py'
--- hooks/nova_cc_hooks.py 2015-04-22 14:39:04 +0000
+++ hooks/nova_cc_hooks.py 2015-05-22 18:20:03 +0000
@@ -124,8 +124,18 @@
124124
125from charmhelpers.contrib.charmsupport import nrpe125from charmhelpers.contrib.charmsupport import nrpe
126126
127try:
128 FileNotFoundError
129except NameError:
130 # python3 compatibility
131 FileNotFoundError = IOError
132
127hooks = Hooks()133hooks = Hooks()
128CONFIGS = register_configs()134CONFIGS = register_configs()
135COLO_CONSOLEAUTH = 'inf: res_nova_consoleauth grp_nova_vips'
136AGENT_CONSOLEAUTH = 'ocf:openstack:nova-consoleauth'
137AGENT_CA_PARAMS = 'op monitor interval="5s"'
138NOVA_CONSOLEAUTH_OVERRIDE = '/etc/init/nova-consoleauth.override'
129139
130140
131@hooks.hook()141@hooks.hook()
@@ -179,6 +189,8 @@
179 [cluster_joined(rid) for rid in relation_ids('cluster')]189 [cluster_joined(rid) for rid in relation_ids('cluster')]
180 update_nrpe_config()190 update_nrpe_config()
181191
192 update_nova_consoleauth_config()
193
182194
183@hooks.hook('amqp-relation-joined')195@hooks.hook('amqp-relation-joined')
184def amqp_joined(relation_id=None):196def amqp_joined(relation_id=None):
@@ -648,7 +660,7 @@
648 'res_nova_haproxy': 'lsb:haproxy',660 'res_nova_haproxy': 'lsb:haproxy',
649 }661 }
650 resource_params = {662 resource_params = {
651 'res_nova_haproxy': 'op monitor interval="5s"'663 'res_nova_haproxy': 'op monitor interval="5s"',
652 }664 }
653665
654 vip_group = []666 vip_group = []
@@ -686,12 +698,21 @@
686 clones = {698 clones = {
687 'cl_nova_haproxy': 'res_nova_haproxy'699 'cl_nova_haproxy': 'res_nova_haproxy'
688 }700 }
701 colocations = {}
702
703 if config('single-nova-consoleauth') and console_attributes('protocol'):
704 colocations['vip_consoleauth'] = COLO_CONSOLEAUTH
705 init_services['res_nova_consoleauth'] = 'nova-consoleauth'
706 resources['res_nova_consoleauth'] = AGENT_CONSOLEAUTH
707 resource_params['res_nova_consoleauth'] = AGENT_CA_PARAMS
708
689 relation_set(init_services=init_services,709 relation_set(init_services=init_services,
690 corosync_bindiface=cluster_config['ha-bindiface'],710 corosync_bindiface=cluster_config['ha-bindiface'],
691 corosync_mcastport=cluster_config['ha-mcastport'],711 corosync_mcastport=cluster_config['ha-mcastport'],
692 resources=resources,712 resources=resources,
693 resource_params=resource_params,713 resource_params=resource_params,
694 clones=clones)714 clones=clones,
715 colocations=colocations)
695716
696717
697@hooks.hook('ha-relation-changed')718@hooks.hook('ha-relation-changed')
@@ -713,6 +734,8 @@
713 for rid in relation_ids('identity-service'):734 for rid in relation_ids('identity-service'):
714 identity_joined(rid=rid)735 identity_joined(rid=rid)
715736
737 update_nova_consoleauth_config()
738
716739
717@hooks.hook('shared-db-relation-broken',740@hooks.hook('shared-db-relation-broken',
718 'pgsql-nova-db-relation-broken')741 'pgsql-nova-db-relation-broken')
@@ -800,6 +823,7 @@
800 for unit in related_units(r_id):823 for unit in related_units(r_id):
801 compute_changed(r_id, unit)824 compute_changed(r_id, unit)
802 update_nrpe_config()825 update_nrpe_config()
826 update_nova_consoleauth_config()
803827
804828
805# remote_restart is defaulted to true as nova-cells may have started the829# remote_restart is defaulted to true as nova-cells may have started the
@@ -911,6 +935,68 @@
911 CONFIGS.write(NOVA_CONF)935 CONFIGS.write(NOVA_CONF)
912936
913937
938def update_nova_consoleauth_config():
939 """
940 Configure nova-consoleauth pacemaker resources
941 """
942 relids = relation_ids('ha')
943 if len(relids) == 0:
944 log('Related to {} ha services'.format(len(relids)), level='DEBUG')
945 ha_relid = None
946 data = {}
947 else:
948 ha_relid = relids[0]
949 data = relation_get(rid=ha_relid) or {}
950
951 # initialize keys in case this is a new dict
952 data.setdefault('delete_resources', [])
953 for k in ['colocations', 'init_services', 'resources', 'resource_params']:
954 data.setdefault(k, {})
955
956 if config('single-nova-consoleauth') and console_attributes('protocol'):
957 for item in ['vip_consoleauth', 'res_nova_consoleauth']:
958 try:
959 data['delete_resources'].remove(item)
960 except ValueError:
961 pass # nothing to remove, we are good
962
963 # the new pcmkr resources have to be added to the existing ones
964 data['colocations']['vip_consoleauth'] = COLO_CONSOLEAUTH
965 data['init_services']['res_nova_consoleauth'] = 'nova-consoleauth'
966 data['resources']['res_nova_consoleauth'] = AGENT_CONSOLEAUTH
967 data['resource_params']['res_nova_consoleauth'] = AGENT_CA_PARAMS
968
969 for rid in relation_ids('ha'):
970 relation_set(rid, **data)
971
972 # nova-consoleauth will be managed by pacemaker, so mark it as manual
973 if relation_ids('ha'):
974 with open(NOVA_CONSOLEAUTH_OVERRIDE, 'w') as fp:
975 fp.write('manual\n')
976 fp.flush()
977
978 elif (not config('single-nova-consoleauth')
979 and console_attributes('protocol')):
980 for item in ['vip_consoleauth', 'res_nova_consoleauth']:
981 if item not in data['delete_resources']:
982 data['delete_resources'].append(item)
983
984 # remove them from the rel, so they aren't recreated when the hook
985 # is recreated
986 data['colocations'].pop('vip_consoleauth', None)
987 data['init_services'].pop('res_nova_consoleauth', None)
988 data['resources'].pop('res_nova_consoleauth', None)
989 data['resource_params'].pop('res_nova_consoleauth', None)
990
991 for rid in relation_ids('ha'):
992 relation_set(rid, **data)
993
994 try:
995 os.remove(NOVA_CONSOLEAUTH_OVERRIDE)
996 except FileNotFoundError as e:
997 log(str(e), level='DEBUG')
998
999
914def main():1000def main():
915 try:1001 try:
916 hooks.execute(sys.argv)1002 hooks.execute(sys.argv)
9171003
=== modified file 'unit_tests/test_nova_cc_hooks.py'
--- unit_tests/test_nova_cc_hooks.py 2015-04-22 19:22:30 +0000
+++ unit_tests/test_nova_cc_hooks.py 2015-05-22 18:20:03 +0000
@@ -1,6 +1,7 @@
1from mock import MagicMock, patch, call1from mock import MagicMock, patch, call
2from test_utils import CharmTestCase, patch_open2from test_utils import CharmTestCase, patch_open
3import os3import os
4import tempfile
45
5with patch('charmhelpers.core.hookenv.config') as config:6with patch('charmhelpers.core.hookenv.config') as config:
6 config.return_value = 'neutron'7 config.return_value = 'neutron'
@@ -90,11 +91,20 @@
9091
91 def setUp(self):92 def setUp(self):
92 super(NovaCCHooksTests, self).setUp(hooks, TO_PATCH)93 super(NovaCCHooksTests, self).setUp(hooks, TO_PATCH)
94 (tmpfd, hooks.NOVA_CONSOLEAUTH_OVERRIDE) = tempfile.mkstemp()
9395
94 self.config.side_effect = self.test_config.get96 self.config.side_effect = self.test_config.get
95 self.relation_get.side_effect = self.test_relation.get97 self.relation_get.side_effect = self.test_relation.get
96 self.charm_dir.return_value = '/var/lib/juju/charms/nova/charm'98 self.charm_dir.return_value = '/var/lib/juju/charms/nova/charm'
9799
100 def tearDown(self):
101 try:
102 os.remove(hooks.NOVA_CONSOLEAUTH_OVERRIDE)
103 except OSError:
104 pass
105
106 super(NovaCCHooksTests, self).tearDown()
107
98 def test_install_hook(self):108 def test_install_hook(self):
99 self.determine_packages.return_value = [109 self.determine_packages.return_value = [
100 'nova-scheduler', 'nova-api-ec2']110 'nova-scheduler', 'nova-api-ec2']
@@ -622,30 +632,128 @@
622 'neutron-api charm.'632 'neutron-api charm.'
623 )633 )
624634
625 def test_ha_relation_joined_no_bound_ip(self):635 @patch('nova_cc_utils.config')
626 self.get_hacluster_config.return_value = {636 def test_ha_relation_joined_no_bound_ip(self, config):
627 'ha-bindiface': 'em0',637 self.get_hacluster_config.return_value = {
628 'ha-mcastport': '8080',638 'ha-bindiface': 'em0',
629 'vip': '10.10.10.10',639 'ha-mcastport': '8080',
630 }640 'vip': '10.10.10.10',
631 self.test_config.set('vip_iface', 'eth120')641 }
632 self.test_config.set('vip_cidr', '21')642 self.test_config.set('vip_iface', 'eth120')
633 self.get_iface_for_address.return_value = None643 self.test_config.set('vip_cidr', '21')
634 self.get_netmask_for_address.return_value = None644 config.return_value = None
635 hooks.ha_joined()645 self.get_iface_for_address.return_value = None
636 args = {646 self.get_netmask_for_address.return_value = None
637 'corosync_bindiface': 'em0',647 hooks.ha_joined()
638 'corosync_mcastport': '8080',648 args = {
639 'init_services': {'res_nova_haproxy': 'haproxy'},649 'corosync_bindiface': 'em0',
640 'resources': {'res_nova_eth120_vip': 'ocf:heartbeat:IPaddr2',650 'corosync_mcastport': '8080',
641 'res_nova_haproxy': 'lsb:haproxy'},651 'init_services': {'res_nova_haproxy': 'haproxy'},
642 'resource_params': {652 'resources': {'res_nova_eth120_vip': 'ocf:heartbeat:IPaddr2',
643 'res_nova_eth120_vip': 'params ip="10.10.10.10"'653 'res_nova_haproxy': 'lsb:haproxy'},
644 ' cidr_netmask="21" nic="eth120"',654 'resource_params': {
645 'res_nova_haproxy': 'op monitor interval="5s"'},655 'res_nova_eth120_vip': 'params ip="10.10.10.10"'
646 'clones': {'cl_nova_haproxy': 'res_nova_haproxy'}656 ' cidr_netmask="21" nic="eth120"',
647 }657 'res_nova_haproxy': 'op monitor interval="5s"'},
648 self.relation_set.assert_has_calls([658 'colocations': {},
649 call(groups={'grp_nova_vips': 'res_nova_eth120_vip'}),659 'clones': {'cl_nova_haproxy': 'res_nova_haproxy'}
650 call(**args),660 }
661 self.relation_set.assert_has_calls([
662 call(groups={'grp_nova_vips': 'res_nova_eth120_vip'}),
663 call(**args),
664 ])
665
666 @patch('nova_cc_utils.config')
667 def test_ha_relation_multi_consoleauth(self, config):
668 self.get_hacluster_config.return_value = {
669 'ha-bindiface': 'em0',
670 'ha-mcastport': '8080',
671 'vip': '10.10.10.10',
672 }
673 self.test_config.set('vip_iface', 'eth120')
674 self.test_config.set('vip_cidr', '21')
675 self.test_config.set('single-nova-consoleauth', False)
676 config.return_value = 'novnc'
677 self.get_iface_for_address.return_value = None
678 self.get_netmask_for_address.return_value = None
679 hooks.ha_joined()
680 args = {
681 'corosync_bindiface': 'em0',
682 'corosync_mcastport': '8080',
683 'init_services': {'res_nova_haproxy': 'haproxy'},
684 'resources': {'res_nova_eth120_vip': 'ocf:heartbeat:IPaddr2',
685 'res_nova_haproxy': 'lsb:haproxy'},
686 'resource_params': {
687 'res_nova_eth120_vip': 'params ip="10.10.10.10"'
688 ' cidr_netmask="21" nic="eth120"',
689 'res_nova_haproxy': 'op monitor interval="5s"'},
690 'colocations': {},
691 'clones': {'cl_nova_haproxy': 'res_nova_haproxy'}
692 }
693 self.relation_set.assert_has_calls([
694 call(groups={'grp_nova_vips': 'res_nova_eth120_vip'}),
695 call(**args),
696 ])
697
698 @patch('nova_cc_utils.config')
699 def test_ha_relation_single_consoleauth(self, config):
700 self.get_hacluster_config.return_value = {
701 'ha-bindiface': 'em0',
702 'ha-mcastport': '8080',
703 'vip': '10.10.10.10',
704 }
705 self.test_config.set('vip_iface', 'eth120')
706 self.test_config.set('vip_cidr', '21')
707 config.return_value = 'novnc'
708 self.get_iface_for_address.return_value = None
709 self.get_netmask_for_address.return_value = None
710 hooks.ha_joined()
711 args = {
712 'corosync_bindiface': 'em0',
713 'corosync_mcastport': '8080',
714 'init_services': {'res_nova_haproxy': 'haproxy',
715 'res_nova_consoleauth': 'nova-consoleauth'},
716 'resources': {'res_nova_eth120_vip': 'ocf:heartbeat:IPaddr2',
717 'res_nova_haproxy': 'lsb:haproxy',
718 'res_nova_consoleauth':
719 'ocf:openstack:nova-consoleauth'},
720 'resource_params': {
721 'res_nova_eth120_vip': 'params ip="10.10.10.10"'
722 ' cidr_netmask="21" nic="eth120"',
723 'res_nova_haproxy': 'op monitor interval="5s"',
724 'res_nova_consoleauth': 'op monitor interval="5s"'},
725 'colocations': {
726 'vip_consoleauth': 'inf: res_nova_consoleauth grp_nova_vips'
727 },
728 'clones': {'cl_nova_haproxy': 'res_nova_haproxy'}
729 }
730 self.relation_set.assert_has_calls([
731 call(groups={'grp_nova_vips': 'res_nova_eth120_vip'}),
732 call(**args),
733 ])
734
735 @patch('nova_cc_hooks.configure_https')
736 @patch('nova_cc_utils.config')
737 def test_config_changed_single_consoleauth(self, config, *args):
738 config.return_value = 'novnc'
739 rids = {'ha': ['ha:1']}
740
741 def f(r):
742 return rids.get(r, [])
743
744 self.relation_ids.side_effect = f
745 hooks.config_changed()
746 args = {
747 'delete_resources': [],
748 'init_services': {'res_nova_consoleauth': 'nova-consoleauth'},
749 'resources': {'res_nova_consoleauth':
750 'ocf:openstack:nova-consoleauth'},
751 'resource_params': {
752 'res_nova_consoleauth': 'op monitor interval="5s"'},
753 'colocations': {
754 'vip_consoleauth': 'inf: res_nova_consoleauth grp_nova_vips'
755 }
756 }
757 self.relation_set.assert_has_calls([
758 call(v, **args) for v in rids['ha']
651 ])759 ])
652760
=== modified file 'unit_tests/test_utils.py'
--- unit_tests/test_utils.py 2014-07-29 12:23:46 +0000
+++ unit_tests/test_utils.py 2015-05-22 18:20:03 +0000
@@ -23,7 +23,7 @@
2323
24 if not config:24 if not config:
25 logging.error('Could not find config.yaml in any parent directory '25 logging.error('Could not find config.yaml in any parent directory '
26 'of %s. ' % file)26 'of %s. ' % f)
27 raise Exception27 raise Exception
2828
29 return yaml.safe_load(open(config).read())['options']29 return yaml.safe_load(open(config).read())['options']

Subscribers

People subscribed via source and target branches