push global invsource fields onto invsource obj

This commit is contained in:
Chris Meyers
2020-08-05 13:33:24 -04:00
committed by Ryan Petrello
parent d518891520
commit a9cdf07690
5 changed files with 79 additions and 60 deletions

View File

@@ -7,7 +7,6 @@ import time
import logging
import re
import copy
import json
import os.path
from urllib.parse import urljoin
import yaml
@@ -863,6 +862,39 @@ class InventorySourceOptions(BaseModel):
default='',
help_text=_('Inventory source variables in YAML or JSON format.'),
)
enabled_var = models.TextField(
blank=True,
default='',
help_text=_('Retrieve the enabled state from the given dict of host '
'variables. The enabled variable may be specified as "foo.bar", '
'in which case the lookup will traverse into nested dicts, '
'equivalent to: from_dict.get("foo", {}).get("bar", default)'),
)
enabled_value = models.TextField(
blank=True,
default='',
help_text=_('Only used when enabled_var is set. Value when the host is '
'considered enabled. For example if enabled_var="status.power_state"'
'and enabled_value="powered_on" with host variables:'
'{'
' "status": {'
' "power_state": "powered_on",'
' "created": "2020-08-04T18:13:04+00:00",'
' "healthy": true'
' },'
' "name": "foobar",'
' "ip_address": "192.168.2.1"'
'}'
'The host would be marked enabled. If power_state where any '
'value other than powered_on then the host would be disabled '
'when imported into Tower. If the key is not found then the '
'host will be enabled'),
)
host_filter = models.TextField(
blank=True,
default='',
help_text=_('Regex where only matching hosts will be imported into Tower.'),
)
overwrite = models.BooleanField(
default=False,
help_text=_('Overwrite local groups and hosts from remote inventory source.'),