mirror of
https://github.com/ansible/awx.git
synced 2026-03-04 10:11:05 -03:30
Fix order become methods render and migration query
This commit is contained in:
@@ -38,7 +38,13 @@ from rest_framework.utils.serializer_helpers import ReturnList
|
|||||||
from polymorphic.models import PolymorphicModel
|
from polymorphic.models import PolymorphicModel
|
||||||
|
|
||||||
# AWX
|
# AWX
|
||||||
from awx.main.constants import SCHEDULEABLE_PROVIDERS, ANSI_SGR_PATTERN, ACTIVE_STATES, TOKEN_CENSOR
|
from awx.main.constants import (
|
||||||
|
SCHEDULEABLE_PROVIDERS,
|
||||||
|
ANSI_SGR_PATTERN,
|
||||||
|
ACTIVE_STATES,
|
||||||
|
TOKEN_CENSOR,
|
||||||
|
CHOICES_PRIVILEGE_ESCALATION_METHODS,
|
||||||
|
)
|
||||||
from awx.main.models import * # noqa
|
from awx.main.models import * # noqa
|
||||||
from awx.main.models.base import NEW_JOB_TYPE_CHOICES
|
from awx.main.models.base import NEW_JOB_TYPE_CHOICES
|
||||||
from awx.main.access import get_user_capabilities
|
from awx.main.access import get_user_capabilities
|
||||||
@@ -2494,6 +2500,9 @@ class CredentialTypeSerializer(BaseSerializer):
|
|||||||
field['label'] = _(field['label'])
|
field['label'] = _(field['label'])
|
||||||
if 'help_text' in field:
|
if 'help_text' in field:
|
||||||
field['help_text'] = _(field['help_text'])
|
field['help_text'] = _(field['help_text'])
|
||||||
|
if field['type'] == 'become_method':
|
||||||
|
field.pop('type')
|
||||||
|
field['choices'] = map(operator.itemgetter(0), CHOICES_PRIVILEGE_ESCALATION_METHODS)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def filter_field_metadata(self, fields, method):
|
def filter_field_metadata(self, fields, method):
|
||||||
|
|||||||
@@ -14,9 +14,10 @@ __all__ = [
|
|||||||
CLOUD_PROVIDERS = ('azure_rm', 'ec2', 'gce', 'vmware', 'openstack', 'rhv', 'satellite6', 'cloudforms', 'tower')
|
CLOUD_PROVIDERS = ('azure_rm', 'ec2', 'gce', 'vmware', 'openstack', 'rhv', 'satellite6', 'cloudforms', 'tower')
|
||||||
SCHEDULEABLE_PROVIDERS = CLOUD_PROVIDERS + ('custom', 'scm',)
|
SCHEDULEABLE_PROVIDERS = CLOUD_PROVIDERS + ('custom', 'scm',)
|
||||||
PRIVILEGE_ESCALATION_METHODS = [
|
PRIVILEGE_ESCALATION_METHODS = [
|
||||||
('enable', _('Enable')), ('doas', _('Doas')),
|
|
||||||
('sudo', _('Sudo')), ('su', _('Su')), ('pbrun', _('Pbrun')), ('pfexec', _('Pfexec')),
|
('sudo', _('Sudo')), ('su', _('Su')), ('pbrun', _('Pbrun')), ('pfexec', _('Pfexec')),
|
||||||
('dzdo', _('DZDO')), ('pmrun', _('Pmrun')), ('runas', _('Runas'))]
|
('dzdo', _('DZDO')), ('pmrun', _('Pmrun')), ('runas', _('Runas')),
|
||||||
|
('enable', _('Enable')), ('doas', _('Doas')),
|
||||||
|
]
|
||||||
CHOICES_PRIVILEGE_ESCALATION_METHODS = [('', _('None'))] + PRIVILEGE_ESCALATION_METHODS
|
CHOICES_PRIVILEGE_ESCALATION_METHODS = [('', _('None'))] + PRIVILEGE_ESCALATION_METHODS
|
||||||
ANSI_SGR_PATTERN = re.compile(r'\x1b\[[0-9;]*m')
|
ANSI_SGR_PATTERN = re.compile(r'\x1b\[[0-9;]*m')
|
||||||
CAN_CANCEL = ('new', 'pending', 'waiting', 'running')
|
CAN_CANCEL = ('new', 'pending', 'waiting', 'running')
|
||||||
|
|||||||
@@ -200,6 +200,6 @@ def add_azure_cloud_environment_field(apps, schema_editor):
|
|||||||
|
|
||||||
|
|
||||||
def remove_become_methods(apps, schema_editor):
|
def remove_become_methods(apps, schema_editor):
|
||||||
become_credtype = CredentialType.objects.get(kind='ssh').first()
|
become_credtype = CredentialType.objects.filter(kind='ssh', managed_by_tower=True).first()
|
||||||
become_credtype.inputs = CredentialType.defaults.get('ssh')().inputs
|
become_credtype.inputs = CredentialType.defaults.get('ssh')().inputs
|
||||||
become_credtype.save()
|
become_credtype.save()
|
||||||
|
|||||||
Reference in New Issue
Block a user