From 3ab6133c2ad1a52c5188cb4236dd2f44448ea9d5 Mon Sep 17 00:00:00 2001 From: Chris Holcombe Date: Thu, 14 Jul 2016 13:49:18 -0700 Subject: [PATCH] Use osd-upgrade user for pause/resume The pause and resume actions shell out to the ceph command to run OSD operations (in/out). Because the default cephx key given out by the monitor cluster does not contain the correct permissions, these commands fail. Use the osd-upgrade user which has the correct permissions. Closes-Bug: 1602826 Depends-On: I6af43b61149c6eeeeb5c77950701194beda2da71 Change-Id: Ie31bc9048972dbb0986ac8deb5b821a4db5d585f --- actions/pause_resume.py | 11 ++++++++--- unit_tests/test_actions_pause_resume.py | 9 ++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/actions/pause_resume.py b/actions/pause_resume.py index f918994a..4d10b759 100755 --- a/actions/pause_resume.py +++ b/actions/pause_resume.py @@ -46,7 +46,10 @@ def pause(args): @raises OSError if it can't get the local osd ids. """ for local_id in get_local_osd_ids(): - cmd = ['ceph', 'osd', 'out', str(local_id)] + cmd = [ + 'ceph', + '--id', 'osd-upgrade', + 'osd', 'out', str(local_id)] check_call(cmd) set_unit_paused() assess_status() @@ -59,12 +62,14 @@ def resume(args): @raises OSError if the unit can't get the local osd ids """ for local_id in get_local_osd_ids(): - cmd = ['ceph', 'osd', 'in', str(local_id)] + cmd = [ + 'ceph', + '--id', 'osd-upgrade', + 'osd', 'in', str(local_id)] check_call(cmd) clear_unit_paused() assess_status() - # A dictionary of all the defined actions to callables (which take # parsed arguments). ACTIONS = {"pause": pause, "resume": resume} diff --git a/unit_tests/test_actions_pause_resume.py b/unit_tests/test_actions_pause_resume.py index 1d2fe072..b0ac4418 100644 --- a/unit_tests/test_actions_pause_resume.py +++ b/unit_tests/test_actions_pause_resume.py @@ -24,7 +24,6 @@ import pause_resume as actions class PauseTestCase(CharmTestCase): - def setUp(self): super(PauseTestCase, self).setUp( actions, ["check_call", @@ -35,14 +34,14 @@ class PauseTestCase(CharmTestCase): def test_pauses_services(self): self.get_local_osd_ids.return_value = [5] actions.pause([]) - cmd = ['ceph', 'osd', 'out', '5'] + cmd = ['ceph', '--id', + 'osd-upgrade', 'osd', 'out', '5'] self.check_call.assert_called_once_with(cmd) self.set_unit_paused.assert_called_once_with() self.assess_status.assert_called_once_with() class ResumeTestCase(CharmTestCase): - def setUp(self): super(ResumeTestCase, self).setUp( actions, ["check_call", @@ -53,14 +52,14 @@ class ResumeTestCase(CharmTestCase): def test_pauses_services(self): self.get_local_osd_ids.return_value = [5] actions.resume([]) - cmd = ['ceph', 'osd', 'in', '5'] + cmd = ['ceph', '--id', + 'osd-upgrade', 'osd', 'in', '5'] self.check_call.assert_called_once_with(cmd) self.clear_unit_paused.assert_called_once_with() self.assess_status.assert_called_once_with() class MainTestCase(CharmTestCase): - def setUp(self): super(MainTestCase, self).setUp(actions, ["action_fail"])