diff --git a/awx/main/management/commands/check_migrations.py b/awx/main/management/commands/check_migrations.py
index 50ea354960..6f9cfc7727 100644
--- a/awx/main/management/commands/check_migrations.py
+++ b/awx/main/management/commands/check_migrations.py
@@ -8,5 +8,7 @@ class Command(MakeMigrations):
def execute(self, *args, **options):
settings = connections['default'].settings_dict.copy()
settings['ENGINE'] = 'sqlite3'
+ if 'application_name' in settings['OPTIONS']:
+ del settings['OPTIONS']['application_name']
connections['default'] = DatabaseWrapper(settings)
return MakeMigrations().execute(*args, **options)
diff --git a/awx/main/management/commands/graph_jobs.py b/awx/main/management/commands/graph_jobs.py
new file mode 100644
index 0000000000..f1c8ad75e1
--- /dev/null
+++ b/awx/main/management/commands/graph_jobs.py
@@ -0,0 +1,117 @@
+# Python
+import asciichartpy as chart
+import collections
+import time
+import sys
+
+# Django
+from django.db.models import Count
+from django.core.management.base import BaseCommand
+
+# AWX
+from awx.main.models import (
+ Job,
+ Instance
+)
+
+
+DEFAULT_WIDTH = 100
+DEFAULT_HEIGHT = 30
+
+
+def chart_color_lookup(color_str):
+ return getattr(chart, color_str)
+
+
+def clear_screen():
+ print(chr(27) + "[2J")
+
+
+class JobStatus():
+ def __init__(self, status, color, width):
+ self.status = status
+ self.color = color
+ self.color_code = chart_color_lookup(color)
+ self.x = collections.deque(maxlen=width)
+ self.y = collections.deque(maxlen=width)
+
+ def tick(self, x, y):
+ self.x.append(x)
+ self.y.append(y)
+
+
+class JobStatusController:
+ RESET = chart_color_lookup('reset')
+
+ def __init__(self, width):
+ self.plots = [
+ JobStatus('pending', 'red', width),
+ JobStatus('waiting', 'blue', width),
+ JobStatus('running', 'green', width)
+ ]
+ self.ts_start = int(time.time())
+
+ def tick(self):
+ ts = int(time.time()) - self.ts_start
+ q = Job.objects.filter(status__in=['pending','waiting','running']).values_list('status').order_by().annotate(Count('status'))
+ status_count = dict(pending=0, waiting=0, running=0)
+ for status, count in q:
+ status_count[status] = count
+
+ for p in self.plots:
+ p.tick(ts, status_count[p.status])
+
+ def series(self):
+ return [list(p.y) for p in self.plots]
+
+ def generate_status(self):
+ line = ""
+ lines = []
+ for p in self.plots:
+ lines.append(f'{p.color_code}{p.status} {p.y[-1]}{self.RESET}')
+
+ line += ", ".join(lines) + '\n'
+
+ width = 5
+ time_running = int(time.time()) - self.ts_start
+ instances = Instance.objects.all().order_by('hostname')
+ line += "Capacity: " + ", ".join([f"{instance.capacity:{width}}" for instance in instances]) + '\n'
+ line += "Remaining: " + ", ".join([f"{instance.remaining_capacity:{width}}" for instance in instances]) + '\n'
+ line += f"Seconds running: {time_running}" + '\n'
+
+ return line
+
+
+class Command(BaseCommand):
+ help = "Plot pending, waiting, running jobs over time on the terminal"
+
+ def add_arguments(self, parser):
+ parser.add_argument('--refresh', dest='refresh', type=float, default=1.0,
+ help='Time between refreshes of the graph and data in seconds (defaults to 1.0)')
+ parser.add_argument('--width', dest='width', type=int, default=DEFAULT_WIDTH,
+ help=f'Width of the graph (defaults to {DEFAULT_WIDTH})')
+ parser.add_argument('--height', dest='height', type=int, default=DEFAULT_HEIGHT,
+ help=f'Height of the graph (defaults to {DEFAULT_HEIGHT})')
+
+ def handle(self, *args, **options):
+ refresh_seconds = options['refresh']
+ width = options['width']
+ height = options['height']
+
+ jctl = JobStatusController(width)
+
+ conf = {
+ 'colors': [chart_color_lookup(p.color) for p in jctl.plots],
+ 'height': height,
+ }
+
+ while True:
+ jctl.tick()
+
+ draw = chart.plot(jctl.series(), conf)
+ status_line = jctl.generate_status()
+ clear_screen()
+ print(draw)
+ sys.stdout.write(status_line)
+ time.sleep(refresh_seconds)
+
diff --git a/awx/main/scheduler/task_manager.py b/awx/main/scheduler/task_manager.py
index 861aa0b63f..43d43fe64d 100644
--- a/awx/main/scheduler/task_manager.py
+++ b/awx/main/scheduler/task_manager.py
@@ -14,6 +14,7 @@ from django.db import transaction, connection
from django.utils.translation import ugettext_lazy as _, gettext_noop
from django.utils.timezone import now as tz_now
from django.conf import settings
+from django.db.models import Q
# AWX
from awx.main.dispatch.reaper import reap_job
@@ -67,7 +68,7 @@ class TaskManager():
'''
Init AFTER we know this instance of the task manager will run because the lock is acquired.
'''
- instances = Instance.objects.filter(capacity__gt=0, enabled=True)
+ instances = Instance.objects.filter(~Q(hostname=None), capacity__gt=0, enabled=True)
self.real_instances = {i.hostname: i for i in instances}
instances_partial = [SimpleNamespace(obj=instance,
@@ -284,7 +285,7 @@ class TaskManager():
for group in InstanceGroup.objects.all():
if group.is_containerized or group.controller_id:
continue
- match = group.fit_task_to_most_remaining_capacity_instance(task)
+ match = group.fit_task_to_most_remaining_capacity_instance(task, group.instances.all())
if match:
break
task.instance_group = rampart_group
@@ -528,7 +529,8 @@ class TaskManager():
logger.debug("Starting {} in group {} instance {} (remaining_capacity={})".format(
task.log_format, rampart_group.name, execution_instance.hostname, remaining_capacity))
- execution_instance = self.real_instances[execution_instance.hostname]
+ if execution_instance:
+ execution_instance = self.real_instances[execution_instance.hostname]
self.graph[rampart_group.name]['graph'].add_job(task)
self.start_task(task, rampart_group, task.get_jobs_fail_chain(), execution_instance)
found_acceptable_queue = True
diff --git a/awx/settings/development.py b/awx/settings/development.py
index 3a4e008488..108767b98c 100644
--- a/awx/settings/development.py
+++ b/awx/settings/development.py
@@ -184,3 +184,6 @@ else:
pass
AWX_CALLBACK_PROFILE = True
+
+if 'sqlite3' not in DATABASES['default']['ENGINE']: # noqa
+ DATABASES['default'].setdefault('OPTIONS', dict()).setdefault('application_name', f'{CLUSTER_HOST_ID}-{os.getpid()}-{" ".join(sys.argv)}'[:63]) # noqa
diff --git a/awx/settings/production.py b/awx/settings/production.py
index c2cde28c0f..fb24b7087f 100644
--- a/awx/settings/production.py
+++ b/awx/settings/production.py
@@ -102,6 +102,7 @@ except IOError:
else:
raise
+# The below runs AFTER all of the custom settings are imported.
CELERYBEAT_SCHEDULE.update({ # noqa
'isolated_heartbeat': {
@@ -110,3 +111,5 @@ CELERYBEAT_SCHEDULE.update({ # noqa
'options': {'expires': AWX_ISOLATED_PERIODIC_CHECK * 2}, # noqa
}
})
+
+DATABASES['default'].setdefault('OPTIONS', dict()).setdefault('application_name', f'{CLUSTER_HOST_ID}-{os.getpid()}-{" ".join(sys.argv)}'[:63]) # noqa
diff --git a/awx/ui/client/src/license/license.partial.html b/awx/ui/client/src/license/license.partial.html
index 9a4a9a80f7..2dc7beeb9c 100644
--- a/awx/ui/client/src/license/license.partial.html
+++ b/awx/ui/client/src/license/license.partial.html
@@ -125,7 +125,7 @@
- Provide your Red Hat customer credentials and you can choose from a list of your available licenses. The credentials you use will be stored for future use in retrieving renewal or expanded licenses. You can update or remove them in SETTINGS > SYSTEM.
+ Provide your Red Hat customer credentials and you can choose from a list of your available licenses. The credentials you use will be stored for future use in retrieving renewal or expanded licenses. You can update or remove them in SETTINGS > SYSTEM.
diff --git a/awx/ui/po/ansible-tower-ui.pot b/awx/ui/po/ansible-tower-ui.pot
index f3fb4fe286..5da8733512 100644
--- a/awx/ui/po/ansible-tower-ui.pot
+++ b/awx/ui/po/ansible-tower-ui.pot
@@ -5070,7 +5070,7 @@ msgid "Provide environment variables to pass to the custom inventory script."
msgstr ""
#: client/src/license/license.partial.html:128
-msgid "Provide your Red Hat customer credentials and you can choose from a list of your available licenses. The credentials you use will be stored for future use in retrieving renewal or expanded licenses. You can update or remove them in SETTINGS > SYSTEM."
+msgid "Provide your Red Hat customer credentials and you can choose from a list of your available licenses. The credentials you use will be stored for future use in retrieving renewal or expanded licenses. You can update or remove them in SETTINGS > SYSTEM."
msgstr ""
#: client/src/templates/job_templates/job-template.form.js:374
diff --git a/awx/ui/po/es.po b/awx/ui/po/es.po
index c70c66ee02..fdc1229418 100644
--- a/awx/ui/po/es.po
+++ b/awx/ui/po/es.po
@@ -5179,8 +5179,8 @@ msgid "Provide the named URL encoded name or id of the remote Tower inventory to
msgstr "Indique la URL, el nombre cifrado o id del inventario remoto de Tower para importarlos."
#: client/src/license/license.partial.html:128
-msgid "Provide your Red Hat customer credentials and you can choose from a list of your available licenses. The credentials you use will be stored for future use in retrieving renewal or expanded licenses. You can update or remove them in SETTINGS > SYSTEM."
-msgstr "Proporcione sus credenciales de cliente de Red Hat y podrá elegir de una lista de sus licencias disponibles. Las credenciales que utilice se almacenarán para su uso futuro en la recuperación de las licencias de renovación o ampliadas. Puede actualizarlas o eliminarlas en CONFIGURACIÓN > SISTEMA."
+msgid "Provide your Red Hat customer credentials and you can choose from a list of your available licenses. The credentials you use will be stored for future use in retrieving renewal or expanded licenses. You can update or remove them in SETTINGS > SYSTEM."
+msgstr "Proporcione sus credenciales de cliente de Red Hat y podrá elegir de una lista de sus licencias disponibles. Las credenciales que utilice se almacenarán para su uso futuro en la recuperación de las licencias de renovación o ampliadas. Puede actualizarlas o eliminarlas en CONFIGURACIÓN > SISTEMA."
#: client/src/templates/job_templates/job-template.form.js:374
#: client/src/templates/job_templates/job-template.form.js:382
diff --git a/awx/ui/po/fr.po b/awx/ui/po/fr.po
index 59ed681256..513c1718aa 100644
--- a/awx/ui/po/fr.po
+++ b/awx/ui/po/fr.po
@@ -5185,8 +5185,8 @@ msgid "Provide the named URL encoded name or id of the remote Tower inventory to
msgstr "Fournir le nom encodé de l'URL ou d'id de l'inventaire distant de Tower à importer."
#: client/src/license/license.partial.html:128
-msgid "Provide your Red Hat customer credentials and you can choose from a list of your available licenses. The credentials you use will be stored for future use in retrieving renewal or expanded licenses. You can update or remove them in SETTINGS > SYSTEM."
-msgstr "Fournissez vos informations d’identification client Red Hat et choisissez parmi une liste de licences disponibles pour vous. Les informations d'identification que vous utilisez seront stockées pour une utilisation ultérieure lors de la récupération des licences renouvelées ou étendues. Vous pouvez les mettre à jour ou les supprimer dans PARAMÈTRES > SYSTÈME."
+msgid "Provide your Red Hat customer credentials and you can choose from a list of your available licenses. The credentials you use will be stored for future use in retrieving renewal or expanded licenses. You can update or remove them in SETTINGS > SYSTEM."
+msgstr "Fournissez vos informations d’identification client Red Hat et choisissez parmi une liste de licences disponibles pour vous. Les informations d'identification que vous utilisez seront stockées pour une utilisation ultérieure lors de la récupération des licences renouvelées ou étendues. Vous pouvez les mettre à jour ou les supprimer dans PARAMÈTRES > SYSTÈME."
#: client/src/templates/job_templates/job-template.form.js:374
#: client/src/templates/job_templates/job-template.form.js:382
diff --git a/awx/ui/po/ja.po b/awx/ui/po/ja.po
index 617c5c66ca..9c04b6160a 100644
--- a/awx/ui/po/ja.po
+++ b/awx/ui/po/ja.po
@@ -5102,8 +5102,8 @@ msgid "Provide environment variables to pass to the custom inventory script."
msgstr "カスタムインベントリースクリプトに渡す環境変数を指定します。"
#: client/src/license/license.partial.html:128
-msgid "Provide your Red Hat customer credentials and you can choose from a list of your available licenses. The credentials you use will be stored for future use in retrieving renewal or expanded licenses. You can update or remove them in SETTINGS > SYSTEM."
-msgstr "Red Hat の顧客認証情報を指定して、利用可能なライセンス一覧から選択してください。使用した認証情報は、今後、ライセンスの更新や延長情報を取得する時に利用できるように保存されます。設定 > システムでこの情報は更新または削除できます。"
+msgid "Provide your Red Hat customer credentials and you can choose from a list of your available licenses. The credentials you use will be stored for future use in retrieving renewal or expanded licenses. You can update or remove them in SETTINGS > SYSTEM."
+msgstr "Red Hat の顧客認証情報を指定して、利用可能なライセンス一覧から選択してください。使用した認証情報は、今後、ライセンスの更新や延長情報を取得する時に利用できるように保存されます。設定 > システムでこの情報は更新または削除できます。"
#: client/src/templates/job_templates/job-template.form.js:374
#: client/src/templates/job_templates/job-template.form.js:382
diff --git a/awx/ui/po/nl.po b/awx/ui/po/nl.po
index 721a28368c..c311590856 100644
--- a/awx/ui/po/nl.po
+++ b/awx/ui/po/nl.po
@@ -5183,8 +5183,8 @@ msgid "Provide the named URL encoded name or id of the remote Tower inventory to
msgstr "Voer de URL, versleutelde naam of ID of de externe inventaris in die geïmporteerd moet worden."
#: client/src/license/license.partial.html:128
-msgid "Provide your Red Hat customer credentials and you can choose from a list of your available licenses. The credentials you use will be stored for future use in retrieving renewal or expanded licenses. You can update or remove them in SETTINGS > SYSTEM."
-msgstr "Geef uw Red Hat-klantengegevens door en u kunt kiezen uit een lijst met beschikbare licenties. De toegangsgegevens die u gebruikt, worden opgeslagen voor toekomstig gebruik bij het ophalen van verlengingen of uitbreidingen van licenties. U kunt deze updaten of verwijderen in INSTELLINGEN > SYSTEEM."
+msgid "Provide your Red Hat customer credentials and you can choose from a list of your available licenses. The credentials you use will be stored for future use in retrieving renewal or expanded licenses. You can update or remove them in SETTINGS > SYSTEM."
+msgstr "Geef uw Red Hat-klantengegevens door en u kunt kiezen uit een lijst met beschikbare licenties. De toegangsgegevens die u gebruikt, worden opgeslagen voor toekomstig gebruik bij het ophalen van verlengingen of uitbreidingen van licenties. U kunt deze updaten of verwijderen in INSTELLINGEN > SYSTEEM."
#: client/src/templates/job_templates/job-template.form.js:374
#: client/src/templates/job_templates/job-template.form.js:382
diff --git a/awx/ui/po/zh.po b/awx/ui/po/zh.po
index 92348c9c6e..957b5132f1 100644
--- a/awx/ui/po/zh.po
+++ b/awx/ui/po/zh.po
@@ -5183,8 +5183,8 @@ msgid "Provide the named URL encoded name or id of the remote Tower inventory to
msgstr "提供要导入的远程 Tower 清单的命名 URL 编码名称或 ID。"
#: client/src/license/license.partial.html:128
-msgid "Provide your Red Hat customer credentials and you can choose from a list of your available licenses. The credentials you use will be stored for future use in retrieving renewal or expanded licenses. You can update or remove them in SETTINGS > SYSTEM."
-msgstr "提供您的红帽客户凭证,您可以从可用许可证列表中进行选择。您使用的凭证将存储以供将来用于检索续订或扩展许可证。您可以在“设置”>“系统”中更新或删除它们。"
+msgid "Provide your Red Hat customer credentials and you can choose from a list of your available licenses. The credentials you use will be stored for future use in retrieving renewal or expanded licenses. You can update or remove them in SETTINGS > SYSTEM."
+msgstr "提供您的红帽客户凭证,您可以从可用许可证列表中进行选择。您使用的凭证将存储以供将来用于检索续订或扩展许可证。您可以在“设置”>“系统”中更新或删除它们。"
#: client/src/templates/job_templates/job-template.form.js:374
#: client/src/templates/job_templates/job-template.form.js:382
diff --git a/awxkit/awxkit/cli/custom.py b/awxkit/awxkit/cli/custom.py
index fb45043632..38d97d8895 100644
--- a/awxkit/awxkit/cli/custom.py
+++ b/awxkit/awxkit/cli/custom.py
@@ -246,6 +246,7 @@ class AssociationMixin(object):
'success_notification': 'notification_templates',
'failure_notification': 'notification_templates',
'credential': 'credentials',
+ 'galaxy_credential': 'credentials',
}[resource]
def get(self, **kwargs):
@@ -367,9 +368,11 @@ class OrganizationNotificationDisAssociation(NotificationAssociateMixin, CustomA
OrganizationNotificationAssociation.targets.update({
'approval_notification': ['notification_templates_approvals', 'notification_template'],
+ 'galaxy_credential': ['galaxy_credentials', 'credential'],
})
OrganizationNotificationDisAssociation.targets.update({
'approval_notification': ['notification_templates_approvals', 'notification_template'],
+ 'galaxy_credential': ['galaxy_credentials', 'credential'],
})
diff --git a/docs/debugging.md b/docs/debugging.md
index 62a59d5317..1452c3c4bb 100644
--- a/docs/debugging.md
+++ b/docs/debugging.md
@@ -98,3 +98,29 @@ sdb-listen
This will open a Python process that listens for new debugger sessions and
automatically connects to them for you.
+
+Graph Jobs
+----------
+The `awx-manage graph_jobs` can be used to visualize how Jobs progress from
+pending to waiting to running.
+
+```
+awx-manage graph_jobs --help
+usage: awx-manage graph_jobs [-h] [--refresh REFRESH] [--width WIDTH]
+ [--height HEIGHT] [--version] [-v {0,1,2,3}]
+ [--settings SETTINGS] [--pythonpath PYTHONPATH]
+ [--traceback] [--no-color] [--force-color]
+
+Plot pending, waiting, running jobs over time on the terminal
+
+optional arguments:
+ -h, --help show this help message and exit
+ --refresh REFRESH Time between refreshes of the graph and data in
+ seconds (defaults to 1.0)
+ --width WIDTH Width of the graph (defaults to 100)
+ --height HEIGHT Height of the graph (defaults to 30)
+```
+
+Below is an example run with 200 Jobs flowing through the system.
+
+[](https://asciinema.org/a/xnfzMQ30xWPdhwORiISz0wcEw)
diff --git a/docs/licenses/asciichartpy.txt b/docs/licenses/asciichartpy.txt
new file mode 100644
index 0000000000..808639aa5b
--- /dev/null
+++ b/docs/licenses/asciichartpy.txt
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright © 2016 Igor Kroitor
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/requirements/requirements.in b/requirements/requirements.in
index 7848e5833b..8b8de10272 100644
--- a/requirements/requirements.in
+++ b/requirements/requirements.in
@@ -1,6 +1,7 @@
aiohttp
ansible-runner>=1.4.6
ansiconv==1.0.0 # UPGRADE BLOCKER: from 2013, consider replacing instead of upgrading
+asciichartpy
azure-keyvault==1.1.0 # see UPGRADE BLOCKERs
channels
channels-redis>=3.1.0 # https://github.com/django/channels_redis/issues/212
diff --git a/requirements/requirements.txt b/requirements/requirements.txt
index c1c4c49d14..dac5c5267d 100644
--- a/requirements/requirements.txt
+++ b/requirements/requirements.txt
@@ -3,6 +3,7 @@ aiohttp==3.6.2 # via -r /awx_devel/requirements/requirements.in
aioredis==1.3.1 # via channels-redis
ansible-runner==1.4.6 # via -r /awx_devel/requirements/requirements.in
ansiconv==1.0.0 # via -r /awx_devel/requirements/requirements.in
+asciichartpy==1.5.25 # via -r /awx_devel/requirements/requirements.in
asgiref==3.2.5 # via channels, channels-redis, daphne
async-timeout==3.0.1 # via aiohttp, aioredis
attrs==19.3.0 # via aiohttp, automat, jsonschema, service-identity, twisted
@@ -130,4 +131,4 @@ zope.interface==5.0.0 # via twisted
# The following packages are considered to be unsafe in a requirements file:
pip==19.3.1 # via -r /awx_devel/requirements/requirements.in
-setuptools==41.6.0 # via -r /awx_devel/requirements/requirements.in, google-auth, jsonschema, kubernetes, markdown, python-daemon, zope.interface
+setuptools==41.6.0 # via -r /awx_devel/requirements/requirements.in, asciichartpy, google-auth, jsonschema, kubernetes, markdown, python-daemon, zope.interface