mirror of
https://github.com/ansible/awx.git
synced 2026-03-19 18:07:33 -02:30
Remove tags, add group for templates to VMware inventory script.
This commit is contained in:
@@ -1811,7 +1811,7 @@ class InventoryUpdatesTest(BaseTransactionTest):
|
|||||||
# in host variables.
|
# in host variables.
|
||||||
for host in self.inventory.hosts.all():
|
for host in self.inventory.hosts.all():
|
||||||
self.assertFalse(host.instance_id, host.instance_id)
|
self.assertFalse(host.instance_id, host.instance_id)
|
||||||
if host.enabled:
|
if host.enabled and host.variables_dict.get('vmware_ipAddress', ''):
|
||||||
self.assertTrue(host.variables_dict.get('ansible_ssh_host', ''))
|
self.assertTrue(host.variables_dict.get('ansible_ssh_host', ''))
|
||||||
# Test a field that should be present for host systems, not VMs.
|
# Test a field that should be present for host systems, not VMs.
|
||||||
self.assertFalse(host.variables_dict.get('vmware_product_name', ''))
|
self.assertFalse(host.variables_dict.get('vmware_product_name', ''))
|
||||||
|
|||||||
@@ -192,7 +192,6 @@ class VMwareInventory(object):
|
|||||||
'''
|
'''
|
||||||
host_info = {
|
host_info = {
|
||||||
'name': host.name,
|
'name': host.name,
|
||||||
'tag': host.tag,
|
|
||||||
}
|
}
|
||||||
for attr in ('datastore', 'network', 'vm'):
|
for attr in ('datastore', 'network', 'vm'):
|
||||||
try:
|
try:
|
||||||
@@ -221,7 +220,6 @@ class VMwareInventory(object):
|
|||||||
'''
|
'''
|
||||||
vm_info = {
|
vm_info = {
|
||||||
'name': vm.name,
|
'name': vm.name,
|
||||||
'tag': vm.tag,
|
|
||||||
}
|
}
|
||||||
for attr in ('datastore', 'network'):
|
for attr in ('datastore', 'network'):
|
||||||
try:
|
try:
|
||||||
@@ -313,10 +311,6 @@ class VMwareInventory(object):
|
|||||||
if not self.guests_only:
|
if not self.guests_only:
|
||||||
self._add_host(inv, 'all', host.name)
|
self._add_host(inv, 'all', host.name)
|
||||||
self._add_host(inv, hw_group, host.name)
|
self._add_host(inv, hw_group, host.name)
|
||||||
if host.tag: # FIXME: Is this always a string?
|
|
||||||
host_tag = 'vmware_%s' % host.tag
|
|
||||||
self._add_host(inv, host_tag, host.name)
|
|
||||||
|
|
||||||
host_info = self._get_host_info(host)
|
host_info = self._get_host_info(host)
|
||||||
if meta_hostvars:
|
if meta_hostvars:
|
||||||
inv['_meta']['hostvars'][host.name] = host_info
|
inv['_meta']['hostvars'][host.name] = host_info
|
||||||
@@ -326,9 +320,6 @@ class VMwareInventory(object):
|
|||||||
for vm in host.vm:
|
for vm in host.vm:
|
||||||
self._add_host(inv, 'all', vm.name)
|
self._add_host(inv, 'all', vm.name)
|
||||||
self._add_host(inv, vm_group, vm.name)
|
self._add_host(inv, vm_group, vm.name)
|
||||||
if vm.tag: # FIXME: Is this always a string?
|
|
||||||
vm_tag = 'vmware_%s' % vm.tag
|
|
||||||
self._add_host(inv, vm_tag, vm.name)
|
|
||||||
vm_info = self._get_vm_info(vm)
|
vm_info = self._get_vm_info(vm)
|
||||||
if meta_hostvars:
|
if meta_hostvars:
|
||||||
inv['_meta']['hostvars'][vm.name] = vm_info
|
inv['_meta']['hostvars'][vm.name] = vm_info
|
||||||
@@ -360,6 +351,12 @@ class VMwareInventory(object):
|
|||||||
self._add_child(inv, 'guests', vm_guestId)
|
self._add_child(inv, 'guests', vm_guestId)
|
||||||
self._add_host(inv, vm_guestId, vm.name)
|
self._add_host(inv, vm_guestId, vm.name)
|
||||||
|
|
||||||
|
# Group all VM templates.
|
||||||
|
vm_template = vm_info.get('vmware_template', False)
|
||||||
|
if vm_template:
|
||||||
|
self._add_child(inv, vm_group, 'templates')
|
||||||
|
self._add_host(inv, 'templates', vm.name)
|
||||||
|
|
||||||
self._put_cache(cache_name, inv)
|
self._put_cache(cache_name, inv)
|
||||||
return inv
|
return inv
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user