Commit Graph
100 Commits
Author SHA1 Message Date
Jeff Bradberry 6b82ae46bc Force worker processes to have a different signal handler from the parent
Situations have come up where the 5+ minute kill signal for
run_task_manager is emitted to the worker process running it, but
since the worker improperly inherited the AWXConsumerBase().stop()
handler a deadlock ultimately was triggered on the database
connection.
2020-07-23 12:09:59 -04:00
Jeff Bradberry d8b9d48313 Add a note about import/export 2020-06-23 10:09:32 -04:00
Jeff Bradberry 393369adec First cut at examples of the import and export commands 2020-06-18 15:32:49 -04:00
Jeff Bradberry 0fda9d2c56 Continue after failures to grant roles 2020-06-11 13:19:24 -04:00
Jeff Bradberry bf6e8f8e83 Prioritize membership roles
since certain role grants will not be accepted by the api unless the user or team is part of the correct organization.
2020-06-10 15:27:15 -04:00
Jeff Bradberry 19b7c91486 Return the changed status of imports 2020-06-09 15:00:06 -04:00
Jeff Bradberry aeeed4d371 Add more logging 2020-06-09 15:00:06 -04:00
Jeff Bradberry 1f7c1af64e Fix WFJT nodes endpoint to return node pages when posting
not the node list page.
2020-06-09 15:00:06 -04:00
Jeff Bradberry 65fc2db42f Recursively queue up related assets to be created and/or assigned 2020-06-09 14:59:49 -04:00
Jeff Bradberry c8288af87f Make sure we have a cached version of existing objects
even if it isn't an object being directly imported.  We might need it
for relations of things that are being imported.
2020-06-09 13:54:05 -04:00
Jeff Bradberry 76fb605dcd Deal with exports involving foreign keys where you don't have permission 2020-06-09 13:54:05 -04:00
Jeff Bradberry a531b85b31 Redo waiting until Project updates are complete 2020-06-09 13:54:05 -04:00
Jeff Bradberry 86afa5cf42 Make more use of the PageCache for imports 2020-06-09 13:54:05 -04:00
Jeff Bradberry 57aff6394c Log an error and continue when a related object is not found 2020-06-09 13:54:05 -04:00
Jeff Bradberry 66bc947adb Reuse _import_list for import of related full objects
e.g. WFJT Nodes.  Also rename _import_list from _create_assets.
2020-06-09 13:54:05 -04:00
Jeff Bradberry 301f15bfdd Rename some things for consistency 2020-06-09 13:54:05 -04:00
Jeff Bradberry 9fc1a4bb44 Change the method that exports list views to take a PageList or TentativePage
This will allow the related m2m views to also use this method, with a
bit of effort.  Also, remove the use of pk_or_name in favor of a new
method that reduces the number of api calls.
2020-06-09 13:54:05 -04:00
Jeff Bradberry f7825aefeb Avoid doing an OPTIONS call unless we know it is a related type we export 2020-06-09 13:54:05 -04:00
Jeff Bradberry 14b5f63bd8 Use the new PageCache to store and reuse Page.get results 2020-06-09 13:54:05 -04:00
Jeff Bradberry 1300d38e47 Introduce a new PageCache object
and split out get_post_fields into its own utility function.
2020-06-09 13:54:05 -04:00
Jeff Bradberry bb66e4633d Split _get_options into two pieces 2020-06-09 13:54:05 -04:00
Jeff Bradberry 201de4e18a Attempt to deal with foreign keys that get mislabeled as type integer
such as through the use of DeprecatedCredentialField.
2020-06-09 13:54:05 -04:00
Jeff Bradberry 471dc2babf Deal with relations that we cannot resolve
such as due to a lack of permissions.  If there is a foreign key to
something where we don't have sufficient read permissions, we now drop
the parent object from the export.
2020-06-09 13:54:05 -04:00
Jeff Bradberry 6387258da1 Only wait for Project updates
not other kinds of objects that have a status.
2020-06-09 13:54:05 -04:00
Jeff Bradberry 6958815f6e Remove the $encrypted$ placeholders from export values 2020-06-09 13:54:05 -04:00
Jeff Bradberry 43b76f4575 Deal with unreadable mandatory foreign keys
by dropping the parent object.  Also, clarify some of the warning log
messages.
2020-06-09 13:54:05 -04:00
Jeff Bradberry 53d81d42cc Hook up creation and attachment of related objects 2020-06-09 13:54:05 -04:00
Jeff Bradberry 385725e52a Fix the _create_assets method to use _get_options 2020-06-09 13:54:05 -04:00
Jeff Bradberry 1b264011a2 Enable interconnections between WFJT Nodes 2020-06-09 13:54:05 -04:00
Jeff Bradberry 719f0b407c Enable credential relations
but only when it is in an attach/detach list view.
2020-06-09 13:54:05 -04:00
Jeff Bradberry a5fa34bd3b Fall back to parsing the OPTIONS description
to determine the needed fields for constructing an object.
2020-06-09 13:54:05 -04:00
Jeff Bradberry eb10a1873d Drop objects that cannot be read or do not have a natural key
don't fail hard.
2020-06-09 13:54:05 -04:00
Jeff Bradberry ab15349c8c Remove the NoNaturalKey error
It's too awkward, and it makes more sense to return None instead.
2020-06-09 13:54:05 -04:00
Jeff Bradberry e053a58223 Handle some more bad cases when doing OPTIONS calls
- deprecated endpoints
- read-only endpoints
- insufficient privileges

