Skip to content

Commit a42d787

Browse files
asm0deuzguits
authored andcommitted
Fix CI issues
- 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 <tonay@ibm.com>
1 parent 3e9fa3c commit a42d787

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2385
-1181
lines changed

changelogs/fragments/1_0_2.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
major_changes:
2+
- Import ceph-ansible modules and fixes unittests

plugins/module_utils/ceph_common.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
__metaclass__ = type
33

44
import datetime
5+
import os
56
import time
67
from typing import TYPE_CHECKING, Any, List, Dict, Callable, Type, TypeVar, Optional
78

@@ -10,6 +11,7 @@
1011

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

14+
1315
def generate_cmd(cmd='ceph',
1416
sub_cmd=None,
1517
args=None,
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from __future__ import absolute_import, division, print_function
2+
__metaclass__ = type
3+
4+
5+
try:
6+
from ansible_collections.ceph.automation.plugins.module_utils.ceph_common import generate_cmd
7+
except ImportError:
8+
from module_utils.ceph_common import generate_cmd
9+
10+
11+
def get_rule(module, container_image=None):
12+
'''
13+
Get existing crush rule
14+
'''
15+
16+
cluster = module.params.get('cluster')
17+
name = module.params.get('name')
18+
19+
args = ['dump', name, '--format=json']
20+
21+
cmd = generate_cmd(sub_cmd=['osd', 'crush', 'rule'],
22+
args=args,
23+
cluster=cluster,
24+
container_image=container_image)
25+
26+
return cmd
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from __future__ import absolute_import, division, print_function
2+
__metaclass__ = type
3+
4+
5+
def exec_commands(module, cmd_list):
6+
'''
7+
Execute command(s)
8+
'''
9+
10+
for cmd in cmd_list:
11+
rc, out, err = module.run_command(cmd)
12+
if rc != 0:
13+
return rc, cmd, out, err
14+
15+
return rc, cmd, out, err

0 commit comments

Comments
 (0)