Add Python 3 support to ovirt4 inventory script. (#57824)

Python 3 only allows strings through the config parser. This is fine for 
the URL, Username, and Password since these values are required. The CA 
File is optional so an empty string is used in leiu of None in the 
config dictionary.
This commit is contained in:
Ryan Kraus 2019-06-21 12:05:45 -04:00 committed by Sam Doran
parent b86c7759c5
commit 7d4e3af11e
2 changed files with 5 additions and 3 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- ovirt4 inventory - Updated the dynamic inventory script for Python 3 support

View file

@ -121,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'):
@ -133,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'),
)