Skip to content

Commit

Permalink
Merge pull request #146 from elyezer/foreman-debug-task
Browse files Browse the repository at this point in the history
Add foreman_debug task
  • Loading branch information
sthirugn committed Feb 18, 2015
2 parents f6fc70f + 2021134 commit aadfffc
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 aadfffc

Please sign in to comment.