mirror of
https://github.com/ansible/awx.git
synced 2024-10-31 15:21:13 +03:00
Update vmware implementation to new agreements
This commit is contained in:
parent
50197c6a12
commit
68f5482c42
@ -2265,42 +2265,50 @@ class vmware(PluginFileInjector):
|
||||
def inventory_as_dict(self, inventory_update, private_data_dir):
|
||||
ret = super(vmware, self).inventory_as_dict(inventory_update, private_data_dir)
|
||||
ret['strict'] = False
|
||||
ret['properties'] = [
|
||||
"name",
|
||||
# Documentation of props, see
|
||||
# https://github.com/ansible/ansible/blob/devel/docs/docsite/rst/scenario_guides/vmware_scenarios/vmware_inventory_vm_attributes.rst
|
||||
UPPERCASE_PROPS = [
|
||||
"ansible_ssh_host",
|
||||
"ansible_host",
|
||||
"ansible_uuid",
|
||||
"availablefield",
|
||||
"capability", # nested properties
|
||||
"config", # nested properties
|
||||
"configissue",
|
||||
"configstatus",
|
||||
"customvalue",
|
||||
"availableField", # optional?
|
||||
"configIssue", # optional?
|
||||
"configStatus", # optional?
|
||||
"customValue", # optional?
|
||||
"datastore",
|
||||
"effectiverole",
|
||||
"guest", # nested properties
|
||||
"guestheartbeatstatus",
|
||||
"layout",
|
||||
"layoutex",
|
||||
"effectiveRole", # optional?
|
||||
"guestHeartbeatStatus", # optonal?
|
||||
"layout", # optional?
|
||||
"layoutEx", # optional?
|
||||
"name",
|
||||
"network",
|
||||
"overallstatus",
|
||||
"parentvapp",
|
||||
"overallStatus", # optional?
|
||||
"parentVApp", # optional?
|
||||
"permission",
|
||||
"recenttask",
|
||||
"resourcepool",
|
||||
"rootsnapshot",
|
||||
"runtime", # nested properties
|
||||
"snapshot",
|
||||
"storage", # nested properties
|
||||
"summary", # repeat of other properties
|
||||
"recentTask", # optional?
|
||||
"resourcePool",
|
||||
"rootSnapshot", # optional?
|
||||
"snapshot", # optional
|
||||
"tag",
|
||||
"triggeredalarmstate",
|
||||
"value",
|
||||
"triggeredAlarmState",
|
||||
"value"
|
||||
]
|
||||
# ret['properties'] = ["all"] # causes UnknownWsdlTypeError exception
|
||||
ret['with_nested_properties'] = True
|
||||
ret['property_name_format'] = 'lower_case'
|
||||
NESTED_PROPS = [
|
||||
"capability",
|
||||
"config",
|
||||
"guest",
|
||||
"runtime",
|
||||
"storage",
|
||||
"summary", # repeat of other properties
|
||||
]
|
||||
ret['properties'] = UPPERCASE_PROPS + NESTED_PROPS
|
||||
ret['compose'] = {}
|
||||
for prop in UPPERCASE_PROPS:
|
||||
if prop == prop.lower():
|
||||
continue
|
||||
ret['compose'][prop.lower()] = prop
|
||||
# ret['with_nested_properties'] = True # only dacrystal/topic/vmware-inventory-plugin-enhancements
|
||||
# ret['property_name_format'] = 'lower_case' # only dacrystal/topic/vmware-inventory-plugin-property-format
|
||||
|
||||
# process custom options
|
||||
vmware_opts = dict(inventory_update.source_vars_dict.items())
|
||||
@ -2320,16 +2328,18 @@ class vmware(PluginFileInjector):
|
||||
|
||||
host_pattern = vmware_opts.get('host_pattern') # not working in script
|
||||
if host_pattern:
|
||||
pass # does not appear to have an option for this
|
||||
stripped_hp = host_pattern.replace('{', '').replace('}', '').strip() # make best effort
|
||||
ret['compose']['ansible_host'] = stripped_hp
|
||||
ret['compose']['ansible_ssh_host'] = stripped_hp
|
||||
|
||||
host_filters = vmware_opts.get('host_filters')
|
||||
if host_filters:
|
||||
ret.setdefault('host_filters', [])
|
||||
ret.setdefault('filters', [])
|
||||
for hf in host_filters.split(','):
|
||||
striped_hf = hf.replace('{', '').replace('}', '').strip() # make best effort
|
||||
if not striped_hf:
|
||||
continue
|
||||
ret['host_filters'].append(striped_hf)
|
||||
ret['filters'].append(striped_hf)
|
||||
|
||||
groupby_patterns = vmware_opts.get('groupby_patterns')
|
||||
if groupby_patterns:
|
||||
|
@ -1,43 +1,55 @@
|
||||
host_filters:
|
||||
- config.name == "only_my_server"
|
||||
- somevar == "bar"
|
||||
compose:
|
||||
availablefield: availableField
|
||||
configissue: configIssue
|
||||
configstatus: configStatus
|
||||
customvalue: customValue
|
||||
effectiverole: effectiveRole
|
||||
guestheartbeatstatus: guestHeartbeatStatus
|
||||
layoutex: layoutEx
|
||||
overallstatus: overallStatus
|
||||
parentvapp: parentVApp
|
||||
recenttask: recentTask
|
||||
resourcepool: resourcePool
|
||||
rootsnapshot: rootSnapshot
|
||||
triggeredalarmstate: triggeredAlarmState
|
||||
filters:
|
||||
- config.zoo == "DC0_H0_VM0"
|
||||
hostnames:
|
||||
- config.foo
|
||||
keyed_groups:
|
||||
- key: fouo
|
||||
- key: config.asdf
|
||||
prefix: ''
|
||||
separator: ''
|
||||
plugin: community.vmware.vmware_vm_inventory
|
||||
properties:
|
||||
- name
|
||||
- ansible_ssh_host
|
||||
- ansible_host
|
||||
- ansible_uuid
|
||||
- availablefield
|
||||
- capability
|
||||
- config
|
||||
- configissue
|
||||
- configstatus
|
||||
- customvalue
|
||||
- availableField
|
||||
- configIssue
|
||||
- configStatus
|
||||
- customValue
|
||||
- datastore
|
||||
- effectiverole
|
||||
- guest
|
||||
- guestheartbeatstatus
|
||||
- effectiveRole
|
||||
- guestHeartbeatStatus
|
||||
- layout
|
||||
- layoutex
|
||||
- layoutEx
|
||||
- name
|
||||
- network
|
||||
- overallstatus
|
||||
- parentvapp
|
||||
- overallStatus
|
||||
- parentVApp
|
||||
- permission
|
||||
- recenttask
|
||||
- resourcepool
|
||||
- rootsnapshot
|
||||
- runtime
|
||||
- recentTask
|
||||
- resourcePool
|
||||
- rootSnapshot
|
||||
- snapshot
|
||||
- tag
|
||||
- triggeredAlarmState
|
||||
- value
|
||||
- capability
|
||||
- config
|
||||
- guest
|
||||
- runtime
|
||||
- storage
|
||||
- summary
|
||||
- tag
|
||||
- triggeredalarmstate
|
||||
- value
|
||||
property_name_format: lower_case
|
||||
strict: false
|
||||
with_nested_properties: true
|
||||
|
@ -5,6 +5,7 @@ username = fooo
|
||||
password = fooo
|
||||
server = https://foo.invalid
|
||||
base_source_var = value_of_var
|
||||
host_filters = {{ config.name == "only_my_server" }},{{ somevar == "bar"}}
|
||||
groupby_patterns = fouo
|
||||
alias_pattern = {{ config.foo }}
|
||||
host_filters = {{ config.zoo == "DC0_H0_VM0" }}
|
||||
groupby_patterns = {{ config.asdf }}
|
||||
|
||||
|
@ -53,6 +53,9 @@ INI_TEST_VARS = {
|
||||
'rhv': {}, # there are none
|
||||
'tower': {}, # there are none
|
||||
'vmware': {
|
||||
'alias_pattern': "{{ config.foo }}",
|
||||
'host_filters': '{{ config.zoo == "DC0_H0_VM0" }}',
|
||||
'groupby_patterns': "{{ config.asdf }}",
|
||||
# setting VMWARE_VALIDATE_CERTS is duplicated with env var
|
||||
},
|
||||
'azure_rm': {
|
||||
|
Loading…
Reference in New Issue
Block a user