Skip to content

Commit

Permalink
Add foreman_debug task
Browse files Browse the repository at this point in the history
This task helps on creating bugs by generate and download the
foreman-debug report tarball and also prints the Satellite release
string. The release string will be grabbed from the satellite.repo yum
repo file which is the repo file created for every downstream install.

Closes #137
  • Loading branch information
elyezer committed Feb 18, 2015
1 parent f6fc70f commit 2021134
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
30 changes: 29 additions & 1 deletion automation_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from re import search
from urlparse import urlsplit

from fabric.api import cd, env, execute, local, put, run, warn_only
from fabric.api import cd, env, execute, get, local, put, run, warn_only
if sys.version_info[0] is 2:
from urlparse import urljoin # (import-error) pylint:disable=F0401
from StringIO import StringIO # (import-error) pylint:disable=F0401
Expand Down Expand Up @@ -1457,6 +1457,34 @@ def update_packages(*args, **kwargs):
)


# =============================================================================
# Utility tasks
# =============================================================================
def foreman_debug(tarball_name=None):
"""Generates and download the foreman-debug generated tarball
:param str tarball_name: The tarball file name which will be downloaded
relative to the current working directory. If ``None`` the tarball will
be named foreman-debug-<timestamp>.
"""
if tarball_name is None:
tarball_name = 'foreman-debug-{0}'.format(int(time.time()))

with cd('/tmp'):
run('foreman-debug -q -d {0}'.format(tarball_name), quiet=True)
get(
local_path='%(basename)s',
remote_path='/tmp/{0}/{0}.tar.xz'.format(tarball_name),
)

release = run(
'cat /etc/yum.repos.d/satellite.repo | grep baseurl | cut -d "/" -f 7',
quiet=True
)
print('Satellite release: {0}'.format(release))


# =============================================================================
# Helper functions
# =============================================================================
Expand Down
1 change: 1 addition & 0 deletions fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
downstream_install,
errata_upgrade,
fix_hostname,
foreman_debug,
install_errata,
install_katello_agent,
install_prerequisites,
Expand Down

0 comments on commit 2021134

Please sign in to comment.