Skip to content
This repository has been archived by the owner on Feb 1, 2021. It is now read-only.

Commit

Permalink
script & package log dir content added to support bundle; /tmp prefix…
Browse files Browse the repository at this point in the history
… removed on support bundle creation from path (#1694)
  • Loading branch information
ashish-jabble authored Sep 10, 2019
1 parent 6fe34da commit 6e16c58
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
data/etc/storage.json
data/etc/certs/*
data/var
data/tmp
data/support
data/scripts
data/plugins
data/snapshots
Expand Down
4 changes: 2 additions & 2 deletions python/foglamp/services/core/api/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ async def get_syslog_entries(request):

def _get_support_dir():
if _FOGLAMP_DATA:
support_dir = os.path.expanduser(_FOGLAMP_DATA + '/tmp/support')
support_dir = os.path.expanduser(_FOGLAMP_DATA + '/support')
else:
support_dir = os.path.expanduser(_FOGLAMP_ROOT + '/data/tmp/support')
support_dir = os.path.expanduser(_FOGLAMP_ROOT + '/data/support')

return support_dir
20 changes: 20 additions & 0 deletions python/foglamp/services/core/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
from foglamp.services.core.connect import *
from foglamp.common import logger
from foglamp.services.core.api.service import get_service_records
from foglamp.common.common import _FOGLAMP_ROOT, _FOGLAMP_DATA


__author__ = "Amarendra K Sinha"
__copyright__ = "Copyright (c) 2017 OSIsoft, LLC"
Expand All @@ -30,6 +32,7 @@
_LOGGER = logger.setup(__name__)
_NO_OF_FILES_TO_RETAIN = 3
_SYSLOG_FILE = '/var/log/syslog'
_PATH = _FOGLAMP_DATA if _FOGLAMP_DATA else _FOGLAMP_ROOT + '/data'

if ('centos' in platform.platform()) or ('redhat' in platform.platform()):
_SYSLOG_FILE = '/var/log/messages'
Expand Down Expand Up @@ -71,6 +74,8 @@ async def build(self):
self.add_service_registry(pyz, file_spec)
self.add_machine_resources(pyz, file_spec)
self.add_psinfo(pyz, file_spec)
self.add_script_dir_content(pyz)
self.add_package_log_dir_content(pyz)
finally:
pyz.close()
except Exception as ex:
Expand Down Expand Up @@ -177,3 +182,18 @@ def add_psinfo(self, pyz, file_spec):
"runningPythonProcesses": c
}
self.write_to_tar(pyz, temp_file, data)

def add_script_dir_content(self, pyz):
script_file_path = _PATH + '/scripts'
if os.path.exists(script_file_path):
# recursively 'true' by default and __pycache__ dir excluded
pyz.add(script_file_path, arcname='scripts', filter=self.exclude_pycache)

def add_package_log_dir_content(self, pyz):
script_package_logs_path = _PATH + '/logs'
if os.path.exists(script_package_logs_path):
# recursively 'true' by default and __pycache__ dir excluded
pyz.add(script_package_logs_path, arcname='package_logs', filter=self.exclude_pycache)

def exclude_pycache(self, tar_info):
return None if '__pycache__' in tar_info.name else tar_info

0 comments on commit 6e16c58

Please sign in to comment.