mirror of
https://github.com/ansible/awx.git
synced 2026-02-12 07:04:45 -03:30
Merge pull request #10429 from AlanCoding/teardown_global_ee
Make ExecutionEnvironment awxkit class able to handle null values in … This is how the Project class does it, and I can confirm it makes factories.execution_environment(organization=None) work correctly. Reviewed-by: Jeff Bradberry <None>
This commit is contained in:
@@ -6,7 +6,7 @@ from awxkit.api.pages import (
|
||||
Organization,
|
||||
)
|
||||
from awxkit.api.resources import resources
|
||||
from awxkit.utils import random_title, PseudoNamespace
|
||||
from awxkit.utils import random_title, PseudoNamespace, filter_by_class
|
||||
|
||||
from . import base
|
||||
from . import page
|
||||
@@ -21,15 +21,19 @@ class ExecutionEnvironment(HasCreate, HasCopy, base.Base):
|
||||
NATURAL_KEY = ('name',)
|
||||
|
||||
# fields are name, image, organization, managed_by_tower, credential
|
||||
def create(self, name='', image='quay.io/ansible/ansible-runner:devel', credential=None, pull='', **kwargs):
|
||||
def create(self, name='', image='quay.io/ansible/ansible-runner:devel', organization=Organization, credential=None, pull='', **kwargs):
|
||||
# we do not want to make a credential by default
|
||||
payload = self.create_payload(name=name, image=image, credential=credential, pull=pull, **kwargs)
|
||||
payload = self.create_payload(name=name, image=image, organization=organization, credential=credential, pull=pull, **kwargs)
|
||||
ret = self.update_identity(ExecutionEnvironments(self.connection).post(payload))
|
||||
return ret
|
||||
|
||||
def create_payload(self, name='', organization=Organization, **kwargs):
|
||||
self.create_and_update_dependencies(organization)
|
||||
payload = self.payload(name=name, organization=self.ds.organization, **kwargs)
|
||||
def create_payload(self, name='', organization=Organization, credential=None, **kwargs):
|
||||
self.create_and_update_dependencies(*filter_by_class((credential, Credential), (organization, Organization)))
|
||||
|
||||
credential = self.ds.credential if credential else None
|
||||
organization = self.ds.organization if organization else None
|
||||
|
||||
payload = self.payload(name=name, organization=organization, credential=credential, **kwargs)
|
||||
payload.ds = DSAdapter(self.__class__.__name__, self._dependency_store)
|
||||
return payload
|
||||
|
||||
|
||||
Reference in New Issue
Block a user