Move get_ceph_conf_filename to util
required for reusing this functions in other commands Change-Id: If53610e5b47eeb8364b5c6c74c80ad32f329c708
This commit is contained in:
parent
d21f7cff25
commit
bf77a7a947
|
@ -22,6 +22,7 @@ from cliff import command as cmd
|
|||
from fuelclient.objects import environment as environment_obj
|
||||
|
||||
from octane import magic_consts
|
||||
from octane.util import ceph
|
||||
from octane.util import env as env_util
|
||||
from octane.util import node as node_util
|
||||
from octane.util import ssh
|
||||
|
@ -68,20 +69,6 @@ def import_bootstrap_osd(node):
|
|||
"allow profile bootstrap-osd"], node=node)
|
||||
|
||||
|
||||
def get_ceph_conf_filename(node):
|
||||
cmd = [
|
||||
'bash', '-c',
|
||||
'pgrep ceph-mon | xargs -I{} cat /proc/{}/cmdline',
|
||||
]
|
||||
cmdlines = ssh.call_output(cmd, node=node)
|
||||
if cmdlines:
|
||||
cmdline = cmdlines.split('\n')[0].split('\0')
|
||||
for i, value in enumerate(cmdline):
|
||||
if value == '-c' and i < len(cmdline):
|
||||
return cmdline[i + 1]
|
||||
return '/etc/ceph/ceph.conf'
|
||||
|
||||
|
||||
def add_rgw_frontends(conf):
|
||||
rgw_frontends_line = ("rgw_frontends = fastcgi socket_port=9000 "
|
||||
"socket_host=127.0.0.1")
|
||||
|
@ -161,7 +148,7 @@ def ceph_set_new_mons(orig_env, seed_env, filename, conf_filename, db_path):
|
|||
|
||||
def extract_mon_conf_files(orig_env, tar_filename):
|
||||
controller = env_util.get_one_controller(orig_env)
|
||||
conf_filename = get_ceph_conf_filename(controller)
|
||||
conf_filename = ceph.get_ceph_conf_filename(controller)
|
||||
conf_dir = os.path.dirname(conf_filename)
|
||||
hostname = short_hostname(
|
||||
node_util.get_hostname_remotely(controller))
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import pytest
|
||||
|
||||
from octane.util import ceph
|
||||
|
||||
|
||||
@pytest.mark.parametrize("cmd_output,conf_file", [
|
||||
(
|
||||
"/usr/bin/ceph-mon\0--cluster=ceph\0-i\0node-4\0-f",
|
||||
"/etc/ceph/ceph.conf"
|
||||
),
|
||||
("", "/etc/ceph/ceph.conf"),
|
||||
(
|
||||
"/usr/bin/ceph-mon\0--cluster=ceph\0-i\0node-4\0-f\0-c\0new_conf_path",
|
||||
"new_conf_path"
|
||||
),
|
||||
])
|
||||
def test_get_ceph_conf_filename(mocker, node, cmd_output, conf_file):
|
||||
cmd = [
|
||||
'bash', '-c',
|
||||
'pgrep ceph-mon | xargs -I{} cat /proc/{}/cmdline',
|
||||
]
|
||||
mock_ssh = mocker.patch(
|
||||
"octane.util.ssh.call_output", return_value=cmd_output)
|
||||
assert conf_file == ceph.get_ceph_conf_filename(node)
|
||||
mock_ssh.assert_called_once_with(cmd, node=node)
|
|
@ -34,3 +34,17 @@ def set_osd_noout(env):
|
|||
def unset_osd_noout(env):
|
||||
controller = env_util.get_one_controller(env)
|
||||
ssh.call(['ceph', 'osd', 'unset', 'noout'], node=controller)
|
||||
|
||||
|
||||
def get_ceph_conf_filename(node):
|
||||
cmd = [
|
||||
'bash', '-c',
|
||||
'pgrep ceph-mon | xargs -I{} cat /proc/{}/cmdline',
|
||||
]
|
||||
cmdlines = ssh.call_output(cmd, node=node)
|
||||
if cmdlines:
|
||||
cmdline = cmdlines.split('\n')[0].split('\0')
|
||||
for i, value in enumerate(cmdline):
|
||||
if value == '-c' and i < len(cmdline):
|
||||
return cmdline[i + 1]
|
||||
return '/etc/ceph/ceph.conf'
|
||||
|
|
Loading…
Reference in New Issue