mirror of
https://github.com/ansible/awx.git
synced 2024-10-31 23:51:09 +03:00
Updated ovirt4 dynamic inventory script.
Pulling in the new ovirt4 dynamic inventory script that will be pulled in ansible/ansible#57824 Signed-off-by: Ryan Kraus <rmkraus@gmail.com>
This commit is contained in:
parent
793e78d9c0
commit
468e79a754
@ -65,15 +65,9 @@ import sys
|
||||
|
||||
from collections import defaultdict
|
||||
|
||||
try:
|
||||
import ConfigParser as configparser
|
||||
except ImportError:
|
||||
import configparser
|
||||
from ansible.module_utils.six.moves import configparser
|
||||
|
||||
try:
|
||||
import json
|
||||
except ImportError:
|
||||
import simplejson as json
|
||||
import json
|
||||
|
||||
try:
|
||||
import ovirtsdk4 as sdk
|
||||
@ -127,7 +121,7 @@ def create_connection():
|
||||
'ovirt_url': os.environ.get('OVIRT_URL'),
|
||||
'ovirt_username': os.environ.get('OVIRT_USERNAME'),
|
||||
'ovirt_password': os.environ.get('OVIRT_PASSWORD'),
|
||||
'ovirt_ca_file': os.environ.get('OVIRT_CAFILE'),
|
||||
'ovirt_ca_file': os.environ.get('OVIRT_CAFILE', ''),
|
||||
}
|
||||
)
|
||||
if not config.has_section('ovirt'):
|
||||
@ -139,8 +133,8 @@ def create_connection():
|
||||
url=config.get('ovirt', 'ovirt_url'),
|
||||
username=config.get('ovirt', 'ovirt_username'),
|
||||
password=config.get('ovirt', 'ovirt_password', raw=True),
|
||||
ca_file=config.get('ovirt', 'ovirt_ca_file'),
|
||||
insecure=config.get('ovirt', 'ovirt_ca_file') is None,
|
||||
ca_file=config.get('ovirt', 'ovirt_ca_file') or None,
|
||||
insecure=not config.get('ovirt', 'ovirt_ca_file'),
|
||||
)
|
||||
|
||||
|
||||
@ -179,7 +173,7 @@ def get_dict_of_struct(connection, vm):
|
||||
if vm.name in [vm.name for vm in connection.follow_link(group.vms)]
|
||||
],
|
||||
'statistics': dict(
|
||||
(stat.name, stat.values[0].datum) for stat in stats
|
||||
(stat.name, stat.values[0].datum) for stat in stats if stat.values
|
||||
),
|
||||
'devices': dict(
|
||||
(device.name, [ip.address for ip in device.ips]) for device in devices if device.ips
|
||||
@ -258,5 +252,6 @@ def main():
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user