Merge lp:~james-page/charms/trusty/glance/fixup-allowedunits-migration into lp:~openstack-charmers-archive/charms/trusty/glance/next

Proposed by James Page
Status: Merged
Merged at revision: 111
Proposed branch: lp:~james-page/charms/trusty/glance/fixup-allowedunits-migration
Merge into: lp:~openstack-charmers-archive/charms/trusty/glance/next
Diff against target: 65 lines (+23/-13)
2 files modified
hooks/glance_relations.py (+12/-11)
unit_tests/test_glance_relations.py (+11/-2)
To merge this branch: bzr merge lp:~james-page/charms/trusty/glance/fixup-allowedunits-migration
Reviewer Review Type Date Requested Status
Liam Young (community) Approve
Adam Collard (community) Approve
Review via email: mp+256956@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Adam Collard (adam-collard) wrote :

Needs tests

review: Needs Fixing
112. By James Page

Add unit tests to ensure that acls are setup prior to db migration

113. By James Page

Tidy lint

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

charm_lint_check #3688 glance-next for james-page mp256956
    LINT OK: passed

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

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

charm_unit_test #3475 glance-next for james-page mp256956
    UNIT OK: passed

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

Revision history for this message
Adam Collard (adam-collard) wrote :

Thanks for adding those. +1

review: Approve
Revision history for this message
Liam Young (gnuoy) wrote :

Approve

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/glance_relations.py'
2--- hooks/glance_relations.py 2015-04-01 16:48:59 +0000
3+++ hooks/glance_relations.py 2015-04-21 15:33:22 +0000
4@@ -164,18 +164,19 @@
5 # acl entry has been added. So, if the db supports passing a list of
6 # permitted units then check if we're in the list.
7 allowed_units = relation_get('allowed_units')
8- if allowed_units and local_unit() not in allowed_units.split():
9- juju_log('Allowed_units list provided and this unit not present')
10- return
11- if rel == "essex":
12- status = call(['glance-manage', 'db_version'])
13- if status != 0:
14- juju_log('Setting version_control to 0')
15- cmd = ["glance-manage", "version_control", "0"]
16- check_call(cmd)
17+ if allowed_units and local_unit() in allowed_units.split():
18+ if rel == "essex":
19+ status = call(['glance-manage', 'db_version'])
20+ if status != 0:
21+ juju_log('Setting version_control to 0')
22+ cmd = ["glance-manage", "version_control", "0"]
23+ check_call(cmd)
24
25- juju_log('Cluster leader, performing db sync')
26- migrate_database()
27+ juju_log('Cluster leader, performing db sync')
28+ migrate_database()
29+ else:
30+ juju_log('allowed_units either not presented, or local unit '
31+ 'not in acl list: %s' % allowed_units)
32
33
34 @hooks.hook('pgsql-db-relation-changed')
35
36=== modified file 'unit_tests/test_glance_relations.py'
37--- unit_tests/test_glance_relations.py 2015-04-01 16:48:59 +0000
38+++ unit_tests/test_glance_relations.py 2015-04-21 15:33:22 +0000
39@@ -207,8 +207,9 @@
40 'pgsql-db relation incomplete. Peer not ready?'
41 )
42
43- def _shared_db_test(self, configs, unit_name):
44- self.relation_get.return_value = 'glance/0 glance/3'
45+ def _shared_db_test(self, configs, unit_name,
46+ allowed_units='glance/0 glance/3'):
47+ self.relation_get.return_value = allowed_units
48 self.local_unit.return_value = unit_name
49 configs.complete_contexts = MagicMock()
50 configs.complete_contexts.return_value = ['shared-db']
51@@ -241,6 +242,14 @@
52 self.assertFalse(self.migrate_database.called)
53
54 @patch.object(relations, 'CONFIGS')
55+ def test_db_changed_no_acls(self, configs):
56+ self._shared_db_test(configs, 'glance/2', None)
57+ self.assertEquals([call('/etc/glance/glance-registry.conf'),
58+ call('/etc/glance/glance-api.conf')],
59+ configs.write.call_args_list)
60+ self.assertFalse(self.migrate_database.called)
61+
62+ @patch.object(relations, 'CONFIGS')
63 def test_postgresql_db_changed_no_essex(self, configs):
64 self._postgresql_db_test(configs)
65 self.assertEquals([call('/etc/glance/glance-registry.conf'),

Subscribers

People subscribed via source and target branches