1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Use try block for field splitting

This commit is contained in:
Dagobert Michelsen 2015-02-20 13:57:02 +01:00
parent 90e760ba84
commit c1dba60961

View file

@ -2507,18 +2507,21 @@ class SunOSVirtual(Virtual):
# DOMAINROLE|impl=LDoms|control=false|io=false|service=false|root=false # DOMAINROLE|impl=LDoms|control=false|io=false|service=false|root=false
# The output may also be not formated and the returncode is set to 0 regardless of the error condition: # The output may also be not formated and the returncode is set to 0 regardless of the error condition:
# virtinfo can only be run from the global zone # virtinfo can only be run from the global zone
for line in out.split('\n'): try:
fields = line.split('|') for line in out.split('\n'):
if( fields[0] == 'DOMAINROLE' and fields[1] == 'impl=LDoms' ): fields = line.split('|')
self.facts['virtualization_type'] = 'ldom' if( fields[0] == 'DOMAINROLE' and fields[1] == 'impl=LDoms' ):
self.facts['virtualization_role'] = 'guest' self.facts['virtualization_type'] = 'ldom'
hostfeatures = [] self.facts['virtualization_role'] = 'guest'
for field in fields[2:]: hostfeatures = []
arg = field.split('=') for field in fields[2:]:
if( arg[1] == 'true' ): arg = field.split('=')
hostfeatures.append(arg[0]) if( arg[1] == 'true' ):
if( len(hostfeatures) > 0 ): hostfeatures.append(arg[0])
self.facts['virtualization_role'] = 'host (' + ','.join(hostfeatures) + ')' if( len(hostfeatures) > 0 ):
self.facts['virtualization_role'] = 'host (' + ','.join(hostfeatures) + ')'
except ValueError, e:
pass
def get_file_content(path, default=None, strip=True): def get_file_content(path, default=None, strip=True):
data = default data = default