-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[slicehost|dns] give dns its own namespace/service
- Loading branch information
Showing
21 changed files
with
129 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
module Fog | ||
module Slicehost | ||
class DNS < Fog::Service | ||
|
||
requires :slicehost_password | ||
recognizes :host, :port, :scheme, :persistent | ||
|
||
model_path 'fog/slicehost/models/dns' | ||
|
||
request_path 'fog/slicehost/requests/dns' | ||
request :create_record | ||
request :create_zone | ||
request :delete_record | ||
request :delete_zone | ||
request :get_record | ||
request :get_records | ||
request :get_zone | ||
request :get_zones | ||
|
||
class Mock | ||
|
||
def self.data | ||
@data ||= Hash.new do |hash, key| | ||
hash[key] = {} | ||
end | ||
end | ||
|
||
def self.reset_data(keys=data.keys) | ||
for key in [*keys] | ||
data.delete(key) | ||
end | ||
end | ||
|
||
def initialize(options={}) | ||
@slicehost_password = options[:slicehost_password] | ||
@data = self.class.data[@slicehost_password] | ||
end | ||
|
||
end | ||
|
||
class Real | ||
|
||
def initialize(options={}) | ||
@slicehost_password = options[:slicehost_password] | ||
@host = options[:host] || "api.slicehost.com" | ||
@port = options[:port] || 443 | ||
@scheme = options[:scheme] || 'https' | ||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent]) | ||
end | ||
|
||
def reload | ||
@connection.reset | ||
end | ||
|
||
def request(params) | ||
params[:headers] ||= {} | ||
params[:headers].merge!({ | ||
'Authorization' => "Basic #{Base64.encode64(@slicehost_password).delete("\r\n")}" | ||
}) | ||
case params[:method] | ||
when 'DELETE', 'GET', 'HEAD' | ||
params[:headers]['Accept'] = 'application/xml' | ||
when 'POST', 'PUT' | ||
params[:headers]['Content-Type'] = 'application/xml' | ||
end | ||
|
||
begin | ||
response = @connection.request(params.merge!({:host => @host})) | ||
rescue Excon::Errors::HTTPStatusError => error | ||
raise case error | ||
when Excon::Errors::NotFound | ||
Fog::Slicehost::DNS::NotFound.slurp(error) | ||
else | ||
error | ||
end | ||
end | ||
|
||
response | ||
end | ||
|
||
end | ||
end | ||
end | ||
end |
2 changes: 1 addition & 1 deletion
2
...licehost/parsers/compute/create_record.rb → ...og/slicehost/parsers/dns/create_record.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
module Fog | ||
module Parsers | ||
module Slicehost | ||
module Compute | ||
module DNS | ||
|
||
class CreateRecord < Fog::Parsers::Base | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
.../slicehost/parsers/compute/create_zone.rb → lib/fog/slicehost/parsers/dns/create_zone.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
module Fog | ||
module Parsers | ||
module Slicehost | ||
module Compute | ||
module DNS | ||
|
||
class CreateZone < Fog::Parsers::Base | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
...g/slicehost/parsers/compute/get_record.rb → lib/fog/slicehost/parsers/dns/get_record.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
module Fog | ||
module Parsers | ||
module Slicehost | ||
module Compute | ||
module DNS | ||
|
||
class GetRecord < Fog::Parsers::Base | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
.../slicehost/parsers/compute/get_records.rb → lib/fog/slicehost/parsers/dns/get_records.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
module Fog | ||
module Parsers | ||
module Slicehost | ||
module Compute | ||
module DNS | ||
|
||
class GetRecords < Fog::Parsers::Base | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
...fog/slicehost/parsers/compute/get_zone.rb → lib/fog/slicehost/parsers/dns/get_zone.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
module Fog | ||
module Parsers | ||
module Slicehost | ||
module Compute | ||
module DNS | ||
|
||
class GetZone < Fog::Parsers::Base | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
...og/slicehost/parsers/compute/get_zones.rb → lib/fog/slicehost/parsers/dns/get_zones.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
module Fog | ||
module Parsers | ||
module Slicehost | ||
module Compute | ||
module DNS | ||
|
||
class GetZones < Fog::Parsers::Base | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...icehost/requests/compute/delete_record.rb → ...g/slicehost/requests/dns/delete_record.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module Fog | ||
module Slicehost | ||
class Compute | ||
class DNS | ||
class Real | ||
|
||
# Delete a record from the specified DNS zone | ||
|
2 changes: 1 addition & 1 deletion
2
...slicehost/requests/compute/delete_zone.rb → ...fog/slicehost/requests/dns/delete_zone.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module Fog | ||
module Slicehost | ||
class Compute | ||
class DNS | ||
class Real | ||
|
||
# Delete a zone from Slicehost's DNS | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.