mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 01:17:37 -02:30
adding in a 3rd command that shows the associated templates, orgs, and invs the venv is tied to
This commit is contained in:
@@ -12,7 +12,6 @@ class Command(BaseCommand):
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'path',
|
'path',
|
||||||
type=str,
|
type=str,
|
||||||
nargs='?',
|
|
||||||
default='',
|
default='',
|
||||||
help='run this with a path to a virtual environment as an argument to see the pip freeze data',
|
help='run this with a path to a virtual environment as an argument to see the pip freeze data',
|
||||||
)
|
)
|
||||||
@@ -24,7 +23,7 @@ class Command(BaseCommand):
|
|||||||
if pip_data:
|
if pip_data:
|
||||||
print(pip_data)
|
print(pip_data)
|
||||||
msg = [
|
msg = [
|
||||||
'To list all available custom virtual environments run:',
|
'To list all (now deprecated) custom virtual environments run:',
|
||||||
'awx-manage list_custom_venvs',
|
'awx-manage list_custom_venvs',
|
||||||
]
|
]
|
||||||
print('\n'.join(msg))
|
print('\n'.join(msg))
|
||||||
|
|||||||
35
awx/main/management/commands/get_custom_venv_associations.py
Normal file
35
awx/main/management/commands/get_custom_venv_associations.py
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# Copyright (c) 2021 Ansible, Inc.
|
||||||
|
# All Rights Reserved
|
||||||
|
|
||||||
|
from django.core.management.base import BaseCommand
|
||||||
|
from awx.main.models import Organization, InventorySource, UnifiedJobTemplate
|
||||||
|
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
"""Returns the pip freeze from the path passed in the argument"""
|
||||||
|
|
||||||
|
def add_arguments(self, parser):
|
||||||
|
parser.add_argument(
|
||||||
|
'path',
|
||||||
|
type=str,
|
||||||
|
nargs='?',
|
||||||
|
default='',
|
||||||
|
help='run this with a path to a virtual environment as an argument to see the pip freeze data',
|
||||||
|
)
|
||||||
|
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
# look organiztions and unified job templates (which include JTs, workflows, and Inventory updates)
|
||||||
|
super(Command, self).__init__()
|
||||||
|
results = {}
|
||||||
|
if options.get('path'):
|
||||||
|
# sanity check here - is path in list
|
||||||
|
path = options.get('path')
|
||||||
|
orgs = [{"name": org.name, "id": org.id} for org in Organization.objects.filter(custom_virtualenv=path)]
|
||||||
|
ujts = [{"name": org.name, "id": org.id} for org in UnifiedJobTemplate.objects.filter(custom_virtualenv=path)]
|
||||||
|
invsrc = [{"name": inv.name, "id": inv.id} for inv in InventorySource.objects.filter(custom_virtualenv=path)]
|
||||||
|
results["Organizations"] = orgs
|
||||||
|
results["Unified Job Templates"] = ujts
|
||||||
|
results["Inventory Sources"] = invsrc
|
||||||
|
print(results)
|
||||||
|
else:
|
||||||
|
print("missing argument: please include a path argument following the command.")
|
||||||
@@ -8,7 +8,7 @@ from django.conf import settings
|
|||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
"""Returns either a list of custom venv paths from the path passed in the argument"""
|
"""Returns a list of custom venv paths from the path passed in the argument"""
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
super(Command, self).__init__()
|
super(Command, self).__init__()
|
||||||
@@ -20,7 +20,7 @@ class Command(BaseCommand):
|
|||||||
|
|
||||||
msg = [
|
msg = [
|
||||||
'',
|
'',
|
||||||
'To export the contents of a 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',
|
'awx-manage export_custom_venv /path/to/venv',
|
||||||
]
|
]
|
||||||
print('\n'.join(msg))
|
print('\n'.join(msg))
|
||||||
|
|||||||
Reference in New Issue
Block a user