Get zone from config

This commit is contained in:
Jake Spain 2023-02-07 07:29:17 -05:00
parent ad57ae053f
commit cbb3ad3904
No known key found for this signature in database
GPG key ID: BC1C4DA0A085E113

View file

@ -44,14 +44,19 @@ module Vmpooler
'gcp-clouddns' 'gcp-clouddns'
end end
# main configuration options
def zone_name
dns_config['zone_name']
end
def create_or_replace_record(hostname) def create_or_replace_record(hostname)
ip = get_ip(hostname) ip = get_ip(hostname)
connection.zone('vmpooler-example-com').add(hostname, 'A', 60, ip) connection.zone(zone_name).add(hostname, 'A', 60, ip)
end end
def delete_record(hostname) def delete_record(hostname)
retries = 0 retries = 0
connection.zone('vmpooler-example-com').remove(hostname, 'A') connection.zone(zone_name).remove(hostname, 'A')
rescue Google::Cloud::FailedPreconditionError => e rescue Google::Cloud::FailedPreconditionError => e
# this error was experienced intermittently, will retry to see if it can complete successfully # this error was experienced intermittently, will retry to see if it can complete successfully
# the error is Google::Cloud::FailedPreconditionError: conditionNotMet: Precondition not met for 'entity.change.deletions[1]' # the error is Google::Cloud::FailedPreconditionError: conditionNotMet: Precondition not met for 'entity.change.deletions[1]'