Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not pass NoneType as argument to ceph_crush_rule #7466

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion library/ceph_crush_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
options:
name:
description:
- name of the Ceph Crush rule.
- name of the Ceph Crush rule. If state is 'info' - empty string
can be provided as a value to get all crush rules
required: true
cluster:
description:
Expand Down
2 changes: 1 addition & 1 deletion roles/ceph-facts/tasks/get_def_crush_rule_name.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: get current default crush rule details
ceph_crush_rule:
name: null
name: ""
cluster: "{{ cluster }}"
state: info
environment:
Expand Down
25 changes: 25 additions & 0 deletions tests/library/test_ceph_crush_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,31 @@ def test_get_existing_rule(self, m_run_command, m_exit_json):
assert result['stderr'] == stderr
assert result['stdout'] == stdout

@patch('ansible.module_utils.basic.AnsibleModule.exit_json')
@patch('ansible.module_utils.basic.AnsibleModule.run_command')
def test_get_all_rules(self, m_run_command, m_exit_json):
ca_test_common.set_module_args({
'name': str(),
'state': 'info'
})
m_exit_json.side_effect = ca_test_common.exit_json
rc = 0
stderr = ''
stdout = '{{"rule_name":"{}","steps":[{{"item_name":"{}"}},{{"type":"{}"}}]}}'.format(fake_name, fake_bucket_root, fake_bucket_type)
m_run_command.return_value = rc, stdout, stderr

with pytest.raises(ca_test_common.AnsibleExitJson) as result:
ceph_crush_rule.main()

result = result.value.args[0]
assert not result['changed']
assert result['cmd'] == ['ceph', '-n', fake_user, '-k', fake_keyring,
'--cluster', fake_cluster, 'osd', 'crush', 'rule',
'dump', '', '--format=json']
assert result['rc'] == rc
assert result['stderr'] == stderr
assert result['stdout'] == stdout

@patch.dict(os.environ, {'CEPH_CONTAINER_BINARY': fake_container_binary})
@patch.dict(os.environ, {'CEPH_CONTAINER_IMAGE': fake_container_image})
@patch('ansible.module_utils.basic.AnsibleModule.exit_json')
Expand Down
Loading