Class: Sunzi::Vps::DNS::Vultr
- Inherits:
-
Base
- Object
- Base
- Sunzi::Vps::DNS::Vultr
show all
- Defined in:
- lib/sunzi/vps/dns/vultr.rb
Instance Attribute Summary
Attributes inherited from Base
#api
Instance Method Summary
collapse
Methods inherited from Base
#client, #initialize
Instance Method Details
#add(fqdn, ip) ⇒ Object
12
13
14
15
|
# File 'lib/sunzi/vps/dns/vultr.rb', line 12
def add(fqdn, ip)
say 'adding the public IP to Vultr DNS...'
client::DNS.create_record(domain: @zone, name: fqdn.sub('.' + @zone, ''), type: 'A', data: ip)
end
|
#delete(ip) ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/sunzi/vps/dns/vultr.rb', line 17
def delete(ip)
say 'deleting the public IP from Vultr DNS...'
result = client::DNS.records(domain: @zone)
hash = result[:result].find{|i| i['type'] == 'A' && i['data'] == ip }
abort_with "ip address #{ip} was not found on Vultr DNS!" unless hash['RECORDID']
client::DNS.delete_record(domain: @zone, RECORDID: hash['RECORDID'])
end
|
#verify ⇒ Object
6
7
8
9
10
|
# File 'lib/sunzi/vps/dns/vultr.rb', line 6
def verify
result = client::DNS.list
domain = result[:result].find{|h| h['domain'] == @zone }
abort_with "zone for #{@zone} was not found on Vultr DNS!" unless domain
end
|