Skip to content

Commit

Permalink
Fix CI issues
Browse files Browse the repository at this point in the history
- Fixes ansible-lint errors
- Extract info and list states from ceph_key (1) by creating 2 new
  modules
- Extract info from ceph_crush_rules (1) by creating an additional
  module

(1) https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_general.html#creating-an-info-or-a-facts-module

Signed-off-by: Teoman ONAY <[email protected]>
  • Loading branch information
asm0deuz authored and guits committed Dec 9, 2024
1 parent 3e9fa3c commit a42d787
Show file tree
Hide file tree
Showing 62 changed files with 2,385 additions and 1,181 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/1_0_2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
major_changes:
- Import ceph-ansible modules and fixes unittests
2 changes: 2 additions & 0 deletions plugins/module_utils/ceph_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
__metaclass__ = type

import datetime
import os
import time
from typing import TYPE_CHECKING, Any, List, Dict, Callable, Type, TypeVar, Optional

Expand All @@ -10,6 +11,7 @@

ExceptionType = TypeVar('ExceptionType', bound=BaseException)


def generate_cmd(cmd='ceph',
sub_cmd=None,
args=None,
Expand Down
26 changes: 26 additions & 0 deletions plugins/module_utils/ceph_crush_rule_common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type


try:
from ansible_collections.ceph.automation.plugins.module_utils.ceph_common import generate_cmd
except ImportError:
from module_utils.ceph_common import generate_cmd


def get_rule(module, container_image=None):
'''
Get existing crush rule
'''

cluster = module.params.get('cluster')
name = module.params.get('name')

args = ['dump', name, '--format=json']

cmd = generate_cmd(sub_cmd=['osd', 'crush', 'rule'],
args=args,
cluster=cluster,
container_image=container_image)

return cmd
15 changes: 15 additions & 0 deletions plugins/module_utils/ceph_key_common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type


def exec_commands(module, cmd_list):
'''
Execute command(s)
'''

for cmd in cmd_list:
rc, out, err = module.run_command(cmd)
if rc != 0:
return rc, cmd, out, err

return rc, cmd, out, err
Loading

0 comments on commit a42d787

Please sign in to comment.