parent
fd61b3d730
commit
9ad9c132fe
|
@ -19,6 +19,7 @@ from kollacli.api.group import GroupApi
|
|||
from kollacli.api.host import HostApi
|
||||
from kollacli.api.password import PasswordApi
|
||||
from kollacli.api.service import ServiceApi
|
||||
from kollacli.api.support import SupportApi
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -30,6 +31,7 @@ class ClientApi(
|
|||
HostApi,
|
||||
PasswordApi,
|
||||
ServiceApi,
|
||||
SupportApi,
|
||||
):
|
||||
|
||||
def base_call(self):
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
# Copyright(c) 2016, Oracle and/or its affiliates. All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
from kollacli.common.support import dump
|
||||
|
||||
|
||||
class SupportApi(object):
|
||||
|
||||
def support_dump(self):
|
||||
"""Dumps configuration data for debugging.
|
||||
|
||||
Dumps most files in /etc/kolla and /usr/share/kolla into a
|
||||
tar file so be given to support / development to help with
|
||||
debugging problems.
|
||||
|
||||
:return: path to dump file
|
||||
:rtype: string
|
||||
"""
|
||||
dumpfile_path = dump()
|
||||
return dumpfile_path
|
|
@ -11,9 +11,14 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
from kollacli.common.support import dump
|
||||
|
||||
from cliff.command import Command
|
||||
from kollacli.api.client import ClientApi
|
||||
import kollacli.i18n as u
|
||||
import logging
|
||||
import traceback
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
CLIENT = ClientApi()
|
||||
|
||||
|
||||
class Dump(Command):
|
||||
|
@ -24,4 +29,10 @@ class Dump(Command):
|
|||
debugging problems.
|
||||
"""
|
||||
def take_action(self, parsed_args):
|
||||
dump()
|
||||
try:
|
||||
dump_path = CLIENT.support_dump()
|
||||
LOG.info(u._('Dump successful to {path}').format(path=dump_path))
|
||||
except Exception:
|
||||
msg = (u._('Dump failed: {reason}')
|
||||
.format(reason=traceback.format_exc()))
|
||||
raise Exception(msg)
|
||||
|
|
|
@ -17,9 +17,6 @@ import logging
|
|||
import os
|
||||
import tarfile
|
||||
import tempfile
|
||||
import traceback
|
||||
|
||||
import kollacli.i18n as u
|
||||
|
||||
from kollacli.common.inventory import Inventory
|
||||
from kollacli.common.utils import get_kolla_etc
|
||||
|
@ -38,53 +35,41 @@ def dump():
|
|||
tar file so be given to support / development to help with
|
||||
debugging problems.
|
||||
"""
|
||||
try:
|
||||
msg = None
|
||||
return_code = 0
|
||||
kolla_home = get_kolla_home()
|
||||
kolla_logs = get_kolla_log_dir()
|
||||
kolla_ansible = os.path.join(kolla_home, 'ansible')
|
||||
kolla_docs = os.path.join(kolla_home, 'docs')
|
||||
kolla_etc = get_kolla_etc()
|
||||
kolla_config = os.path.join(kolla_etc, 'config')
|
||||
kollacli_etc = get_kollacli_etc().rstrip('/')
|
||||
ketc = 'kolla/etc/'
|
||||
kshare = 'kolla/share/'
|
||||
fd, dump_path = tempfile.mkstemp(prefix='kollacli_dump_',
|
||||
suffix='.tgz')
|
||||
os.close(fd) # avoid fd leak
|
||||
with tarfile.open(dump_path, 'w:gz') as tar:
|
||||
# Can't blanket add kolla_home because the .ssh dir is
|
||||
# accessible by the kolla user only (not kolla group)
|
||||
tar.add(kolla_ansible,
|
||||
arcname=kshare + os.path.basename(kolla_ansible))
|
||||
tar.add(kolla_docs,
|
||||
arcname=kshare + os.path.basename(kolla_docs))
|
||||
kolla_home = get_kolla_home()
|
||||
kolla_logs = get_kolla_log_dir()
|
||||
kolla_ansible = os.path.join(kolla_home, 'ansible')
|
||||
kolla_docs = os.path.join(kolla_home, 'docs')
|
||||
kolla_etc = get_kolla_etc()
|
||||
kolla_config = os.path.join(kolla_etc, 'config')
|
||||
kollacli_etc = get_kollacli_etc().rstrip('/')
|
||||
ketc = 'kolla/etc/'
|
||||
kshare = 'kolla/share/'
|
||||
fd, dump_path = tempfile.mkstemp(prefix='kollacli_dump_',
|
||||
suffix='.tgz')
|
||||
os.close(fd) # avoid fd leak
|
||||
with tarfile.open(dump_path, 'w:gz') as tar:
|
||||
# Can't blanket add kolla_home because the .ssh dir is
|
||||
# accessible by the kolla user only (not kolla group)
|
||||
tar.add(kolla_ansible,
|
||||
arcname=kshare + os.path.basename(kolla_ansible))
|
||||
tar.add(kolla_docs,
|
||||
arcname=kshare + os.path.basename(kolla_docs))
|
||||
|
||||
# Can't blanket add kolla_etc because the passwords.yml
|
||||
# file is accessible by the kolla user only (not kolla group)
|
||||
tar.add(kolla_config,
|
||||
arcname=ketc + os.path.basename(kolla_config))
|
||||
tar.add(kollacli_etc,
|
||||
arcname=ketc + os.path.basename(kollacli_etc))
|
||||
# Can't blanket add kolla_etc because the passwords.yml
|
||||
# file is accessible by the kolla user only (not kolla group)
|
||||
tar.add(kolla_config,
|
||||
arcname=ketc + os.path.basename(kolla_config))
|
||||
tar.add(kollacli_etc,
|
||||
arcname=ketc + os.path.basename(kollacli_etc))
|
||||
|
||||
# add kolla log files
|
||||
if os.path.isdir(kolla_logs):
|
||||
tar.add(kolla_logs)
|
||||
# add kolla log files
|
||||
if os.path.isdir(kolla_logs):
|
||||
tar.add(kolla_logs)
|
||||
|
||||
# add output of various commands
|
||||
_add_cmd_info(tar)
|
||||
# add output of various commands
|
||||
_add_cmd_info(tar)
|
||||
|
||||
msg = u._LI('dump successful to {path}').format(path=dump_path)
|
||||
LOG.info(msg)
|
||||
|
||||
except Exception:
|
||||
msg = (u._LI('dump failed: {reason}')
|
||||
.format(reason=traceback.format_exc()))
|
||||
LOG.error(msg)
|
||||
return_code = -1
|
||||
|
||||
return return_code, msg
|
||||
return dump_path
|
||||
|
||||
|
||||
def _add_cmd_info(tar):
|
||||
|
|
Loading…
Reference in New Issue