cloudstack: inventory: consider more keys optional (#49364)
This commit is contained in:
parent
238786c0d3
commit
bd1050dfc7
1 changed files with 30 additions and 8 deletions
|
@ -157,24 +157,35 @@ class CloudStackInventory(object):
|
||||||
data['affinity_group'] = host['affinitygroup']
|
data['affinity_group'] = host['affinitygroup']
|
||||||
data['security_group'] = host['securitygroup']
|
data['security_group'] = host['securitygroup']
|
||||||
data['cpu_number'] = host['cpunumber']
|
data['cpu_number'] = host['cpunumber']
|
||||||
data['cpu_speed'] = host['cpuspeed']
|
if 'cpu_speed' in host:
|
||||||
|
data['cpu_speed'] = host['cpuspeed']
|
||||||
if 'cpuused' in host:
|
if 'cpuused' in host:
|
||||||
data['cpu_used'] = host['cpuused']
|
data['cpu_used'] = host['cpuused']
|
||||||
data['memory'] = host['memory']
|
data['memory'] = host['memory']
|
||||||
data['tags'] = host['tags']
|
data['tags'] = host['tags']
|
||||||
data['hypervisor'] = host['hypervisor']
|
if 'hypervisor' in host:
|
||||||
|
data['hypervisor'] = host['hypervisor']
|
||||||
data['created'] = host['created']
|
data['created'] = host['created']
|
||||||
data['nic'] = []
|
data['nic'] = []
|
||||||
for nic in host['nic']:
|
for nic in host['nic']:
|
||||||
data['nic'].append({
|
nicdata = {
|
||||||
'ip': nic['ipaddress'],
|
'ip': nic['ipaddress'],
|
||||||
'mac': nic['macaddress'],
|
'mac': nic['macaddress'],
|
||||||
'netmask': nic['netmask'],
|
'netmask': nic['netmask'],
|
||||||
'gateway': nic['gateway'],
|
'gateway': nic['gateway'],
|
||||||
'type': nic['type'],
|
'type': nic['type'],
|
||||||
})
|
}
|
||||||
|
if 'ip6address' in nic:
|
||||||
|
nicdata['ip6'] = nic['ip6address']
|
||||||
|
if 'gateway' in nic:
|
||||||
|
nicdata['gateway'] = nic['gateway']
|
||||||
|
if 'netmask' in nic:
|
||||||
|
nicdata['netmask'] = nic['netmask']
|
||||||
|
data['nic'].append(nicdata)
|
||||||
if nic['isdefault']:
|
if nic['isdefault']:
|
||||||
data['default_ip'] = nic['ipaddress']
|
data['default_ip'] = nic['ipaddress']
|
||||||
|
if 'ip6address' in nic:
|
||||||
|
data['default_ip6'] = nic['ip6address']
|
||||||
break
|
break
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
@ -221,25 +232,36 @@ class CloudStackInventory(object):
|
||||||
data['_meta']['hostvars'][host_name]['affinity_group'] = host['affinitygroup']
|
data['_meta']['hostvars'][host_name]['affinity_group'] = host['affinitygroup']
|
||||||
data['_meta']['hostvars'][host_name]['security_group'] = host['securitygroup']
|
data['_meta']['hostvars'][host_name]['security_group'] = host['securitygroup']
|
||||||
data['_meta']['hostvars'][host_name]['cpu_number'] = host['cpunumber']
|
data['_meta']['hostvars'][host_name]['cpu_number'] = host['cpunumber']
|
||||||
data['_meta']['hostvars'][host_name]['cpu_speed'] = host['cpuspeed']
|
if 'cpuspeed' in host:
|
||||||
|
data['_meta']['hostvars'][host_name]['cpu_speed'] = host['cpuspeed']
|
||||||
if 'cpuused' in host:
|
if 'cpuused' in host:
|
||||||
data['_meta']['hostvars'][host_name]['cpu_used'] = host['cpuused']
|
data['_meta']['hostvars'][host_name]['cpu_used'] = host['cpuused']
|
||||||
data['_meta']['hostvars'][host_name]['created'] = host['created']
|
data['_meta']['hostvars'][host_name]['created'] = host['created']
|
||||||
data['_meta']['hostvars'][host_name]['memory'] = host['memory']
|
data['_meta']['hostvars'][host_name]['memory'] = host['memory']
|
||||||
data['_meta']['hostvars'][host_name]['tags'] = host['tags']
|
data['_meta']['hostvars'][host_name]['tags'] = host['tags']
|
||||||
data['_meta']['hostvars'][host_name]['hypervisor'] = host['hypervisor']
|
if 'hypervisor' in host:
|
||||||
|
data['_meta']['hostvars'][host_name]['hypervisor'] = host['hypervisor']
|
||||||
data['_meta']['hostvars'][host_name]['created'] = host['created']
|
data['_meta']['hostvars'][host_name]['created'] = host['created']
|
||||||
data['_meta']['hostvars'][host_name]['nic'] = []
|
data['_meta']['hostvars'][host_name]['nic'] = []
|
||||||
for nic in host['nic']:
|
for nic in host['nic']:
|
||||||
data['_meta']['hostvars'][host_name]['nic'].append({
|
nicdata = {
|
||||||
'ip': nic['ipaddress'],
|
'ip': nic['ipaddress'],
|
||||||
'mac': nic['macaddress'],
|
'mac': nic['macaddress'],
|
||||||
'netmask': nic['netmask'],
|
'netmask': nic['netmask'],
|
||||||
'gateway': nic['gateway'],
|
'gateway': nic['gateway'],
|
||||||
'type': nic['type'],
|
'type': nic['type'],
|
||||||
})
|
}
|
||||||
|
if 'ip6address' in nic:
|
||||||
|
nicdata['ip6'] = nic['ip6address']
|
||||||
|
if 'gateway' in nic:
|
||||||
|
nicdata['gateway'] = nic['gateway']
|
||||||
|
if 'netmask' in nic:
|
||||||
|
nicdata['netmask'] = nic['netmask']
|
||||||
|
data['_meta']['hostvars'][host_name]['nic'].append(nicdata)
|
||||||
if nic['isdefault']:
|
if nic['isdefault']:
|
||||||
data['_meta']['hostvars'][host_name]['default_ip'] = nic['ipaddress']
|
data['_meta']['hostvars'][host_name]['default_ip'] = nic['ipaddress']
|
||||||
|
if 'ip6address' in nic:
|
||||||
|
data['_meta']['hostvars'][host_name]['default_ip6'] = nic['ip6address']
|
||||||
|
|
||||||
group_name = ''
|
group_name = ''
|
||||||
if 'group' in host:
|
if 'group' in host:
|
||||||
|
|
Loading…
Reference in a new issue