mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 18:40:01 -03:30
add the conditionals for incorrect paths and helpful info for if a user does that
and remove unused import
This commit is contained in:
parent
cece7ff741
commit
550ab82f63
@ -24,7 +24,7 @@ from awx.api.generics import APIView
|
||||
from awx.conf.registry import settings_registry
|
||||
from awx.main.analytics import all_collectors
|
||||
from awx.main.ha import is_ha_environment
|
||||
from awx.main.utils import get_awx_version, get_custom_venv_choices
|
||||
from awx.main.utils import get_awx_version
|
||||
from awx.main.utils.licensing import validate_entitlement_manifest
|
||||
from awx.api.versioning import reverse, drf_reverse
|
||||
from awx.main.constants import PRIVILEGE_ESCALATION_METHODS
|
||||
|
||||
@ -26,7 +26,8 @@ class Command(BaseCommand):
|
||||
results = {}
|
||||
path = options.get('path')
|
||||
if path:
|
||||
if path[0] in get_custom_venv_choices(): # verify this is a valid path
|
||||
all_venvs = get_custom_venv_choices()
|
||||
if path[0] in all_venvs: # verify this is a valid path
|
||||
path = path[0]
|
||||
orgs = [{"name": org.name, "id": org.id} for org in Organization.objects.filter(custom_virtualenv=path)]
|
||||
jts = [{"name": jt.name, "id": jt.id} for jt in JobTemplate.objects.filter(custom_virtualenv=path)]
|
||||
@ -38,14 +39,21 @@ class Command(BaseCommand):
|
||||
results["inventory_sources"] = invsrc
|
||||
print('\n', '# {}'.format("Virtual environments associations:"))
|
||||
print(yaml.dump(results))
|
||||
if not options.get('q'):
|
||||
msg = [
|
||||
'',
|
||||
'To list all (now deprecated) custom virtual environments run:',
|
||||
'awx-manage list_custom_venvs',
|
||||
'',
|
||||
'To export the contents of a (deprecated) virtual environment, ' 'run the following command while supplying the path as an argument:',
|
||||
'awx-manage export_custom_venv /path/to/venv',
|
||||
'',
|
||||
]
|
||||
print('\n'.join(msg))
|
||||
|
||||
if not options.get('q'):
|
||||
msg = [
|
||||
'',
|
||||
'- To list all (now deprecated) custom virtual environments run:',
|
||||
'awx-manage list_custom_venvs',
|
||||
'',
|
||||
'- To export the contents of a (deprecated) virtual environment, ' 'run the following command while supplying the path as an argument:',
|
||||
'awx-manage export_custom_venv /path/to/venv',
|
||||
'',
|
||||
'- Run these commands with `-q` to remove tool tips.',
|
||||
'',
|
||||
]
|
||||
print('\n'.join(msg))
|
||||
|
||||
else:
|
||||
print('\n', '# Incorrect path, verify your path is from the following list:')
|
||||
print('\n'.join(all_venvs), '\n')
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
# Copyright (c) 2021 Ansible, Inc.
|
||||
# All Rights Reserved
|
||||
|
||||
from awx.main.utils.common import get_custom_venv_pip_freeze
|
||||
from awx.main.utils.common import get_custom_venv_pip_freeze, get_custom_venv_choices
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
|
||||
@ -21,17 +21,26 @@ class Command(BaseCommand):
|
||||
def handle(self, *args, **options):
|
||||
super(Command, self).__init__()
|
||||
if options.get('path'):
|
||||
pip_data = get_custom_venv_pip_freeze(options.get('path')[0])
|
||||
if pip_data:
|
||||
print('\n', '# {}'.format("Virtual environment contents:"))
|
||||
print(pip_data)
|
||||
if not options.get('q'):
|
||||
msg = [
|
||||
'To list all (now deprecated) custom virtual environments run:',
|
||||
'awx-manage list_custom_venvs',
|
||||
'',
|
||||
'To view the connections a (deprecated) virtual environment had in the database, run the following command while supplying the path as an argument:',
|
||||
'awx-manage custom_venv_associations /path/to/venv',
|
||||
'',
|
||||
]
|
||||
print('\n'.join(msg))
|
||||
path = options.get('path')
|
||||
all_venvs = get_custom_venv_choices()
|
||||
if path[0] in all_venvs:
|
||||
pip_data = get_custom_venv_pip_freeze(options.get('path')[0])
|
||||
if pip_data:
|
||||
print('\n', '# {}'.format("Virtual environment contents:"))
|
||||
print(pip_data)
|
||||
if not options.get('q'):
|
||||
msg = [
|
||||
'- To list all (now deprecated) custom virtual environments run:',
|
||||
'awx-manage list_custom_venvs',
|
||||
'',
|
||||
'- To view the connections a (deprecated) virtual environment had in the database, run the following command while supplying the path as an argument:',
|
||||
'awx-manage custom_venv_associations /path/to/venv',
|
||||
'',
|
||||
'- Run these commands with `-q` to remove tool tips.',
|
||||
'',
|
||||
]
|
||||
print('\n'.join(msg))
|
||||
|
||||
else:
|
||||
print('\n', '# Incorrect path, verify your path is from the following list:')
|
||||
print('\n'.join(all_venvs))
|
||||
|
||||
@ -18,21 +18,19 @@ class Command(BaseCommand):
|
||||
venvs = get_custom_venv_choices()
|
||||
if venvs:
|
||||
print('\n', '# {}'.format("Discovered virtual environments:"))
|
||||
for venv in venvs:
|
||||
print(venv)
|
||||
print('\n'.join(venvs), '\n')
|
||||
if not options.get('q'):
|
||||
msg = [
|
||||
'',
|
||||
'To export the contents of a (deprecated) virtual environment, ' 'run the following command while supplying the path as an argument:',
|
||||
'- To export the contents of a (deprecated) virtual environment, ' 'run the following command while supplying the path as an argument:',
|
||||
'awx-manage export_custom_venv /path/to/venv',
|
||||
'',
|
||||
'To view the connections a (deprecated) virtual environment had in the database, run the following command while supplying the path as an argument:',
|
||||
'- To view the connections a (deprecated) virtual environment had in the database, run the following command while supplying the path as an argument:',
|
||||
'awx-manage custom_venv_associations /path/to/venv',
|
||||
'',
|
||||
'- Run these commands with `-q` to remove tool tips.',
|
||||
'',
|
||||
]
|
||||
print('\n'.join(msg))
|
||||
else:
|
||||
print('\n')
|
||||
|
||||
else:
|
||||
msg = ["No custom virtual environments detected in:", settings.BASE_VENV_PATH]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user