mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
add dynect DNS provider with session request implemented
This commit is contained in:
parent
0776800b94
commit
4906eae3df
8 changed files with 143 additions and 1 deletions
|
@ -73,3 +73,4 @@ require 'fog/bin/vcloud'
|
||||||
require 'fog/bin/virtual_box'
|
require 'fog/bin/virtual_box'
|
||||||
require 'fog/bin/voxel'
|
require 'fog/bin/voxel'
|
||||||
require 'fog/bin/zerigo'
|
require 'fog/bin/zerigo'
|
||||||
|
require 'fog/bin/dynect'
|
||||||
|
|
32
lib/fog/bin/dynect.rb
Normal file
32
lib/fog/bin/dynect.rb
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
require 'fog/dns/dynect'
|
||||||
|
|
||||||
|
class Dynect < Fog::Bin
|
||||||
|
class << self
|
||||||
|
|
||||||
|
def class_for(key)
|
||||||
|
case key
|
||||||
|
when :dns
|
||||||
|
Fog::Dynect::DNS
|
||||||
|
else
|
||||||
|
raise ArgumentError, "Unrecognized service: #{key}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def [](service)
|
||||||
|
@@connections ||= Hash.new do |hash, key|
|
||||||
|
hash[key] = case key
|
||||||
|
when :dns
|
||||||
|
Fog::DNS.new(:provider => 'Dynect')
|
||||||
|
else
|
||||||
|
raise ArgumentError, "Unrecognized service: #{service}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@@connections[service]
|
||||||
|
end
|
||||||
|
|
||||||
|
def services
|
||||||
|
[:dns]
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
|
@ -29,6 +29,9 @@ module Fog
|
||||||
when :zerigo
|
when :zerigo
|
||||||
require 'fog/dns/zerigo'
|
require 'fog/dns/zerigo'
|
||||||
Fog::DNS::Zerigo.new(attributes)
|
Fog::DNS::Zerigo.new(attributes)
|
||||||
|
when 'Dynect'
|
||||||
|
require 'fog/dns/dynect'
|
||||||
|
Fog::Dynect::DNS.new(attributes)
|
||||||
else
|
else
|
||||||
raise ArgumentError.new("#{provider} is not a recognized dns provider")
|
raise ArgumentError.new("#{provider} is not a recognized dns provider")
|
||||||
end
|
end
|
||||||
|
|
57
lib/fog/dns/dynect.rb
Normal file
57
lib/fog/dns/dynect.rb
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
module Fog
|
||||||
|
module Dynect
|
||||||
|
class DNS < Fog::Service
|
||||||
|
|
||||||
|
requires :dynect_customer, :dynect_username, :dynect_password
|
||||||
|
recognizes :timeout, :persistent
|
||||||
|
recognizes :provider # remove post deprecation
|
||||||
|
|
||||||
|
# model_path 'fog/dns/models/dynect'
|
||||||
|
# model :record
|
||||||
|
# collection :records
|
||||||
|
# model :zone
|
||||||
|
# collection :zones
|
||||||
|
|
||||||
|
request_path 'fog/dns/requests/dynect'
|
||||||
|
request :session
|
||||||
|
|
||||||
|
class Real
|
||||||
|
def initialize(options={})
|
||||||
|
@dynect_customer = options[:dynect_customer]
|
||||||
|
@dynect_username = options[:dynect_username]
|
||||||
|
@dynect_password = options[:dynect_password]
|
||||||
|
|
||||||
|
@host = "api2.dynect.net"
|
||||||
|
@port = options[:port] || 443
|
||||||
|
@scheme = options[:scheme] || 'https'
|
||||||
|
@version = options[:version] || '2.3.1'
|
||||||
|
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent] || true)
|
||||||
|
end
|
||||||
|
|
||||||
|
def request(params)
|
||||||
|
begin
|
||||||
|
params[:headers] ||= {}
|
||||||
|
params[:headers]['Content-Type'] = 'text/xml'
|
||||||
|
params[:headers]['API-Version'] = @version
|
||||||
|
response = @connection.request(params.merge!({:host => @host}))
|
||||||
|
rescue Excon::Errors::HTTPStatusError => error
|
||||||
|
raise case error
|
||||||
|
when Excon::Errors::NotFound
|
||||||
|
Fog::Dynect::DNS::NotFound.slurp(error)
|
||||||
|
else
|
||||||
|
error
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
response
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def zones
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
32
lib/fog/dns/requests/dynect/session.rb
Normal file
32
lib/fog/dns/requests/dynect/session.rb
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
module Fog
|
||||||
|
module Dynect
|
||||||
|
class DNS
|
||||||
|
class Real
|
||||||
|
def session
|
||||||
|
builder = Builder::XmlMarkup.new
|
||||||
|
xml = builder.parameters do |root|
|
||||||
|
root.customer_name(@dynect_customer)
|
||||||
|
root.user_name( @dynect_username)
|
||||||
|
root.password(@dynect_password)
|
||||||
|
end
|
||||||
|
|
||||||
|
request(
|
||||||
|
:expects => 200,
|
||||||
|
:method => "POST",
|
||||||
|
:path => "/REST/Session/",
|
||||||
|
:body => xml
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
|
||||||
|
def session
|
||||||
|
Fog::Mock.not_implemented
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -26,6 +26,9 @@ def dns_providers
|
||||||
},
|
},
|
||||||
:zerigo => {
|
:zerigo => {
|
||||||
:mocked => false
|
:mocked => false
|
||||||
|
},
|
||||||
|
Dynect => {
|
||||||
|
:mocked => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
14
tests/dns/requests/dynect/dns_tests.rb
Normal file
14
tests/dns/requests/dynect/dns_tests.rb
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
Shindo.tests('Dynect::dns | DNS requests', ['dynect', 'dns']) do
|
||||||
|
tests( 'success') do
|
||||||
|
test ('start api session') do
|
||||||
|
pending if Fog.mocking?
|
||||||
|
|
||||||
|
response = Dynect[:dns].session
|
||||||
|
if response.status == 200
|
||||||
|
@auth_token = response.body['token']
|
||||||
|
end
|
||||||
|
|
||||||
|
response.status == 200
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -8,7 +8,7 @@ def lorem_file
|
||||||
end
|
end
|
||||||
|
|
||||||
# check to see which credentials are available and add others to the skipped tags list
|
# check to see which credentials are available and add others to the skipped tags list
|
||||||
all_providers = ['aws', 'bluebox', 'brightbox', 'dnsimple', 'dnsmadeeasy', 'ecloud', 'gogrid', 'google', 'linode', 'local', 'ninefold', 'newservers', 'rackspace', 'slicehost', 'stormondemand', 'voxel', 'zerigo']
|
all_providers = ['aws', 'bluebox', 'brightbox', 'dnsimple', 'dnsmadeeasy', 'dynect', 'ecloud', 'gogrid', 'google', 'linode', 'local', 'ninefold', 'newservers', 'rackspace', 'slicehost', 'stormondemand', 'voxel', 'zerigo']
|
||||||
available_providers = Fog.available_providers.map {|provider| provider.downcase}
|
available_providers = Fog.available_providers.map {|provider| provider.downcase}
|
||||||
for provider in (all_providers - available_providers)
|
for provider in (all_providers - available_providers)
|
||||||
Formatador.display_line("[yellow]Skipping tests for [bold]#{provider}[/] [yellow]due to lacking credentials (add some to '~/.fog' to run them)[/]")
|
Formatador.display_line("[yellow]Skipping tests for [bold]#{provider}[/] [yellow]due to lacking credentials (add some to '~/.fog' to run them)[/]")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue