mirror of https://github.com/ceph/ceph-ansible.git
lib/ceph-volume: support zapping by osd_id
This commit adds the support for zapping an osd by osd_id in the ceph_volume module. Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>pull/6718/head
parent
a305296384
commit
70f1d6e2cd
|
@ -62,6 +62,10 @@ options:
|
||||||
description:
|
description:
|
||||||
- The OSD FSID
|
- The OSD FSID
|
||||||
required: false
|
required: false
|
||||||
|
osd_id:
|
||||||
|
description:
|
||||||
|
- The OSD ID
|
||||||
|
required: false
|
||||||
journal:
|
journal:
|
||||||
description:
|
description:
|
||||||
- The logical volume name or partition to use as a filestore journal.
|
- The logical volume name or partition to use as a filestore journal.
|
||||||
|
@ -476,6 +480,7 @@ def zap_devices(module, container_image):
|
||||||
wal = module.params.get('wal', None)
|
wal = module.params.get('wal', None)
|
||||||
wal_vg = module.params.get('wal_vg', None)
|
wal_vg = module.params.get('wal_vg', None)
|
||||||
osd_fsid = module.params.get('osd_fsid', None)
|
osd_fsid = module.params.get('osd_fsid', None)
|
||||||
|
osd_id = module.params.get('osd_id', None)
|
||||||
destroy = module.params.get('destroy', True)
|
destroy = module.params.get('destroy', True)
|
||||||
|
|
||||||
# build the CLI
|
# build the CLI
|
||||||
|
@ -487,6 +492,9 @@ def zap_devices(module, container_image):
|
||||||
if osd_fsid:
|
if osd_fsid:
|
||||||
cmd.extend(['--osd-fsid', osd_fsid])
|
cmd.extend(['--osd-fsid', osd_fsid])
|
||||||
|
|
||||||
|
if osd_id:
|
||||||
|
cmd.extend(['--osd-id', osd_id])
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
data = get_data(data, data_vg)
|
data = get_data(data, data_vg)
|
||||||
cmd.append(data)
|
cmd.append(data)
|
||||||
|
@ -533,12 +541,19 @@ def run_module():
|
||||||
wal_devices=dict(type='list', required=False, default=[]),
|
wal_devices=dict(type='list', required=False, default=[]),
|
||||||
report=dict(type='bool', required=False, default=False),
|
report=dict(type='bool', required=False, default=False),
|
||||||
osd_fsid=dict(type='str', required=False),
|
osd_fsid=dict(type='str', required=False),
|
||||||
|
osd_id=dict(type='str', required=False),
|
||||||
destroy=dict(type='bool', required=False, default=True),
|
destroy=dict(type='bool', required=False, default=True),
|
||||||
)
|
)
|
||||||
|
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=module_args,
|
argument_spec=module_args,
|
||||||
supports_check_mode=True
|
supports_check_mode=True,
|
||||||
|
mutually_exclusive=[
|
||||||
|
('data', 'osd_fsid', 'osd_id'),
|
||||||
|
],
|
||||||
|
required_if=[
|
||||||
|
('action', 'zap', ('data', 'osd_fsid', 'osd_id'), True)
|
||||||
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
result = dict(
|
result = dict(
|
||||||
|
@ -621,7 +636,8 @@ def run_module():
|
||||||
|
|
||||||
cmd = zap_devices(module, container_image)
|
cmd = zap_devices(module, container_image)
|
||||||
|
|
||||||
if any(skip) or module.params.get('osd_fsid', None):
|
if any(skip) or module.params.get('osd_fsid', None) \
|
||||||
|
or module.params.get('osd_id', None):
|
||||||
rc, cmd, out, err = exec_command(
|
rc, cmd, out, err = exec_command(
|
||||||
module, cmd)
|
module, cmd)
|
||||||
for scan_cmd in ['vgscan', 'lvscan']:
|
for scan_cmd in ['vgscan', 'lvscan']:
|
||||||
|
|
|
@ -113,6 +113,21 @@ class TestCephVolumeModule(object):
|
||||||
result = ceph_volume.zap_devices(fake_module, fake_container_image)
|
result = ceph_volume.zap_devices(fake_module, fake_container_image)
|
||||||
assert result == expected_command_list
|
assert result == expected_command_list
|
||||||
|
|
||||||
|
def test_zap_osd_id(self):
|
||||||
|
fake_module = MagicMock()
|
||||||
|
fake_module.params = {'osd_id': '123'}
|
||||||
|
fake_container_image = None
|
||||||
|
expected_command_list = ['ceph-volume',
|
||||||
|
'--cluster',
|
||||||
|
'ceph',
|
||||||
|
'lvm',
|
||||||
|
'zap',
|
||||||
|
'--destroy',
|
||||||
|
'--osd-id',
|
||||||
|
'123']
|
||||||
|
result = ceph_volume.zap_devices(fake_module, fake_container_image)
|
||||||
|
assert result == expected_command_list
|
||||||
|
|
||||||
def test_activate_osd(self):
|
def test_activate_osd(self):
|
||||||
expected_command_list = ['ceph-volume',
|
expected_command_list = ['ceph-volume',
|
||||||
'--cluster',
|
'--cluster',
|
||||||
|
|
Loading…
Reference in New Issue