Class: Sunzi::Vps::DNS::Linode

Inherits:
Base
  • Object
show all
Defined in:
lib/sunzi/vps/dns/linode.rb

Instance Attribute Summary

Attributes inherited from Base

#api

Instance Method Summary collapse

Methods inherited from Base

#client, #initialize

Constructor Details

This class inherits a constructor from Sunzi::Vps::DNS::Base

Instance Method Details

#add(fqdn, ip) ⇒ Object



11
12
13
14
# File 'lib/sunzi/vps/dns/linode.rb', line 11

def add(fqdn, ip)
  say 'adding the public IP to Linode DNS Manager...'
  client.domain.resource.create(:DomainID => @domain.domainid, :Type => 'A', :Name => fqdn, :Target => ip)
end

#delete(ip) ⇒ Object



16
17
18
19
20
21
# File 'lib/sunzi/vps/dns/linode.rb', line 16

def delete(ip)
  say 'deleting the public IP from Linode DNS Manager...'
  resource = client.domain.resource.list(:DomainID => @domain.domainid).find{|i| i.target == ip }
  abort_with "ip address #{ip} was not found on Linode DNS!" unless resource
  client.domain.resource.delete(:DomainID => @domain.domainid, :ResourceID => resource.resourceid)
end

#verifyObject



6
7
8
9
# File 'lib/sunzi/vps/dns/linode.rb', line 6

def verify
  @domain = client.domain.list.find{|i| i.domain == @zone }
  abort_with "zone for #{@zone} was not found on Linode DNS!" unless @domain
end