Organization on JT as read-only field

Set JT.organization with value from its project

Remove validation requiring JT.organization

Undo some of the additional org definitions in tests

Revert some tests no longer needed for feature

exclude workflow approvals from unified organization field

revert awxkit changes for providing organization

Roll back additional JT creation permission requirement

Fix up more issues by persisting organization field when project is removed

Restrict project org editing, logging, and testing

Grant removed inventory org admin permissions in migration

Add special validate_unique for job templates
  this deals with enforcing name-organization uniqueness

Add back in special message where config is unknown
  when receiving 403 on job relaunch

Fix logical and performance bugs with data migration

within JT.inventory.organization make-permission-explicit migration

remove nested loops so we do .iterator() on JT queryset

in reverse migration, carefully remove execute role on JT
  held by org admins of inventory organization,
  as well as the execute_role holders

Use current state of Role model in logic, with 1 notable exception
  that is used to filter on ancestors
  the ancestor and descentent relationship in the migration model
    is not reliable
  output of this is saved as an integer list to avoid future
    compatibility errors

make the parents rebuilding logic skip over irrelevant models
  this is the largest performance gain for small resource numbers
This commit is contained in:
AlanCoding
2020-01-21 11:12:08 -05:00
parent daa9282790
commit 7d0b207571
31 changed files with 517 additions and 226 deletions

View File

@@ -7,7 +7,7 @@ from awxkit.utils import (
suppress,
update_payload,
PseudoNamespace)
from awxkit.api.pages import Credential, Inventory, Project, UnifiedJobTemplate, Organization
from awxkit.api.pages import Credential, Inventory, Project, UnifiedJobTemplate
from awxkit.api.mixins import HasCreate, HasInstanceGroups, HasNotifications, HasSurvey, HasCopy, DSAdapter
from awxkit.api.resources import resources
import awxkit.exceptions as exc
@@ -23,7 +23,7 @@ class JobTemplate(
HasSurvey,
UnifiedJobTemplate):
optional_dependencies = [Organization, Inventory, Credential, Project]
optional_dependencies = [Inventory, Credential, Project]
def launch(self, payload={}):
"""Launch the job_template using related->launch endpoint."""
@@ -129,7 +129,6 @@ class JobTemplate(
playbook='ping.yml',
credential=Credential,
inventory=Inventory,
organization=Organization,
project=None,
**kwargs):
if not project:
@@ -149,18 +148,12 @@ class JobTemplate(
project = self.ds.project if project else None
inventory = self.ds.inventory if inventory else None
credential = self.ds.credential if credential else None
# if the created project has an organization, and the parameters
# specified no organization, then borrow the one from the project
if hasattr(project.ds, 'organization') and organization is Organization:
self.ds.organization = project.ds.organization
organization = self.ds.organization
payload = self.payload(
name=name,
description=description,
job_type=job_type,
playbook=playbook,
organization=organization,
credential=credential,
inventory=inventory,
project=project,
@@ -176,12 +169,11 @@ class JobTemplate(
playbook='ping.yml',
credential=Credential,
inventory=Inventory,
organization=Organization,
project=None,
**kwargs):
payload, credential = self.create_payload(name=name, description=description, job_type=job_type,
playbook=playbook, credential=credential, inventory=inventory,
project=project, organization=organization, **kwargs)
project=project, **kwargs)
ret = self.update_identity(
JobTemplates(
self.connection).post(payload))

View File

@@ -12,7 +12,7 @@ from . import page
class WorkflowJobTemplate(HasCopy, HasCreate, HasNotifications, HasSurvey, UnifiedJobTemplate):
dependencies = [Organization]
optional_dependencies = [Organization]
def launch(self, payload={}):
"""Launch using related->launch endpoint."""
@@ -71,14 +71,14 @@ class WorkflowJobTemplate(HasCopy, HasCreate, HasNotifications, HasSurvey, Unifi
return payload
def create_payload(self, name='', description='', organization=Organization, **kwargs):
def create_payload(self, name='', description='', organization=None, **kwargs):
self.create_and_update_dependencies(*filter_by_class((organization, Organization)))
organization = self.ds.organization if organization else None
payload = self.payload(name=name, description=description, organization=organization, **kwargs)
payload.ds = DSAdapter(self.__class__.__name__, self._dependency_store)
return payload
def create(self, name='', description='', organization=Organization, **kwargs):
def create(self, name='', description='', organization=None, **kwargs):
payload = self.create_payload(name=name, description=description, organization=organization, **kwargs)
return self.update_identity(WorkflowJobTemplates(self.connection).post(payload))

View File

@@ -63,6 +63,7 @@ class Resources(object):
_inventory_related_root_groups = r'inventories/\d+/root_groups/'
_inventory_related_script = r'inventories/\d+/script/'
_inventory_related_update_inventory_sources = r'inventories/\d+/update_inventory_sources/'
_inventory_scan_job_templates = r'inventories/\d+/scan_job_templates/'
_inventory_script = r'inventory_scripts/\d+/'
_inventory_script_copy = r'inventory_scripts/\d+/copy/'
_inventory_scripts = 'inventory_scripts/'