The latter case currently just drops it on the floor, but ought to do
something better.
2020-06-09 13:54:05 -04:00
Jeff Bradberry 4262dd38ba Change the NoNaturalKey exception to no longer derive from Common
which seems to be entirely use for response exceptions.  Maybe rename
Common?
2020-06-09 13:54:05 -04:00
Jeff Bradberry 0deacc4391 If attempting to link to a resource that is not yet complete, wait 2020-06-09 13:54:05 -04:00
Jeff Bradberry 329293dbf0 Tentatively enable inventory sources 2020-06-09 13:54:05 -04:00
Jeff Bradberry e92c8cfdcc Remove the natural key lookup dict and make each Page responsible instead 2020-06-09 13:54:05 -04:00
Jeff Bradberry 07ba521b8b Enable schedules 2020-06-09 13:54:05 -04:00
Jeff Bradberry 972d3ab535 Export full related objects under some conditions 2020-06-09 13:54:05 -04:00
Jeff Bradberry a1f7d0b781 Fix a bug with inventory.variables
Using Page[key] instead of Page.json[key] causes inner json blob
strings to automatically get parsed, which is not what we want with
this field.
2020-06-09 13:54:05 -04:00
Jeff Bradberry 30a3e3e172 Deal with lack of permissions 2020-06-09 13:54:05 -04:00
Jeff Bradberry 01d575f833 Enable the remaining top-level exportable resources
and rearrange the import/export methods a bit.
2020-06-09 13:54:05 -04:00
Jeff Bradberry e0f6af4700 Enable the export of several relation field types 2020-06-09 13:54:05 -04:00
Jeff Bradberry 3860c7597f Move the import logic into methods on the ApiV2 class 2020-06-09 13:54:05 -04:00
Jeff Bradberry e4146e9bc7 Move the export logic onto methods on the ApiV2 class
making it easier to invoke programmatically.
2020-06-09 13:54:05 -04:00
Jeff Bradberry 19c92a7055 Enable notification templates 2020-06-09 13:54:05 -04:00
Jeff Bradberry 6a9add4fe3 Deal somewhat reasonably with missing fields as part of the natural key
- JobTemplate.organization has recently been added, we need to support
  with and without
- WorkflowJobTemplateNode is shortly going to get an identifier field,
  and we will need to support both with and without
