From c7a85d9738a1e7ddd52a65968766800ed8c34d12 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Wed, 26 Jul 2017 10:58:46 -0400 Subject: [PATCH 1/8] Mass rename from ansible_(awx|tower) -> (awx|tower) --- awx/__init__.py | 2 +- awx/api/filters.py | 2 +- awx/api/metadata.py | 2 +- awx/api/templates/api/api_root_view.md | 2 +- awx/api/templates/api/api_v2_root_view.md | 2 +- awx/main/isolated/run.py | 6 ++-- awx/main/models/base.py | 2 +- awx/main/models/ha.py | 6 ++-- awx/main/models/notifications.py | 10 +++--- awx/main/notifications/base.py | 2 +- awx/main/tasks.py | 36 +++++++++---------- awx/main/tests/job_base.py | 4 +-- awx/main/tests/unit/test_tasks.py | 12 +++---- awx/main/utils/__init__.py | 2 +- awx/main/utils/common.py | 6 ++-- awx/main/utils/handlers.py | 6 ++-- awx/main/utils/mem_inventory.py | 2 +- awx/main/utils/reload.py | 2 +- awx/sso/views.py | 2 +- awx/templates/error.html | 2 +- awx/templates/rest_framework/api.html | 2 +- awx/templates/rest_framework/base.html | 2 +- setup.py | 6 ++-- tools/docker-compose/Dockerfile | 4 +-- tools/docker-compose/awx-manage | 6 ++-- .../PKG-INFO | 8 ++--- .../SOURCES.txt | 0 .../dependency_links.txt | 0 .../entry_points.txt | 0 .../not-zip-safe | 0 .../top_level.txt | 0 .../{ansible-awx.egg-link => awx.egg-link} | 0 tools/docker-compose/start_development.sh | 6 ++-- tools/docker-isolated/awx-expect | 2 +- tools/scripts/awx-expect | 2 +- 35 files changed, 74 insertions(+), 74 deletions(-) rename tools/docker-compose/{ansible_awx.egg-info => awx.egg-info}/PKG-INFO (76%) rename tools/docker-compose/{ansible_awx.egg-info => awx.egg-info}/SOURCES.txt (100%) rename tools/docker-compose/{ansible_awx.egg-info => awx.egg-info}/dependency_links.txt (100%) rename tools/docker-compose/{ansible_awx.egg-info => awx.egg-info}/entry_points.txt (100%) rename tools/docker-compose/{ansible_awx.egg-info => awx.egg-info}/not-zip-safe (100%) rename tools/docker-compose/{ansible_awx.egg-info => awx.egg-info}/top_level.txt (100%) rename tools/docker-compose/{ansible-awx.egg-link => awx.egg-link} (100%) diff --git a/awx/__init__.py b/awx/__init__.py index 39111823c6..b35364ce35 100644 --- a/awx/__init__.py +++ b/awx/__init__.py @@ -7,7 +7,7 @@ import warnings from pkg_resources import get_distribution -__version__ = get_distribution('ansible-awx').version +__version__ = get_distribution('awx').version __all__ = ['__version__'] diff --git a/awx/api/filters.py b/awx/api/filters.py index afce3dfe57..a231c8af8d 100644 --- a/awx/api/filters.py +++ b/awx/api/filters.py @@ -20,7 +20,7 @@ from django.utils.translation import ugettext_lazy as _ from rest_framework.exceptions import ParseError, PermissionDenied from rest_framework.filters import BaseFilterBackend -# Ansible Tower +# AWX from awx.main.utils import get_type_for_model, to_python_boolean from awx.main.models.credential import CredentialType from awx.main.models.rbac import RoleAncestorEntry diff --git a/awx/api/metadata.py b/awx/api/metadata.py index b0879f5b41..87aec4b69f 100644 --- a/awx/api/metadata.py +++ b/awx/api/metadata.py @@ -16,7 +16,7 @@ from rest_framework import serializers from rest_framework.relations import RelatedField, ManyRelatedField from rest_framework.request import clone_request -# Ansible Tower +# AWX from awx.main.models import InventorySource, NotificationTemplate diff --git a/awx/api/templates/api/api_root_view.md b/awx/api/templates/api/api_root_view.md index 1d487dc9fe..fdef862d17 100644 --- a/awx/api/templates/api/api_root_view.md +++ b/awx/api/templates/api/api_root_view.md @@ -1,4 +1,4 @@ -The root of the Ansible Tower REST API. +The root of the REST API. Make a GET request to this resource to obtain information about the available API versions. diff --git a/awx/api/templates/api/api_v2_root_view.md b/awx/api/templates/api/api_v2_root_view.md index 837d90c1b4..b35e523a51 100644 --- a/awx/api/templates/api/api_v2_root_view.md +++ b/awx/api/templates/api/api_v2_root_view.md @@ -1,4 +1,4 @@ -Version 2 of the Ansible Tower REST API. +Version 2 of the REST API. Make a GET request to this resource to obtain a list of all child resources available via the API. diff --git a/awx/main/isolated/run.py b/awx/main/isolated/run.py index db14be820d..432a9b1c11 100755 --- a/awx/main/isolated/run.py +++ b/awx/main/isolated/run.py @@ -180,10 +180,10 @@ def run_isolated_job(private_data_dir, secrets, logfile=sys.stdout): pexpect_timeout = secrets.get('pexpect_timeout', 5) # Use local callback directory - callback_dir = os.getenv('TOWER_LIB_DIRECTORY') + callback_dir = os.getenv('AWX_LIB_DIRECTORY') if callback_dir is None: - raise RuntimeError('Location for Tower Ansible callbacks must be specified ' - 'by environment variable TOWER_LIB_DIRECTORY.') + raise RuntimeError('Location for callbacks must be specified ' + 'by environment variable AWX_LIB_DIRECTORY.') env['ANSIBLE_CALLBACK_PLUGINS'] = os.path.join(callback_dir, 'isolated_callbacks') if 'AD_HOC_COMMAND_ID' in env: env['ANSIBLE_STDOUT_CALLBACK'] = 'minimal' diff --git a/awx/main/models/base.py b/awx/main/models/base.py index 8ba549a2e5..ff0a9797fd 100644 --- a/awx/main/models/base.py +++ b/awx/main/models/base.py @@ -20,7 +20,7 @@ from taggit.managers import TaggableManager # Django-CRUM from crum import get_current_user -# Ansible Tower +# AWX from awx.main.utils import encrypt_field __all__ = ['prevent_search', 'VarsDictProperty', 'BaseModel', 'CreatedModifiedModel', diff --git a/awx/main/models/ha.py b/awx/main/models/ha.py index 600a72af27..2790f89ca6 100644 --- a/awx/main/models/ha.py +++ b/awx/main/models/ha.py @@ -19,7 +19,7 @@ __all__ = ('Instance', 'InstanceGroup', 'JobOrigin', 'TowerScheduleState',) class Instance(models.Model): - """A model representing an Ansible Tower instance running against this database.""" + """A model representing an AWX instance running against this database.""" objects = InstanceManager() uuid = models.CharField(max_length=40) @@ -51,11 +51,11 @@ class Instance(models.Model): @property def role(self): # NOTE: TODO: Likely to repurpose this once standalone ramparts are a thing - return "tower" + return "awx" class InstanceGroup(models.Model): - """A model representing a Queue/Group of Tower Instances.""" + """A model representing a Queue/Group of AWX Instances.""" name = models.CharField(max_length=250, unique=True) created = models.DateTimeField(auto_now_add=True) modified = models.DateTimeField(auto_now=True) diff --git a/awx/main/models/notifications.py b/awx/main/models/notifications.py index f98bcd99b1..3d81f36906 100644 --- a/awx/main/models/notifications.py +++ b/awx/main/models/notifications.py @@ -194,11 +194,11 @@ class JobNotificationMixin(object): def _build_notification_message(self, status_str): notification_body = self.notification_data() - notification_subject = u"{} #{} '{}' {} on Ansible Tower: {}".format(self.get_notification_friendly_name(), - self.id, - self.name, - status_str, - notification_body['url']) + notification_subject = u"{} #{} '{}' {}: {}".format(self.get_notification_friendly_name(), + self.id, + self.name, + status_str, + notification_body['url']) notification_body['friendly_name'] = self.get_notification_friendly_name() return (notification_subject, notification_body) diff --git a/awx/main/notifications/base.py b/awx/main/notifications/base.py index 58202f6612..7d6ed13910 100644 --- a/awx/main/notifications/base.py +++ b/awx/main/notifications/base.py @@ -14,7 +14,7 @@ class TowerBaseEmailBackend(BaseEmailBackend): if "body" in body: body_actual = body['body'] else: - body_actual = smart_text(_("{} #{} had status {} on Ansible Tower, view details at {}\n\n").format( + body_actual = smart_text(_("{} #{} had status {}, view details at {}\n\n").format( body['friendly_name'], body['id'], body['status'], body['url']) ) body_actual += json.dumps(body, indent=4) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 11e7b9efd0..31237a6f54 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -43,8 +43,8 @@ from django.core.cache import cache from django.core.exceptions import ObjectDoesNotExist # AWX -from awx import __version__ as tower_application_version -from awx.main.constants import CLOUD_PROVIDERS, PRIVILEGE_ESCALATION_METHODS +from awx import __version__ as awx_application_version +from awx.main.constants import CLOUD_PROVIDERS from awx.main.models import * # noqa from awx.main.models.unified_jobs import ACTIVE_STATES from awx.main.queue import CallbackQueueDispatcher @@ -188,7 +188,7 @@ def cluster_node_heartbeat(self): if inst.exists(): inst = inst[0] inst.capacity = get_system_task_capacity() - inst.version = tower_application_version + inst.version = awx_application_version inst.save() else: raise RuntimeError("Cluster Host Not Found: {}".format(settings.CLUSTER_HOST_ID)) @@ -197,7 +197,7 @@ def cluster_node_heartbeat(self): for other_inst in recent_inst: if other_inst.version == "": continue - if Version(other_inst.version.split('-', 1)[0]) > Version(tower_application_version) and not settings.DEBUG: + if Version(other_inst.version.split('-', 1)[0]) > Version(awx_application_version) and not settings.DEBUG: logger.error("Host {} reports version {}, but this node {} is at {}, shutting down".format(other_inst.hostname, other_inst.version, inst.hostname, @@ -478,7 +478,7 @@ class BaseTask(LogErrorsTask): ''' Create a temporary directory for job-related files. ''' - path = tempfile.mkdtemp(prefix='ansible_awx_%s_' % instance.pk, dir=settings.AWX_PROOT_BASE_PATH) + path = tempfile.mkdtemp(prefix='awx_%s_' % instance.pk, dir=settings.AWX_PROOT_BASE_PATH) os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) self.cleanup_paths.append(path) return path @@ -541,7 +541,7 @@ class BaseTask(LogErrorsTask): '': '', } - def add_ansible_venv(self, env, add_tower_lib=True): + def add_ansible_venv(self, env, add_awx_lib=True): env['VIRTUAL_ENV'] = settings.ANSIBLE_VENV_PATH env['PATH'] = os.path.join(settings.ANSIBLE_VENV_PATH, "bin") + ":" + env['PATH'] venv_libdir = os.path.join(settings.ANSIBLE_VENV_PATH, "lib") @@ -551,11 +551,11 @@ class BaseTask(LogErrorsTask): env['PYTHONPATH'] = os.path.join(venv_libdir, python_ver, "site-packages") + ":" break # Add awx/lib to PYTHONPATH. - if add_tower_lib: + if add_awx_lib: env['PYTHONPATH'] = env.get('PYTHONPATH', '') + self.get_path_to('..', 'lib') + ':' return env - def add_tower_venv(self, env): + def add_awx_venv(self, env): env['VIRTUAL_ENV'] = settings.AWX_VENV_PATH env['PATH'] = os.path.join(settings.AWX_VENV_PATH, "bin") + ":" + env['PATH'] return env @@ -576,7 +576,7 @@ class BaseTask(LogErrorsTask): # callbacks to work. # Update PYTHONPATH to use local site-packages. # NOTE: - # Derived class should call add_ansible_venv() or add_tower_venv() + # Derived class should call add_ansible_venv() or add_awx_venv() if self.should_use_proot(instance, **kwargs): env['PROOT_TMP_DIR'] = settings.AWX_PROOT_BASE_PATH return env @@ -612,7 +612,7 @@ class BaseTask(LogErrorsTask): # For isolated jobs, we have to interact w/ the REST API from the # controlling node and ship the static JSON inventory to the # isolated host (because the isolated host itself can't reach the - # Tower REST API to fetch the inventory). + # REST API to fetch the inventory). path = os.path.join(kwargs['private_data_dir'], 'inventory') if os.path.exists(path): return path @@ -932,7 +932,7 @@ class RunJob(BaseTask): plugin_dirs.extend(settings.AWX_ANSIBLE_CALLBACK_PLUGINS) plugin_path = ':'.join(plugin_dirs) env = super(RunJob, self).build_env(job, **kwargs) - env = self.add_ansible_venv(env, add_tower_lib=kwargs.get('isolated', False)) + env = self.add_ansible_venv(env, add_awx_lib=kwargs.get('isolated', False)) # Set environment variables needed for inventory and job event # callbacks to work. env['JOB_ID'] = str(job.pk) @@ -1073,7 +1073,7 @@ class RunJob(BaseTask): if job.start_at_task: args.append('--start-at-task=%s' % job.start_at_task) - # Define special extra_vars for Tower, combine with job.extra_vars. + # Define special extra_vars for AWX, combine with job.extra_vars. extra_vars = { 'tower_job_id': job.pk, 'tower_job_launch_type': job.launch_type, @@ -1738,7 +1738,7 @@ class RunInventoryUpdate(BaseTask): """ env = super(RunInventoryUpdate, self).build_env(inventory_update, **kwargs) - env = self.add_tower_venv(env) + env = self.add_awx_venv(env) # Pass inventory source ID to inventory script. env['INVENTORY_SOURCE_ID'] = str(inventory_update.inventory_source_id) env['INVENTORY_UPDATE_ID'] = str(inventory_update.pk) @@ -1748,7 +1748,7 @@ class RunInventoryUpdate(BaseTask): # These are set here and then read in by the various Ansible inventory # modules, which will actually do the inventory sync. # - # The inventory modules are vendored in Tower in the + # The inventory modules are vendored in AWX in the # `awx/plugins/inventory` directory; those files should be kept in # sync with those in Ansible core at all times. passwords = kwargs.get('passwords', {}) @@ -1820,9 +1820,9 @@ class RunInventoryUpdate(BaseTask): src = inventory_update.source # Add several options to the shell arguments based on the - # inventory-source-specific setting in the Tower configuration. + # inventory-source-specific setting in the AWX configuration. # These settings are "per-source"; it's entirely possible that - # they will be different between cloud providers if a Tower user + # they will be different between cloud providers if an AWX user # actively uses more than one. if getattr(settings, '%s_ENABLED_VAR' % src.upper(), False): args.extend(['--enabled-var', @@ -1852,7 +1852,7 @@ class RunInventoryUpdate(BaseTask): elif src == 'scm': args.append(inventory_update.get_actual_source_path()) elif src == 'custom': - runpath = tempfile.mkdtemp(prefix='ansible_awx_inventory_', dir=settings.AWX_PROOT_BASE_PATH) + runpath = tempfile.mkdtemp(prefix='awx_inventory_', dir=settings.AWX_PROOT_BASE_PATH) handle, path = tempfile.mkstemp(dir=runpath) f = os.fdopen(handle, 'w') if inventory_update.source_script is None: @@ -2139,7 +2139,7 @@ class RunSystemJob(BaseTask): def build_env(self, instance, **kwargs): env = super(RunSystemJob, self).build_env(instance, **kwargs) - env = self.add_tower_venv(env) + env = self.add_awx_venv(env) return env def build_cwd(self, instance, **kwargs): diff --git a/awx/main/tests/job_base.py b/awx/main/tests/job_base.py index 1f195c831d..0d36624a79 100644 --- a/awx/main/tests/job_base.py +++ b/awx/main/tests/job_base.py @@ -37,10 +37,10 @@ class BaseJobTestMixin(BaseTestMixin): return inventory def populate(self): - # Here's a little story about the Ansible Bread Company, or ABC. They + # Here's a little story about the AWX Bread Company, or ABC. They # make machines that make bread - bakers, slicers, and packagers - and # these machines are each controlled by a Linux boxes, which is in turn - # managed by Ansible Commander. + # managed by AWX. # Sue is the super user. You don't mess with Sue or you're toast. Ha. self.user_sue = self.make_user('sue', super_user=True) diff --git a/awx/main/tests/unit/test_tasks.py b/awx/main/tests/unit/test_tasks.py index 234f2c4b73..8aae8dc27b 100644 --- a/awx/main/tests/unit/test_tasks.py +++ b/awx/main/tests/unit/test_tasks.py @@ -181,7 +181,7 @@ class TestJobExecution: EXAMPLE_PRIVATE_KEY = '-----BEGIN PRIVATE KEY-----\nxyz==\n-----END PRIVATE KEY-----' def setup_method(self, method): - self.project_path = tempfile.mkdtemp(prefix='ansible_awx_project_') + self.project_path = tempfile.mkdtemp(prefix='awx_project_') with open(os.path.join(self.project_path, 'helloworld.yml'), 'w') as f: f.write('---') @@ -312,7 +312,7 @@ class TestIsolatedExecution(TestJobExecution): credential.inputs['password'] = encrypt_field(credential, 'password') self.instance.credential = credential - private_data = tempfile.mkdtemp(prefix='ansible_awx_') + private_data = tempfile.mkdtemp(prefix='awx_') self.task.build_private_data_dir = mock.Mock(return_value=private_data) inventory = json.dumps({"all": {"hosts": ["localhost"]}}) @@ -351,7 +351,7 @@ class TestIsolatedExecution(TestJobExecution): extra_vars = json.loads(extra_vars) assert extra_vars['dest'] == '/tmp' assert extra_vars['src'] == private_data - assert extra_vars['proot_temp_dir'].startswith('/tmp/ansible_awx_proot_') + assert extra_vars['proot_temp_dir'].startswith('/tmp/awx_proot_') def test_systemctl_failure(self): # If systemctl fails, read the contents of `artifacts/systemctl_logs` @@ -364,7 +364,7 @@ class TestIsolatedExecution(TestJobExecution): ) self.instance.credential = credential - private_data = tempfile.mkdtemp(prefix='ansible_awx_') + private_data = tempfile.mkdtemp(prefix='awx_') self.task.build_private_data_dir = mock.Mock(return_value=private_data) inventory = json.dumps({"all": {"hosts": ["localhost"]}}) @@ -464,7 +464,7 @@ class TestJobCredentials(TestJobExecution): ) return ['successful', 0] - private_data = tempfile.mkdtemp(prefix='ansible_awx_') + private_data = tempfile.mkdtemp(prefix='awx_') self.task.build_private_data_dir = mock.Mock(return_value=private_data) self.run_pexpect.side_effect = partial(run_pexpect_side_effect, private_data) self.task.run(self.pk, private_data_dir=private_data) @@ -1145,7 +1145,7 @@ class TestProjectUpdateCredentials(TestJobExecution): assert 'bob' in kwargs.get('expect_passwords').values() return ['successful', 0] - private_data = tempfile.mkdtemp(prefix='ansible_awx_') + private_data = tempfile.mkdtemp(prefix='awx_') self.task.build_private_data_dir = mock.Mock(return_value=private_data) self.run_pexpect.side_effect = partial(run_pexpect_side_effect, private_data) self.task.run(self.pk) diff --git a/awx/main/utils/__init__.py b/awx/main/utils/__init__.py index fb20b92898..11a34c487c 100644 --- a/awx/main/utils/__init__.py +++ b/awx/main/utils/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Ansible Tower by Red Hat +# Copyright (c) 2017 Ansible by Red Hat # All Rights Reserved. # AWX diff --git a/awx/main/utils/common.py b/awx/main/utils/common.py index 80a72c9cb2..43c9340085 100644 --- a/awx/main/utils/common.py +++ b/awx/main/utils/common.py @@ -152,12 +152,12 @@ def get_ssh_version(): def get_awx_version(): ''' - Return Ansible Tower version as reported by setuptools. + Return AWX version as reported by setuptools. ''' from awx import __version__ try: import pkg_resources - return pkg_resources.require('ansible-awx')[0].version + return pkg_resources.require('awx')[0].version except: return __version__ @@ -655,7 +655,7 @@ def build_proot_temp_dir(): Create a temporary directory for proot to use. ''' from django.conf import settings - path = tempfile.mkdtemp(prefix='ansible_awx_proot_', dir=settings.AWX_PROOT_BASE_PATH) + path = tempfile.mkdtemp(prefix='awx_proot_', dir=settings.AWX_PROOT_BASE_PATH) os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) return path diff --git a/awx/main/utils/handlers.py b/awx/main/utils/handlers.py index 7f5c919e16..4c88681f4b 100644 --- a/awx/main/utils/handlers.py +++ b/awx/main/utils/handlers.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Ansible Tower by Red Hat +# Copyright (c) 2017 Ansible by Red Hat # All Rights Reserved. # Python @@ -134,7 +134,7 @@ class BaseHandler(logging.Handler): # Don't send handler-related records. if logger_name == logger.name: return True - # Tower log emission is only turned off by enablement setting + # AWX log emission is only turned off by enablement setting if not logger_name.startswith('awx.analytics'): return False return self.enabled_loggers is None or logger_name[len('awx.analytics.'):] not in self.enabled_loggers @@ -216,7 +216,7 @@ class BaseHTTPSHandler(BaseHandler): logger = logging.getLogger(__file__) fn, lno, func = logger.findCaller() record = logger.makeRecord('awx', 10, fn, lno, - 'Ansible Tower Connection Test', tuple(), + 'AWX Connection Test', tuple(), None, func) futures = handler.emit(record) for future in futures: diff --git a/awx/main/utils/mem_inventory.py b/awx/main/utils/mem_inventory.py index b7530fd358..b2d1c0d691 100644 --- a/awx/main/utils/mem_inventory.py +++ b/awx/main/utils/mem_inventory.py @@ -95,7 +95,7 @@ class MemHost(MemObject): self.instance_id = None self.name = name if port: - # was `ansible_ssh_port` in older Ansible/Tower versions + # was `ansible_ssh_port` in older Ansible versions self.variables['ansible_port'] = port logger.debug('Loaded host: %s', self.name) diff --git a/awx/main/utils/reload.py b/awx/main/utils/reload.py index 25a4d17a57..143a5d01cf 100644 --- a/awx/main/utils/reload.py +++ b/awx/main/utils/reload.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Ansible Tower by Red Hat +# Copyright (c) 2017 Ansible by Red Hat # All Rights Reserved. # Python diff --git a/awx/sso/views.py b/awx/sso/views.py index 80092a8040..9e680186a9 100644 --- a/awx/sso/views.py +++ b/awx/sso/views.py @@ -16,7 +16,7 @@ from django.utils.encoding import smart_text # Django REST Framework from rest_framework.renderers import JSONRenderer -# Ansible Tower +# AWX from awx.main.models import AuthToken from awx.api.serializers import UserSerializer diff --git a/awx/templates/error.html b/awx/templates/error.html index 563befa8a6..69fade819e 100644 --- a/awx/templates/error.html +++ b/awx/templates/error.html @@ -1,7 +1,7 @@ {% extends "rest_framework/api.html" %} {% load i18n staticfiles %} -{% block title %}{{ name }} · {% trans 'Ansible Tower' %}{% endblock %} +{% block title %}{{ name }} · {% trans 'AWX' %}{% endblock %} {% block style %} {{ block.super }} diff --git a/awx/templates/rest_framework/api.html b/awx/templates/rest_framework/api.html index 863b0e22af..0bcc14eaf7 100644 --- a/awx/templates/rest_framework/api.html +++ b/awx/templates/rest_framework/api.html @@ -1,7 +1,7 @@ {% extends 'rest_framework/base.html' %} {% load i18n staticfiles %} -{% block title %}{{ name }} · {% trans 'Ansible Tower REST API' %}{% endblock %} +{% block title %}{{ name }} · {% trans 'AWX REST API' %}{% endblock %} {% block bootstrap_theme %} diff --git a/awx/templates/rest_framework/base.html b/awx/templates/rest_framework/base.html index a6c4169ebd..7ae5cb8c1a 100644 --- a/awx/templates/rest_framework/base.html +++ b/awx/templates/rest_framework/base.html @@ -1,5 +1,5 @@ -{# Copy of base.html from rest_framework with minor Ansible Tower change. #} +{# Copy of base.html from rest_framework with minor AWX change. #} {% load staticfiles %} {% load rest_framework %} {% load i18n %} diff --git a/setup.py b/setup.py index 349910d927..39a145b13c 100755 --- a/setup.py +++ b/setup.py @@ -123,12 +123,12 @@ def proc_data_files(data_files): setup( - name=os.getenv('NAME', 'ansible-awx'), + name=os.getenv('NAME', 'awx'), version=get_version(), author='Ansible, Inc.', author_email='info@ansible.com', - description='ansible-awx: API, UI and Task Engine for Ansible', - long_description='Ansible AWX provides a web-based user interface, REST API and ' + description='awx: API, UI and Task Engine for Ansible', + long_description='AWX provides a web-based user interface, REST API and ' 'task engine built on top of Ansible', license='MIT', keywords='ansible', diff --git a/tools/docker-compose/Dockerfile b/tools/docker-compose/Dockerfile index b9e5298901..0a648c3d5b 100644 --- a/tools/docker-compose/Dockerfile +++ b/tools/docker-compose/Dockerfile @@ -20,9 +20,9 @@ RUN /usr/bin/ssh-keygen -q -t rsa -N "" -f /root/.ssh/id_rsa RUN mkdir -p /data/db RUN pip2 install honcho RUN pip2 install supervisor -ADD tools/docker-compose/ansible-awx.egg-link /tmp/ansible-awx.egg-link +ADD tools/docker-compose/awx.egg-link /tmp/awx.egg-link ADD tools/docker-compose/awx-manage /usr/local/bin/awx-manage -ADD tools/docker-compose/ansible_awx.egg-info /tmp/ansible_awx.egg-info +ADD tools/docker-compose/awx.egg-info /tmp/awx.egg-info RUN ln -Ffs /awx_devel/tools/docker-compose/nginx.conf /etc/nginx/nginx.conf RUN ln -Ffs /awx_devel/tools/docker-compose/nginx.vh.default.conf /etc/nginx/conf.d/nginx.vh.default.conf RUN ln -s /awx_devel/tools/docker-compose/start_development.sh /start_development.sh diff --git a/tools/docker-compose/awx-manage b/tools/docker-compose/awx-manage index b0a62494c1..65d10accf7 100755 --- a/tools/docker-compose/awx-manage +++ b/tools/docker-compose/awx-manage @@ -1,10 +1,10 @@ #!/venv/awx/bin/python -# EASY-INSTALL-ENTRY-SCRIPT: 'ansible-awx','console_scripts','awx-manage' -__requires__ = 'ansible-awx' +# EASY-INSTALL-ENTRY-SCRIPT: 'awx','console_scripts','awx-manage' import sys from pkg_resources import load_entry_point +__requires__ = 'awx' if __name__ == '__main__': sys.exit( - load_entry_point('ansible-awx', 'console_scripts', 'awx-manage')() + load_entry_point('awx', 'console_scripts', 'awx-manage')() ) diff --git a/tools/docker-compose/ansible_awx.egg-info/PKG-INFO b/tools/docker-compose/awx.egg-info/PKG-INFO similarity index 76% rename from tools/docker-compose/ansible_awx.egg-info/PKG-INFO rename to tools/docker-compose/awx.egg-info/PKG-INFO index eb633cdebb..d02ec5de21 100644 --- a/tools/docker-compose/ansible_awx.egg-info/PKG-INFO +++ b/tools/docker-compose/awx.egg-info/PKG-INFO @@ -1,12 +1,12 @@ Metadata-Version: 1.1 -Name: ansible-awx +Name: awx Version: placeholder -Summary: ansible-awx: API, UI and Task Engine for Ansible -Home-page: http://github.com/ansible/ansible-awx +Summary: awx: API, UI and Task Engine for Ansible +Home-page: http://github.com/ansible/awx Author: Ansible, Inc. Author-email: info@ansible.com License: Proprietary -Description: Ansible AWXprovides a web-based user interface, REST API and task engine built on top of Ansible +Description: Ansible AWX provides a web-based user interface, REST API and task engine built on top of Ansible Keywords: ansible Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable diff --git a/tools/docker-compose/ansible_awx.egg-info/SOURCES.txt b/tools/docker-compose/awx.egg-info/SOURCES.txt similarity index 100% rename from tools/docker-compose/ansible_awx.egg-info/SOURCES.txt rename to tools/docker-compose/awx.egg-info/SOURCES.txt diff --git a/tools/docker-compose/ansible_awx.egg-info/dependency_links.txt b/tools/docker-compose/awx.egg-info/dependency_links.txt similarity index 100% rename from tools/docker-compose/ansible_awx.egg-info/dependency_links.txt rename to tools/docker-compose/awx.egg-info/dependency_links.txt diff --git a/tools/docker-compose/ansible_awx.egg-info/entry_points.txt b/tools/docker-compose/awx.egg-info/entry_points.txt similarity index 100% rename from tools/docker-compose/ansible_awx.egg-info/entry_points.txt rename to tools/docker-compose/awx.egg-info/entry_points.txt diff --git a/tools/docker-compose/ansible_awx.egg-info/not-zip-safe b/tools/docker-compose/awx.egg-info/not-zip-safe similarity index 100% rename from tools/docker-compose/ansible_awx.egg-info/not-zip-safe rename to tools/docker-compose/awx.egg-info/not-zip-safe diff --git a/tools/docker-compose/ansible_awx.egg-info/top_level.txt b/tools/docker-compose/awx.egg-info/top_level.txt similarity index 100% rename from tools/docker-compose/ansible_awx.egg-info/top_level.txt rename to tools/docker-compose/awx.egg-info/top_level.txt diff --git a/tools/docker-compose/ansible-awx.egg-link b/tools/docker-compose/awx.egg-link similarity index 100% rename from tools/docker-compose/ansible-awx.egg-link rename to tools/docker-compose/awx.egg-link diff --git a/tools/docker-compose/start_development.sh b/tools/docker-compose/start_development.sh index 1892674079..9dd095aeed 100755 --- a/tools/docker-compose/start_development.sh +++ b/tools/docker-compose/start_development.sh @@ -21,9 +21,9 @@ else echo "Failed to find awx source tree, map your development tree volume" fi -cp -R /tmp/ansible_awx.egg-info /awx_devel/ || true -sed -i "s/placeholder/$(git describe --long | sed 's/\./\\./g')/" /awx_devel/ansible_awx.egg-info/PKG-INFO -cp /tmp/ansible-awx.egg-link /venv/awx/lib/python2.7/site-packages/ansible-awx.egg-link +cp -R /tmp/awx.egg-info /awx_devel/ || true +sed -i "s/placeholder/$(git describe --long | sed 's/\./\\./g')/" /awx_devel/awx.egg-info/PKG-INFO +cp /tmp/awx.egg-link /venv/awx/lib/python2.7/site-packages/awx.egg-link ln -s /awx_devel/tools/rdb.py /venv/awx/lib/python2.7/site-packages/rdb.py || true yes | cp -rf /awx_devel/tools/docker-compose/supervisor.conf /supervisor.conf diff --git a/tools/docker-isolated/awx-expect b/tools/docker-isolated/awx-expect index 0ceb7a629c..bf2efb54d2 100755 --- a/tools/docker-isolated/awx-expect +++ b/tools/docker-isolated/awx-expect @@ -1,3 +1,3 @@ #!/bin/bash . /venv/awx/bin/activate -exec env TOWER_LIB_DIRECTORY=/awx_lib /awx_devel/run.py "$@" +exec env AWX_LIB_DIRECTORY=/awx_lib /awx_devel/run.py "$@" diff --git a/tools/scripts/awx-expect b/tools/scripts/awx-expect index bd3364e666..23b85150b0 100755 --- a/tools/scripts/awx-expect +++ b/tools/scripts/awx-expect @@ -1,4 +1,4 @@ #!/bin/bash AWX_LIB=`/var/lib/awx/venv/awx/bin/python -c 'import os, awx; print os.path.dirname(awx.__file__)'` . /var/lib/awx/venv/awx/bin/activate -exec env TOWER_LIB_DIRECTORY=$AWX_LIB/lib /var/lib/awx/venv/awx/bin/python $AWX_LIB/main/isolated/run.pyc "$@" +exec env AWX_LIB_DIRECTORY=$AWX_LIB/lib /var/lib/awx/venv/awx/bin/python $AWX_LIB/main/isolated/run.pyc "$@" From d4b1a07495a746d0cd97f1a35d21255086fe5974 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Wed, 26 Jul 2017 12:06:23 -0400 Subject: [PATCH 2/8] Rename tower display plugins to awx display --- .../__init__.py | 6 +++--- .../cleanup.py | 0 .../display.py | 0 .../events.py | 0 .../minimal.py | 0 .../module.py | 8 ++++---- .../{tower_display.py => awx_display.py} | 2 +- awx/lib/isolated_callbacks/minimal.py | 2 +- awx/lib/sitecustomize.py | 4 ++-- awx/lib/tests/test_display_callback.py | 8 ++++---- awx/main/isolated/run.py | 2 +- awx/main/tasks.py | 2 +- awx/main/tests/unit/isolated/test_expect.py | 2 +- awx/plugins/callback/{tower_display.py => awx_display.py} | 2 +- awx/plugins/callback/minimal.py | 2 +- 15 files changed, 20 insertions(+), 20 deletions(-) rename awx/lib/{tower_display_callback => awx_display_callback}/__init__.py (84%) rename awx/lib/{tower_display_callback => awx_display_callback}/cleanup.py (100%) rename awx/lib/{tower_display_callback => awx_display_callback}/display.py (100%) rename awx/lib/{tower_display_callback => awx_display_callback}/events.py (100%) rename awx/lib/{tower_display_callback => awx_display_callback}/minimal.py (100%) rename awx/lib/{tower_display_callback => awx_display_callback}/module.py (98%) rename awx/lib/isolated_callbacks/{tower_display.py => awx_display.py} (92%) rename awx/plugins/callback/{tower_display.py => awx_display.py} (92%) diff --git a/awx/lib/tower_display_callback/__init__.py b/awx/lib/awx_display_callback/__init__.py similarity index 84% rename from awx/lib/tower_display_callback/__init__.py rename to awx/lib/awx_display_callback/__init__.py index d984956c7f..b7cbf97b9b 100644 --- a/awx/lib/tower_display_callback/__init__.py +++ b/awx/lib/awx_display_callback/__init__.py @@ -17,9 +17,9 @@ from __future__ import (absolute_import, division, print_function) -# Tower Display Callback +# AWX Display Callback from . import cleanup # noqa (registers control persistent cleanup) from . import display # noqa (wraps ansible.display.Display methods) -from .module import TowerDefaultCallbackModule, TowerMinimalCallbackModule +from .module import AWXDefaultCallbackModule, AWXMinimalCallbackModule -__all__ = ['TowerDefaultCallbackModule', 'TowerMinimalCallbackModule'] +__all__ = ['AWXDefaultCallbackModule', 'AWXMinimalCallbackModule'] diff --git a/awx/lib/tower_display_callback/cleanup.py b/awx/lib/awx_display_callback/cleanup.py similarity index 100% rename from awx/lib/tower_display_callback/cleanup.py rename to awx/lib/awx_display_callback/cleanup.py diff --git a/awx/lib/tower_display_callback/display.py b/awx/lib/awx_display_callback/display.py similarity index 100% rename from awx/lib/tower_display_callback/display.py rename to awx/lib/awx_display_callback/display.py diff --git a/awx/lib/tower_display_callback/events.py b/awx/lib/awx_display_callback/events.py similarity index 100% rename from awx/lib/tower_display_callback/events.py rename to awx/lib/awx_display_callback/events.py diff --git a/awx/lib/tower_display_callback/minimal.py b/awx/lib/awx_display_callback/minimal.py similarity index 100% rename from awx/lib/tower_display_callback/minimal.py rename to awx/lib/awx_display_callback/minimal.py diff --git a/awx/lib/tower_display_callback/module.py b/awx/lib/awx_display_callback/module.py similarity index 98% rename from awx/lib/tower_display_callback/module.py rename to awx/lib/awx_display_callback/module.py index 0b0b964a72..6800560cfc 100644 --- a/awx/lib/tower_display_callback/module.py +++ b/awx/lib/awx_display_callback/module.py @@ -27,7 +27,7 @@ from copy import copy from ansible.plugins.callback import CallbackBase from ansible.plugins.callback.default import CallbackModule as DefaultCallbackModule -# Tower Display Callback +# AWX Display Callback from .events import event_context from .minimal import CallbackModule as MinimalCallbackModule @@ -448,12 +448,12 @@ class BaseCallbackModule(CallbackBase): super(BaseCallbackModule, self).v2_runner_retry(result) -class TowerDefaultCallbackModule(BaseCallbackModule, DefaultCallbackModule): +class AWXDefaultCallbackModule(BaseCallbackModule, DefaultCallbackModule): - CALLBACK_NAME = 'tower_display' + CALLBACK_NAME = 'awx_display' -class TowerMinimalCallbackModule(BaseCallbackModule, MinimalCallbackModule): +class AWXMinimalCallbackModule(BaseCallbackModule, MinimalCallbackModule): CALLBACK_NAME = 'minimal' diff --git a/awx/lib/isolated_callbacks/tower_display.py b/awx/lib/isolated_callbacks/awx_display.py similarity index 92% rename from awx/lib/isolated_callbacks/tower_display.py rename to awx/lib/isolated_callbacks/awx_display.py index dbe463303d..f65e96f9af 100644 --- a/awx/lib/isolated_callbacks/tower_display.py +++ b/awx/lib/isolated_callbacks/awx_display.py @@ -27,4 +27,4 @@ if awx_lib_path not in sys.path: sys.path.insert(0, awx_lib_path) # Tower Display Callback -from tower_display_callback import TowerDefaultCallbackModule as CallbackModule # noqa +from awx_display_callback import AWXDefaultCallbackModule as CallbackModule # noqa diff --git a/awx/lib/isolated_callbacks/minimal.py b/awx/lib/isolated_callbacks/minimal.py index 6c136b7824..f54b706837 100644 --- a/awx/lib/isolated_callbacks/minimal.py +++ b/awx/lib/isolated_callbacks/minimal.py @@ -27,4 +27,4 @@ if awx_lib_path not in sys.path: sys.path.insert(0, awx_lib_path) # Tower Display Callback -from tower_display_callback import TowerMinimalCallbackModule as CallbackModule # noqa +from awx_display_callback import AWXMinimalCallbackModule as CallbackModule # noqa diff --git a/awx/lib/sitecustomize.py b/awx/lib/sitecustomize.py index 224840aae7..3df0dc9aef 100644 --- a/awx/lib/sitecustomize.py +++ b/awx/lib/sitecustomize.py @@ -2,13 +2,13 @@ import os import sys -# Based on http://stackoverflow.com/a/6879344/131141 -- Initialize tower display +# Based on http://stackoverflow.com/a/6879344/131141 -- Initialize awx display # callback as early as possible to wrap ansible.display.Display methods. def argv_ready(argv): if argv and os.path.basename(argv[0]) in {'ansible', 'ansible-playbook'}: - import tower_display_callback # noqa + import awx_display_callback # noqa class argv_placeholder(object): diff --git a/awx/lib/tests/test_display_callback.py b/awx/lib/tests/test_display_callback.py index 48960f97c7..1607544827 100644 --- a/awx/lib/tests/test_display_callback.py +++ b/awx/lib/tests/test_display_callback.py @@ -11,10 +11,10 @@ import pytest # search for a plugin implementation (which should be named `CallbackModule`) # # this code modifies the Python path to make our -# `awx.lib.tower_display_callback` callback importable (because `awx.lib` +# `awx.lib.awx_display_callback` callback importable (because `awx.lib` # itself is not a package) # -# we use the `tower_display_callback` imports below within this file, but +# we use the `awx_display_callback` imports below within this file, but # Ansible also uses them when it discovers this file in # `ANSIBLE_CALLBACK_PLUGINS` CALLBACK = os.path.splitext(os.path.basename(__file__))[0] @@ -32,8 +32,8 @@ with mock.patch.dict(os.environ, {'ANSIBLE_STDOUT_CALLBACK': CALLBACK, if path not in sys.path: sys.path.insert(0, path) - from tower_display_callback import TowerDefaultCallbackModule as CallbackModule # noqa - from tower_display_callback.events import event_context # noqa + from awx_display_callback import AWXDefaultCallbackModule as CallbackModule # noqa + from awx_display_callback.events import event_context # noqa @pytest.fixture() diff --git a/awx/main/isolated/run.py b/awx/main/isolated/run.py index 432a9b1c11..a5d524377a 100755 --- a/awx/main/isolated/run.py +++ b/awx/main/isolated/run.py @@ -188,7 +188,7 @@ def run_isolated_job(private_data_dir, secrets, logfile=sys.stdout): if 'AD_HOC_COMMAND_ID' in env: env['ANSIBLE_STDOUT_CALLBACK'] = 'minimal' else: - env['ANSIBLE_STDOUT_CALLBACK'] = 'tower_display' + env['ANSIBLE_STDOUT_CALLBACK'] = 'awx_display' env['AWX_ISOLATED_DATA_DIR'] = private_data_dir env['PYTHONPATH'] = env.get('PYTHONPATH', '') + callback_dir + ':' diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 31237a6f54..8b7b622c37 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -949,7 +949,7 @@ class RunJob(BaseTask): env['MAX_EVENT_RES'] = str(settings.MAX_EVENT_RES_DATA) if not kwargs.get('isolated'): env['ANSIBLE_CALLBACK_PLUGINS'] = plugin_path - env['ANSIBLE_STDOUT_CALLBACK'] = 'tower_display' + env['ANSIBLE_STDOUT_CALLBACK'] = 'awx_display' env['REST_API_URL'] = settings.INTERNAL_API_URL env['REST_API_TOKEN'] = job.task_auth_token or '' env['TOWER_HOST'] = settings.TOWER_URL_BASE diff --git a/awx/main/tests/unit/isolated/test_expect.py b/awx/main/tests/unit/isolated/test_expect.py index e9e36095d7..a180d3e6c2 100644 --- a/awx/main/tests/unit/isolated/test_expect.py +++ b/awx/main/tests/unit/isolated/test_expect.py @@ -193,7 +193,7 @@ def test_run_isolated_job(private_data_dir, rsa_key): assert FILENAME in stdout.getvalue() assert '/path/to/awx/lib' in env['PYTHONPATH'] - assert env['ANSIBLE_STDOUT_CALLBACK'] == 'tower_display' + assert env['ANSIBLE_STDOUT_CALLBACK'] == 'awx_display' assert env['ANSIBLE_CALLBACK_PLUGINS'] == '/path/to/awx/lib/isolated_callbacks' assert env['AWX_ISOLATED_DATA_DIR'] == private_data_dir diff --git a/awx/plugins/callback/tower_display.py b/awx/plugins/callback/awx_display.py similarity index 92% rename from awx/plugins/callback/tower_display.py rename to awx/plugins/callback/awx_display.py index 725232dfe4..326cc6c7be 100644 --- a/awx/plugins/callback/tower_display.py +++ b/awx/plugins/callback/awx_display.py @@ -27,4 +27,4 @@ if awx_lib_path not in sys.path: sys.path.insert(0, awx_lib_path) # Tower Display Callback -from tower_display_callback import TowerDefaultCallbackModule as CallbackModule # noqa +from awx_display_callback import AWXDefaultCallbackModule as CallbackModule # noqa diff --git a/awx/plugins/callback/minimal.py b/awx/plugins/callback/minimal.py index fcbaa76d55..e41f7ff62f 100644 --- a/awx/plugins/callback/minimal.py +++ b/awx/plugins/callback/minimal.py @@ -27,4 +27,4 @@ if awx_lib_path not in sys.path: sys.path.insert(0, awx_lib_path) # Tower Display Callback -from tower_display_callback import TowerMinimalCallbackModule as CallbackModule # noqa +from awx_display_callback import AWXMinimalCallbackModule as CallbackModule # noqa From cc0802c87ef7580d794de4de0317335fe399a07b Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Wed, 26 Jul 2017 12:20:23 -0400 Subject: [PATCH 3/8] Refactor fact cache plugin from tower -> awx --- awx/main/tasks.py | 2 +- awx/plugins/fact_caching/{tower.py => awx.py} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename awx/plugins/fact_caching/{tower.py => awx.py} (100%) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 8b7b622c37..c8def0fc59 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -940,7 +940,7 @@ class RunJob(BaseTask): if job.use_fact_cache and not kwargs.get('isolated'): env['ANSIBLE_LIBRARY'] = self.get_path_to('..', 'plugins', 'library') env['ANSIBLE_CACHE_PLUGINS'] = self.get_path_to('..', 'plugins', 'fact_caching') - env['ANSIBLE_CACHE_PLUGIN'] = "tower" + env['ANSIBLE_CACHE_PLUGIN'] = "awx" env['ANSIBLE_FACT_CACHE_TIMEOUT'] = str(settings.ANSIBLE_FACT_CACHE_TIMEOUT) env['ANSIBLE_CACHE_PLUGIN_CONNECTION'] = settings.CACHES['default']['LOCATION'] if 'LOCATION' in settings.CACHES['default'] else '' if job.project: diff --git a/awx/plugins/fact_caching/tower.py b/awx/plugins/fact_caching/awx.py similarity index 100% rename from awx/plugins/fact_caching/tower.py rename to awx/plugins/fact_caching/awx.py From 9fe6453b1c69bde47848e82aee8c35424f992de4 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Wed, 26 Jul 2017 12:25:36 -0400 Subject: [PATCH 4/8] Refactor Notification backend for tower -> awx --- awx/main/notifications/base.py | 2 +- awx/main/notifications/hipchat_backend.py | 4 ++-- awx/main/notifications/irc_backend.py | 4 ++-- awx/main/notifications/pagerduty_backend.py | 4 ++-- awx/main/notifications/slack_backend.py | 4 ++-- awx/main/notifications/twilio_backend.py | 4 ++-- awx/main/notifications/webhook_backend.py | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/awx/main/notifications/base.py b/awx/main/notifications/base.py index 7d6ed13910..bb5ac7a9ca 100644 --- a/awx/main/notifications/base.py +++ b/awx/main/notifications/base.py @@ -8,7 +8,7 @@ from django.core.mail.backends.base import BaseEmailBackend from django.utils.translation import ugettext_lazy as _ -class TowerBaseEmailBackend(BaseEmailBackend): +class AWXBaseEmailBackend(BaseEmailBackend): def format_body(self, body): if "body" in body: diff --git a/awx/main/notifications/hipchat_backend.py b/awx/main/notifications/hipchat_backend.py index b286439954..e75fcbc296 100644 --- a/awx/main/notifications/hipchat_backend.py +++ b/awx/main/notifications/hipchat_backend.py @@ -7,12 +7,12 @@ import requests from django.utils.encoding import smart_text from django.utils.translation import ugettext_lazy as _ -from awx.main.notifications.base import TowerBaseEmailBackend +from awx.main.notifications.base import AWXBaseEmailBackend logger = logging.getLogger('awx.main.notifications.hipchat_backend') -class HipChatBackend(TowerBaseEmailBackend): +class HipChatBackend(AWXBaseEmailBackend): init_parameters = {"token": {"label": "Token", "type": "password"}, "rooms": {"label": "Destination Rooms", "type": "list"}, diff --git a/awx/main/notifications/irc_backend.py b/awx/main/notifications/irc_backend.py index 277364cf07..2493451e77 100644 --- a/awx/main/notifications/irc_backend.py +++ b/awx/main/notifications/irc_backend.py @@ -9,12 +9,12 @@ import irc.client from django.utils.encoding import smart_text from django.utils.translation import ugettext_lazy as _ -from awx.main.notifications.base import TowerBaseEmailBackend +from awx.main.notifications.base import AWXBaseEmailBackend logger = logging.getLogger('awx.main.notifications.irc_backend') -class IrcBackend(TowerBaseEmailBackend): +class IrcBackend(AWXBaseEmailBackend): init_parameters = {"server": {"label": "IRC Server Address", "type": "string"}, "port": {"label": "IRC Server Port", "type": "int"}, diff --git a/awx/main/notifications/pagerduty_backend.py b/awx/main/notifications/pagerduty_backend.py index 76322c18cf..21eb2a9aae 100644 --- a/awx/main/notifications/pagerduty_backend.py +++ b/awx/main/notifications/pagerduty_backend.py @@ -6,12 +6,12 @@ import pygerduty from django.utils.encoding import smart_text from django.utils.translation import ugettext_lazy as _ -from awx.main.notifications.base import TowerBaseEmailBackend +from awx.main.notifications.base import AWXBaseEmailBackend logger = logging.getLogger('awx.main.notifications.pagerduty_backend') -class PagerDutyBackend(TowerBaseEmailBackend): +class PagerDutyBackend(AWXBaseEmailBackend): init_parameters = {"subdomain": {"label": "Pagerduty subdomain", "type": "string"}, "token": {"label": "API Token", "type": "password"}, diff --git a/awx/main/notifications/slack_backend.py b/awx/main/notifications/slack_backend.py index 2da5c5d8a3..3cea4bd44e 100644 --- a/awx/main/notifications/slack_backend.py +++ b/awx/main/notifications/slack_backend.py @@ -6,12 +6,12 @@ from slackclient import SlackClient from django.utils.encoding import smart_text from django.utils.translation import ugettext_lazy as _ -from awx.main.notifications.base import TowerBaseEmailBackend +from awx.main.notifications.base import AWXBaseEmailBackend logger = logging.getLogger('awx.main.notifications.slack_backend') -class SlackBackend(TowerBaseEmailBackend): +class SlackBackend(AWXBaseEmailBackend): init_parameters = {"token": {"label": "Token", "type": "password"}, "channels": {"label": "Destination Channels", "type": "list"}} diff --git a/awx/main/notifications/twilio_backend.py b/awx/main/notifications/twilio_backend.py index 8bdcc922b1..077ef7573b 100644 --- a/awx/main/notifications/twilio_backend.py +++ b/awx/main/notifications/twilio_backend.py @@ -7,12 +7,12 @@ from twilio.rest import Client from django.utils.encoding import smart_text from django.utils.translation import ugettext_lazy as _ -from awx.main.notifications.base import TowerBaseEmailBackend +from awx.main.notifications.base import AWXBaseEmailBackend logger = logging.getLogger('awx.main.notifications.twilio_backend') -class TwilioBackend(TowerBaseEmailBackend): +class TwilioBackend(AWXBaseEmailBackend): init_parameters = {"account_sid": {"label": "Account SID", "type": "string"}, "account_token": {"label": "Account Token", "type": "password"}, diff --git a/awx/main/notifications/webhook_backend.py b/awx/main/notifications/webhook_backend.py index 8489a90f7b..04135213ed 100644 --- a/awx/main/notifications/webhook_backend.py +++ b/awx/main/notifications/webhook_backend.py @@ -6,13 +6,13 @@ import requests from django.utils.encoding import smart_text from django.utils.translation import ugettext_lazy as _ -from awx.main.notifications.base import TowerBaseEmailBackend +from awx.main.notifications.base import AWXBaseEmailBackend from awx.main.utils import get_awx_version logger = logging.getLogger('awx.main.notifications.webhook_backend') -class WebhookBackend(TowerBaseEmailBackend): +class WebhookBackend(AWXBaseEmailBackend): init_parameters = {"url": {"label": "Target URL", "type": "string"}, "headers": {"label": "HTTP Headers", "type": "object"}} From b3b4a515e26c960464449de81945e45b9b29556d Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Wed, 26 Jul 2017 12:32:55 -0400 Subject: [PATCH 5/8] Refactor some tower periodic tasks to label as awx --- awx/main/isolated/isolated_manager.py | 2 +- awx/main/scheduler/__init__.py | 2 +- awx/main/tasks.py | 4 ++-- awx/main/tests/functional/test_tasks.py | 6 +++--- awx/main/tests/unit/settings/test_defaults.py | 2 +- awx/settings/defaults.py | 2 +- awx/settings/development.py | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/awx/main/isolated/isolated_manager.py b/awx/main/isolated/isolated_manager.py index 72d9f9c58e..1ac035ad4b 100644 --- a/awx/main/isolated/isolated_manager.py +++ b/awx/main/isolated/isolated_manager.py @@ -193,7 +193,7 @@ class IsolatedManager(object): isolated_ssh_path = None try: if getattr(settings, 'AWX_ISOLATED_PRIVATE_KEY', None): - isolated_ssh_path = tempfile.mkdtemp(prefix='ansible_awx_isolated', dir=settings.AWX_PROOT_BASE_PATH) + isolated_ssh_path = tempfile.mkdtemp(prefix='awx_isolated', dir=settings.AWX_PROOT_BASE_PATH) os.chmod(isolated_ssh_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) isolated_key = os.path.join(isolated_ssh_path, '.isolated') ssh_sock = os.path.join(isolated_ssh_path, '.isolated_ssh_auth.sock') diff --git a/awx/main/scheduler/__init__.py b/awx/main/scheduler/__init__.py index 3e83c759d8..fbbb8b0fb5 100644 --- a/awx/main/scheduler/__init__.py +++ b/awx/main/scheduler/__init__.py @@ -161,7 +161,7 @@ class TaskManager(): job.save(update_fields=['status', 'job_explanation']) connection.on_commit(lambda: job.websocket_emit_status('failed')) - # TODO: should we emit a status on the socket here similar to tasks.py tower_periodic_scheduler() ? + # TODO: should we emit a status on the socket here similar to tasks.py awx_periodic_scheduler() ? #emit_websocket_notification('/socket.io/jobs', '', dict(id=)) # See comment in tasks.py::RunWorkflowJob::run() diff --git a/awx/main/tasks.py b/awx/main/tasks.py index c8def0fc59..0608f1c5bd 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -213,7 +213,7 @@ def cluster_node_heartbeat(self): @task(bind=True, base=LogErrorsTask) -def tower_isolated_heartbeat(self): +def awx_isolated_heartbeat(self): local_hostname = settings.CLUSTER_HOST_ID logger.debug("Controlling node checking for any isolated management tasks.") poll_interval = settings.AWX_ISOLATED_PERIODIC_CHECK @@ -237,7 +237,7 @@ def tower_isolated_heartbeat(self): @task(bind=True, queue='tower', base=LogErrorsTask) -def tower_periodic_scheduler(self): +def awx_periodic_scheduler(self): run_now = now() state = TowerScheduleState.get_solo() last_run = state.schedule_last_run diff --git a/awx/main/tests/functional/test_tasks.py b/awx/main/tests/functional/test_tasks.py index 065d979819..24451abbdd 100644 --- a/awx/main/tests/functional/test_tasks.py +++ b/awx/main/tests/functional/test_tasks.py @@ -6,7 +6,7 @@ from django.utils.timezone import now, timedelta from awx.main.tasks import ( RunProjectUpdate, RunInventoryUpdate, - tower_isolated_heartbeat, + awx_isolated_heartbeat, isolated_manager ) from awx.main.models import ( @@ -121,7 +121,7 @@ class TestIsolatedManagementTask: original_isolated_instance = needs_updating.instances.all().first() with mock.patch('awx.main.tasks.settings', MockSettings()): with mock.patch.object(isolated_manager.IsolatedManager, 'health_check') as check_mock: - tower_isolated_heartbeat() + awx_isolated_heartbeat() iso_instance = Instance.objects.get(hostname='isolated') call_args, _ = check_mock.call_args assert call_args[0][0] == iso_instance @@ -131,7 +131,7 @@ class TestIsolatedManagementTask: def test_does_not_take_action(self, control_instance, just_updated): with mock.patch('awx.main.tasks.settings', MockSettings()): with mock.patch.object(isolated_manager.IsolatedManager, 'health_check') as check_mock: - tower_isolated_heartbeat() + awx_isolated_heartbeat() iso_instance = Instance.objects.get(hostname='isolated') check_mock.assert_not_called() assert iso_instance.capacity == 103 diff --git a/awx/main/tests/unit/settings/test_defaults.py b/awx/main/tests/unit/settings/test_defaults.py index 894289002d..52eeb56425 100644 --- a/awx/main/tests/unit/settings/test_defaults.py +++ b/awx/main/tests/unit/settings/test_defaults.py @@ -6,7 +6,7 @@ from datetime import timedelta @pytest.mark.parametrize("job_name,function_path", [ ('admin_checks', 'awx.main.tasks.run_administrative_checks'), - ('tower_scheduler', 'awx.main.tasks.tower_periodic_scheduler'), + ('tower_scheduler', 'awx.main.tasks.awx_periodic_scheduler'), ]) def test_CELERYBEAT_SCHEDULE(mocker, job_name, function_path): assert job_name in settings.CELERYBEAT_SCHEDULE diff --git a/awx/settings/defaults.py b/awx/settings/defaults.py index d076e234ea..b8dfc97f28 100644 --- a/awx/settings/defaults.py +++ b/awx/settings/defaults.py @@ -445,7 +445,7 @@ CELERY_ROUTES = {'awx.main.scheduler.tasks.run_task_manager': {'queue': 'tower', CELERYBEAT_SCHEDULE = { 'tower_scheduler': { - 'task': 'awx.main.tasks.tower_periodic_scheduler', + 'task': 'awx.main.tasks.awx_periodic_scheduler', 'schedule': timedelta(seconds=30), 'options': {'expires': 20,} }, diff --git a/awx/settings/development.py b/awx/settings/development.py index 1dc7bb8688..cb6834ee2d 100644 --- a/awx/settings/development.py +++ b/awx/settings/development.py @@ -126,7 +126,7 @@ CELERY_ROUTES['awx.main.tasks.cluster_node_heartbeat'] = {'queue': CLUSTER_HOST_ # Production only runs this schedule on controlling nodes # but development will just run it on all nodes CELERYBEAT_SCHEDULE['isolated_heartbeat'] = { - 'task': 'awx.main.tasks.tower_isolated_heartbeat', + 'task': 'awx.main.tasks.awx_isolated_heartbeat', 'schedule': timedelta(seconds = AWX_ISOLATED_PERIODIC_CHECK), 'options': {'expires': AWX_ISOLATED_PERIODIC_CHECK * 2,} } From 01403f5fa4bd50df623b88bff3c8a729df4b8c71 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Wed, 26 Jul 2017 12:37:43 -0400 Subject: [PATCH 6/8] Add awx_ and AWX_ environment vars and extra_vars alongside Tower --- awx/main/models/credential.py | 2 +- awx/main/tasks.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/awx/main/models/credential.py b/awx/main/models/credential.py index 53d5cfccb7..2c337bd5f0 100644 --- a/awx/main/models/credential.py +++ b/awx/main/models/credential.py @@ -384,7 +384,7 @@ class CredentialType(CommonModelNameNotUnique): 'VIRTUAL_ENV', 'PATH', 'PYTHONPATH', 'PROOT_TMP_DIR', 'JOB_ID', 'INVENTORY_ID', 'INVENTORY_SOURCE_ID', 'INVENTORY_UPDATE_ID', 'AD_HOC_COMMAND_ID', 'REST_API_URL', 'REST_API_TOKEN', 'TOWER_HOST', - 'MAX_EVENT_RES', 'CALLBACK_QUEUE', 'CALLBACK_CONNECTION', 'CACHE', + 'AWX_HOST', 'MAX_EVENT_RES', 'CALLBACK_QUEUE', 'CALLBACK_CONNECTION', 'CACHE', 'JOB_CALLBACK_DEBUG', 'INVENTORY_HOSTVARS', 'FACT_QUEUE', )) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 0608f1c5bd..e14a5ec0b2 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -953,6 +953,7 @@ class RunJob(BaseTask): env['REST_API_URL'] = settings.INTERNAL_API_URL env['REST_API_TOKEN'] = job.task_auth_token or '' env['TOWER_HOST'] = settings.TOWER_URL_BASE + env['AWX_HOST'] = settings.TOWER_URL_BASE env['CALLBACK_QUEUE'] = settings.CALLBACK_QUEUE env['CALLBACK_CONNECTION'] = settings.BROKER_URL env['CACHE'] = settings.CACHES['default']['LOCATION'] if 'LOCATION' in settings.CACHES['default'] else '' @@ -1077,20 +1078,27 @@ class RunJob(BaseTask): extra_vars = { 'tower_job_id': job.pk, 'tower_job_launch_type': job.launch_type, + 'awx_job_id': job.pk, + 'awx_job_launch_type': job.launch_type, } if job.project: extra_vars.update({ 'tower_project_revision': job.project.scm_revision, + 'awx_project_revision': job.project.scm_revision, }) if job.job_template: extra_vars.update({ 'tower_job_template_id': job.job_template.pk, 'tower_job_template_name': job.job_template.name, + 'awx_job_template_id': job.job_template.pk, + 'awx_job_template_name': job.job_template.name, }) if job.created_by: extra_vars.update({ 'tower_user_id': job.created_by.pk, 'tower_user_name': job.created_by.username, + 'awx_user_id': job.created_by.pk, + 'awx_user_name': job.created_by.username, }) if job.extra_vars_dict: if kwargs.get('display', False) and job.job_template: From ea03e00a0fd14d958248b50760efe7e82fbf47e6 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Wed, 26 Jul 2017 14:16:17 -0400 Subject: [PATCH 7/8] Add back in PRIVILEGE_ESCALATION_METHODS inadvertantly removed --- awx/main/tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index e14a5ec0b2..c95ff9710c 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -44,7 +44,7 @@ from django.core.exceptions import ObjectDoesNotExist # AWX from awx import __version__ as awx_application_version -from awx.main.constants import CLOUD_PROVIDERS +from awx.main.constants import CLOUD_PROVIDERS, PRIVILEGE_ESCALATION_METHODS from awx.main.models import * # noqa from awx.main.models.unified_jobs import ACTIVE_STATES from awx.main.queue import CallbackQueueDispatcher From 7231537841a6f2ae08d460d25e426d63d719f119 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Wed, 26 Jul 2017 14:18:19 -0400 Subject: [PATCH 8/8] Remove ansible reference from dev PKG-INFO --- tools/docker-compose/awx.egg-info/PKG-INFO | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/docker-compose/awx.egg-info/PKG-INFO b/tools/docker-compose/awx.egg-info/PKG-INFO index d02ec5de21..3aded406c9 100644 --- a/tools/docker-compose/awx.egg-info/PKG-INFO +++ b/tools/docker-compose/awx.egg-info/PKG-INFO @@ -6,7 +6,7 @@ Home-page: http://github.com/ansible/awx Author: Ansible, Inc. Author-email: info@ansible.com License: Proprietary -Description: Ansible AWX provides a web-based user interface, REST API and task engine built on top of Ansible +Description: AWX provides a web-based user interface, REST API and task engine built on top of Ansible Keywords: ansible Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable