Merge pull request #34 from ryanpetrello/release_3.2.0

more tower -> awx for task execution and isolated tooling
This commit is contained in:
Ryan Petrello
2017-07-25 11:16:04 -04:00
committed by GitHub
11 changed files with 21 additions and 21 deletions

View File

@@ -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_tower_isolated', dir=settings.AWX_PROOT_BASE_PATH)
isolated_ssh_path = tempfile.mkdtemp(prefix='ansible_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')
@@ -446,7 +446,7 @@ class IsolatedManager(object):
isolated job on
:param private_data_dir: an absolute path on the local file system
where job-specific data should be written
(i.e., `/tmp/ansible_tower_xyz/`)
(i.e., `/tmp/ansible_awx_xyz/`)
:param proot_temp_dir: a temporary directory which bwrap maps
restricted paths to

View File

@@ -143,7 +143,7 @@ def run_isolated_job(private_data_dir, secrets, logfile=sys.stdout):
:param private_data_dir: an absolute path on the local file system where
job metadata exists (i.e.,
`/tmp/ansible_tower_xyz/`)
`/tmp/ansible_awx_xyz/`)
:param secrets: a dict containing sensitive job metadata, {
'env': { ... } # environment variables,
'passwords': { ... } # pexpect password prompts

View File

@@ -472,7 +472,7 @@ class BaseTask(Task):
'''
Create a temporary directory for job-related files.
'''
path = tempfile.mkdtemp(prefix='ansible_tower_%s_' % instance.pk, dir=settings.AWX_PROOT_BASE_PATH)
path = tempfile.mkdtemp(prefix='ansible_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
@@ -1857,7 +1857,7 @@ class RunInventoryUpdate(BaseTask):
elif src == 'scm':
args.append(inventory_update.get_actual_source_path())
elif src == 'custom':
runpath = tempfile.mkdtemp(prefix='ansible_tower_inventory_', dir=settings.AWX_PROOT_BASE_PATH)
runpath = tempfile.mkdtemp(prefix='ansible_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:

View File

@@ -28,7 +28,7 @@ def rsa_key(request):
@pytest.fixture(scope='function')
def private_data_dir(request):
path = tempfile.mkdtemp(prefix='ansible_tower_unit_test')
path = tempfile.mkdtemp(prefix='ansible_awx_unit_test')
request.addfinalizer(lambda: shutil.rmtree(path))
return path

View File

@@ -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_tower_project_')
self.project_path = tempfile.mkdtemp(prefix='ansible_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_tower_')
private_data = tempfile.mkdtemp(prefix='ansible_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_tower_proot_')
assert extra_vars['proot_temp_dir'].startswith('/tmp/ansible_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_tower_')
private_data = tempfile.mkdtemp(prefix='ansible_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_tower_')
private_data = tempfile.mkdtemp(prefix='ansible_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_tower_')
private_data = tempfile.mkdtemp(prefix='ansible_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)

View File

@@ -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_tower_proot_', dir=settings.AWX_PROOT_BASE_PATH)
path = tempfile.mkdtemp(prefix='ansible_awx_proot_', dir=settings.AWX_PROOT_BASE_PATH)
os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
return path

View File

@@ -6,7 +6,7 @@
tasks:
- name: Get capacity of the instance
tower_capacity:
awx_capacity:
- name: Remove any stale temporary files
tower_isolated_cleanup:
awx_isolated_cleanup:

View File

@@ -39,7 +39,7 @@ def main():
job_cutoff = datetime.datetime.now() - datetime.timedelta(hours=1)
for search_pattern in [
'/tmp/ansible_tower_[0-9]*_*', '/tmp/ansible_tower_proot_*',
'/tmp/ansible_awx_[0-9]*_*', '/tmp/ansible_awx_proot_*',
]:
for path in glob.iglob(search_pattern):
st = os.stat(path)
@@ -49,7 +49,7 @@ def main():
continue
elif modtime > folder_cutoff:
try:
re_match = re.match(r'\/tmp\/ansible_tower_\d+_.+', path)
re_match = re.match(r'\/tmp\/ansible_awx_\d+_.+', path)
if re_match is not None:
if subprocess.check_call(['awx-expect', 'is-alive', path]) == 0:
continue