2020-06-09 13:54:05 -04:00
Jeff Bradberry ad574eb896 Enable credential export 2020-06-09 13:54:05 -04:00
Jeff Bradberry 55f79a4569 Fix a couple of flaws
- The dependency ordering may spit out page types that weren't in the import data set.  Make sure to be able to map those to resources anyway.
- freeze() needs to be able to deal with nullable foreign keys.
2020-06-09 13:54:05 -04:00
Jeff Bradberry d20fa03034 Create new Import.dependent_resources method
that yields up resource names, even ones that aren't explicitly in the
import data, in dependency order.
2020-06-09 13:54:05 -04:00
Jeff Bradberry 868aafb263 Filter out managed credential types
since we cannot patch them upon import.
2020-06-09 13:54:05 -04:00
Jeff Bradberry 3f204659a8 Temporarily disable export of resources that may not work yet 2020-06-09 13:54:05 -04:00
Jeff Bradberry ea5b810e87 Sort the asset groups to be imported by their dependency relationships 2020-06-09 13:54:04 -04:00
Jeff Bradberry 2c00d42ced Only use a default password if an import user doesn't already exist 2020-06-09 13:54:04 -04:00
Jeff Bradberry d191edcaf1 Fix a Python 2 syntax error
it doesn't like multiple **kwargs, apparently.
2020-06-09 13:54:04 -04:00
Jeff Bradberry 65e16dc7ae Get and assign the related objects 2020-06-09 13:54:04 -04:00
Jeff Bradberry 95b22bf05b Begin to deal with existing matching assets
by using a registry allowing the lookup of Page objects by (frozen)
natural keys.
2020-06-09 13:54:04 -04:00
Jeff Bradberry 21e36ad19a Add the calculated natural key to the export data for each asset 2020-06-09 13:54:04 -04:00
Jeff Bradberry f53920d3bf Begin changing Import to work with the structure created by Export 2020-06-09 13:54:04 -04:00
Jeff Bradberry 372570ce8e Extract out get_natural_key as a standalone function 2020-06-09 13:54:04 -04:00
Jeff Bradberry 6f28361bf5 Make serialize_asset use Pages to a greater extent 2020-06-09 13:54:04 -04:00
Jeff Bradberry 0877e5305c Modify get_natural_key to work on Pages 2020-06-09 13:54:04 -04:00
Jeff Bradberry e4383c505f Make more use of the functionality of Page in get_assets
and related methods.  Also, rename get_resource_options -> get_options
and enhance_asset -> serialize_asset.
2020-06-09 13:54:04 -04:00
Jeff Bradberry fb066eb52e Fold the other methods doing API calls into get_assets() 2020-06-09 13:54:04 -04:00
Jeff Bradberry 6162ff0439 Start to record the role membership
but not really, since it still isn't fully capturing the role content_object
2020-06-09 13:54:04 -04:00
Jeff Bradberry dfe34563aa Resolve the natural keys of assets we've already collected 2020-06-09 13:54:04 -04:00
Jeff Bradberry 37cbf7691b Split out separate methods for the OPTIONS call and massaging each asset dict 2020-06-09 13:54:04 -04:00
Jeff Bradberry 9280198b0f Use a list of exportable resources to build up the parser
Also, handle an implicit export of everything.
2020-06-09 13:54:04 -04:00
Jeff Bradberry 2127f3c96d Add organizations as a resource type to export 2020-06-09 13:54:04 -04:00
Jeff Bradberry 9f7fecf8da Add basic import command 2020-06-09 13:54:04 -04:00
Jeff Bradberry c1a07ff00b Limit export output to only those fields needed to create the resource 2020-06-09 13:54:04 -04:00
Jeff Bradberry f21d6b1fc4 Actually query the API for the user or users requested 2020-06-09 13:54:04 -04:00
Jeff Bradberry 4312395a3a Normalize the requested resource into a pk
using the pk_or_name helper function.  Also, authenticate to the API.
2020-06-09 13:54:04 -04:00
Jeff Bradberry c1f6fec532 Add skeleton of a custom 'export' resource
This only takes a flag for users at the moment, and does nothing in
particular with it.
2020-06-09 13:54:04 -04:00
Jeff Bradberry ced8f42835 Force worker processes to have a different signal handler from the parent
Situations have come up where the 5+ minute kill signal for
run_task_manager is emitted to the worker process running it, but
since the worker improperly inherited the AWXConsumerBase().stop()
handler a deadlock ultimately was triggered on the database
connection.
2020-06-04 15:41:28 -04:00
Jeff Bradberry 6b3befcb94 Optionally add the webhook_credential link to related
on JTs and WFJTs.
2020-03-26 16:07:14 -04:00
Jeff Bradberry 91135f638f Add a connection kwarg to Page.from_json
if you don't reuse the connection when doing this, you lose your
authentication.
2020-03-24 15:27:51 -04:00
Jeff Bradberry e3ea4e2398 Register the resource copy endpoints as awxkit page types 2020-03-23 15:19:48 -04:00
Jeff Bradberry e4e2d48f53 Register some missing related endpoints in awxkit
- the newer varieties of notification templates
- organization workflow job templates
- credential owner users and owner teams

this allows the endpoints to get wrapped in appropriate Page types,
not just the Base page type.
2020-03-23 15:18:47 -04:00
Jeff Bradberry 1e48d773ae Add job_templates to the set of related endpoints for organizations 2020-03-23 14:33:40 -04:00
Jeff Bradberry d849e81891 Show API choice field metadata more correctly for null vs '' 2020-03-05 17:10:59 -05:00
Jeff Bradberry d0bec97bbb Adjust the logic that renders fields with choices on an API Options call
accounting for the case where blank or null is allowed.

Refs #5099
2020-02-24 10:17:38 -05:00
Jeff Bradberry aff31ac02f Add the no_truncate parameter to the job and adhoc event sublist views
which are the ones that the CLI actually uses.
2019-10-29 11:24:17 -04:00
Jeff Bradberry b48815d2bb Add the no_truncate parameter to the job and adhoc event sublist views
which are the ones that the CLI actually uses.
2019-10-28 12:51:14 -04:00
Jeff Bradberry cf89108edf Force the CLI to use no_truncate for the monitor calls 2019-10-14 11:21:11 -04:00
Jeff Bradberry e672e68a02 Allow the job event list views to take a no_truncate GET param 2019-10-11 17:18:36 -04:00
Jeff Bradberry 9efa7b84df Depend on a serializer context variable no_truncate
to decide whether to turn off the ANSI control sequence-aware
truncation, instead of needing inappropriate awareness of the details
of the view that invoked the serializer.  This will also allow us to
have views that can more flexibly turn off the truncation under other
circumstances.
2019-10-10 16:08:17 -04:00
Jeff Bradberry a803cedd7c Break out a new reusable truncate_stdout utility function 2019-10-10 16:07:08 -04:00
Jeff Bradberry 1122d28a1b Quote the playbook passed to runner from the isolated manager 2019-10-02 11:10:19 -04:00
Jeff Bradberry d549877ebd Check for the existance of a UnifiedJobTemplate with the same webhook GUID
instead of trying (incorrectly) to be specific about the JT/WFJT type.
2019-09-30 15:26:49 -04:00
Jeff Bradberry 204c05aa3b Change the webhook post-back payload to use the job UI url 2019-09-30 13:32:23 -04:00
Jeff Bradberry ac34b24868 Post the job or workflow url to the webhook service as part of the status 2019-09-30 13:32:23 -04:00
Jeff Bradberry ffe89820e3 Return to using ContentType.kind
which is _not_ the `kind` attribute being deprecated.
2019-09-30 13:32:23 -04:00
Jeff Bradberry 062c4908c9 Modify the webhook debounce logic
to check if we've already previously run a job with the same webhook
GUID plus template id.  This will allow organizations to write
multiple JT/WFJTs to handle the same set of webhook events.
2019-09-30 13:32:23 -04:00
Jeff Bradberry b6b70e55fb Address a variety of small review issues 2019-09-30 13:32:23 -04:00
Jeff Bradberry 6aa6471b7c Add help_text to the new fields 2019-09-30 13:32:23 -04:00
Jeff Bradberry e14d4ddec6 Add a doc template to the webhook key API view 2019-09-30 13:32:23 -04:00
Jeff Bradberry df24f5d28f Add a new launch_type of 'webhook' 2019-09-30 13:32:23 -04:00
Jeff Bradberry fea7f914d2 Avoid the use of CredentialType.kind 2019-09-30 13:32:23 -04:00