libcloud_dns: Further fixes to state output, pylint fixes

This commit is contained in:
Ronald van Zantvoort 2017-12-18 12:40:55 +01:00 committed by GitHub
parent e9bbc23b11
commit c72db283d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -89,7 +89,7 @@ def zone_present(domain, type, profile):
return state_result(True, "Zone already exists")
else:
result = __salt__['libcloud_dns.create_zone'](domain, profile, type)
return state_result(domain, result, "Created new zone")
return state_result(domain, result, 'Created new zone')
def zone_absent(domain, profile):
@ -105,10 +105,10 @@ def zone_absent(domain, profile):
zones = __salt__['libcloud_dns.list_zones'](profile)
matching_zone = [z for z in zones if z.domain == domain]
if len(matching_zone) == 0:
return state_result(True, "Zone already absent")
return state_result(domain, True, 'Zone already absent')
else:
result = __salt__['libcloud_dns.delete_zone'](matching_zone[0].id, profile)
return state_result(domain, result, "Deleted zone")
return state_result(domain, result, 'Deleted zone')
def record_present(name, zone, type, data, profile):
@ -137,7 +137,7 @@ def record_present(name, zone, type, data, profile):
try:
matching_zone = [z for z in zones if z.domain == zone][0]
except IndexError:
return state_result(False, "Could not locate zone")
return state_result(zone, False, 'Could not locate zone')
records = __salt__['libcloud_dns.list_records'](matching_zone.id, profile)
matching_records = [record for record in records
if record.name == name and
@ -147,9 +147,9 @@ def record_present(name, zone, type, data, profile):
result = __salt__['libcloud_dns.create_record'](
name, matching_zone.id,
type, data, profile)
return state_result(name, result, "Created new record")
return state_result(name, result, 'Created new record')
else:
return state_result(name, True, "Record already exists")
return state_result(name, True, 'Record already exists')
def record_absent(name, zone, type, data, profile):
@ -178,7 +178,7 @@ def record_absent(name, zone, type, data, profile):
try:
matching_zone = [z for z in zones if z.domain == zone][0]
except IndexError:
return state_result(False, "Zone could not be found")
return state_result(zone, False, 'Zone could not be found')
records = __salt__['libcloud_dns.list_records'](matching_zone.id, profile)
matching_records = [record for record in records
if record.name == name and
@ -191,6 +191,6 @@ def record_absent(name, zone, type, data, profile):
matching_zone.id,
record.id,
profile))
return state_result(name, all(result), "Removed {0} records".format(len(result)))
return state_result(name, all(result), 'Removed {0} records'.format(len(result)))
else:
return state_result(name, True, "Records already absent")
return state_result(name, True, 'Records already absent')