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: I95bedcdea622fbf2fd799e63932cedd0d577568a
This commit is contained in:
Chris Holcombe 2016-07-15 13:47:42 -07:00 committed by James Page
parent bdcb3fe1df
commit becf5ef80f
3 changed files with 16 additions and 4 deletions

View File

@ -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,7 +62,10 @@ 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()

View File

@ -349,6 +349,10 @@ osd_upgrade_caps = {
'allow command "config-key put"',
'allow command "config-key get"',
'allow command "config-key exists"',
'allow command "osd out"',
'allow command "osd in"',
'allow command "osd rm"',
'allow command "auth del"',
]
}

View File

@ -43,7 +43,8 @@ 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()
@ -61,7 +62,8 @@ 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()