Skip to content
This repository has been archived by the owner on Jul 30, 2019. It is now read-only.

Commit

Permalink
Merge pull request #87 from site5/feature/ns-ip
Browse files Browse the repository at this point in the history
Lookup nameserver IP.
  • Loading branch information
boone committed Aug 4, 2014
2 parents 4dc73db + 1c1361c commit 45ec123
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/lumberg/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Lumberg
VERSION = '2.0.0.pre18'
VERSION = '2.0.0.pre19'
end
16 changes: 16 additions & 0 deletions lib/lumberg/whm/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,22 @@ def disk_usage
request
end

# Public: Gets IP address for a given hostname.
#
# options - Hash of options (default: {})
# :host - String host name
#
# Returns a Hash API Response
def lookup_nameserver_ip(options = {})
request = perform_request('lookupnsip',
options.merge(:'api.version' => 1,
response_key: 'data'))

request[:success] = request[:params].has_key?(:ip)

request
end

def account
@account ||= Account.new(server: self)
end
Expand Down
44 changes: 44 additions & 0 deletions spec/vcr_cassettes/whm/server/lookup_nameserver_ip.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions spec/whm/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -372,5 +372,15 @@ module Lumberg
result[:success].should be_true
end
end

describe '#lookup_nameserver_ip' do
use_vcr_cassette 'whm/server/lookup_nameserver_ip'

it 'performs a NS lookup for the given host name' do
result = @whm.lookup_nameserver_ip(host: 'site5.com')

result[:params][:ip].should =~ Resolv::IPv4::Regex
end
end
end
end

0 comments on commit 45ec123

Please sign in to comment.