mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
cleaned up dns stuff
This commit is contained in:
parent
18b2de8c50
commit
608e81e0d9
18 changed files with 0 additions and 510 deletions
|
@ -1,39 +0,0 @@
|
|||
module Fog
|
||||
module HP
|
||||
class DNS
|
||||
|
||||
class Real
|
||||
def create_domain(name, email)
|
||||
data = {
|
||||
name: name,
|
||||
email:email
|
||||
}
|
||||
request(
|
||||
:body => MultiJson.encode(data),
|
||||
:expects => 200,
|
||||
:method => 'POST',
|
||||
:path => 'domains.json'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def create_domain(name,email)
|
||||
response = Excon::Response.new
|
||||
response.status = 200
|
||||
|
||||
data = {
|
||||
id : SecureRandom.uuid,
|
||||
name : "domain1.com.",
|
||||
ttl : 3600,
|
||||
serial : 1351800588,
|
||||
email : "nsadmin@example.org",
|
||||
created_at : "2012-11-01T20:09:48.094457"
|
||||
}
|
||||
response.body = data
|
||||
response
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,44 +0,0 @@
|
|||
module Fog
|
||||
module HP
|
||||
class DNS
|
||||
class Real
|
||||
def create_record(domain_id, name, type, data)
|
||||
|
||||
data = {
|
||||
name: name,
|
||||
type: type,
|
||||
data: data
|
||||
}
|
||||
|
||||
request(
|
||||
:body => MultiJson.encode(data),
|
||||
:expects => 200,
|
||||
:method => 'POST',
|
||||
:path => "domains/#{domain_id}/records"
|
||||
)
|
||||
|
||||
end
|
||||
end
|
||||
class Mock
|
||||
def create_record(domain_id, name, type, data)
|
||||
response = Excon::Response.new
|
||||
response.status = 200
|
||||
data = {
|
||||
id : "2e32e609-3a4f-45ba-bdef-e50eacd345ad",
|
||||
name : "www.example.com.",
|
||||
type : "A",
|
||||
created_at : "2012-11-02T19:56:26.366792",
|
||||
updated_at : null,
|
||||
domain_id : "89acac79-38e7-497d-807c-a011e1310438",
|
||||
ttl : 3600,
|
||||
data : "15.185.172.152",
|
||||
}
|
||||
response.body = data
|
||||
response
|
||||
response
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
module Fog
|
||||
module HP
|
||||
class DNS
|
||||
|
||||
class Real
|
||||
|
||||
# Delete a Domain
|
||||
#
|
||||
# ==== Parameters
|
||||
# * domain_id<~Integer> - Id of domain to delete
|
||||
#
|
||||
def delete_domain(domain_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'DELETE',
|
||||
:path => "domains/#{domain_id}"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
def delete_domain(domain_id)
|
||||
response = Excon::Response.new
|
||||
if image = find_domain(domain_id)
|
||||
response.status = 202
|
||||
response
|
||||
else
|
||||
response.status = 404
|
||||
raise(Excon::Errors.status_error({:expects => 200}, response))
|
||||
end
|
||||
response
|
||||
end
|
||||
|
||||
def find_domain(domain_id)
|
||||
list_domains.body['domains'].detect { |_| _['id'] == domain_id }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,44 +0,0 @@
|
|||
module Fog
|
||||
module HP
|
||||
class DNS
|
||||
class Real
|
||||
# Delete a Record
|
||||
#
|
||||
# ==== Parameters
|
||||
# * domain_id<~Integer> - Id of domain for record
|
||||
# * record_id<~Integer> - Id of record to delete
|
||||
#
|
||||
def delete_record(domain_id, record_id)
|
||||
|
||||
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'DELETE',
|
||||
:path => "domains/#{domain_id}/records/#{record_id}"
|
||||
)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def delete_record(domain_id, record_id)
|
||||
response = Excon::Response.new
|
||||
if image = find_record(domain_id,record_id)
|
||||
response.status = 200
|
||||
response
|
||||
else
|
||||
response.status = 404
|
||||
raise(Excon::Errors.status_error({:expects => 200}, response))
|
||||
end
|
||||
response
|
||||
end
|
||||
|
||||
def find_record(domain_id, record_id)
|
||||
list_records_in_a_domain(domain_id).body['records'].detect { |_| _['id'] == record_id }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,40 +0,0 @@
|
|||
module Fog
|
||||
module HP
|
||||
class DNS
|
||||
|
||||
# Get details for existing domain
|
||||
#
|
||||
# ==== Parameters
|
||||
# * instance_id<~Integer> - Id of the domain to get
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# *TBD
|
||||
class Real
|
||||
def get_domain(instance_id)
|
||||
response = request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:path => "domains/#{instance_id}",
|
||||
)
|
||||
response
|
||||
end
|
||||
end
|
||||
class Mock
|
||||
|
||||
def get_domain(instance_id)
|
||||
response = Excon::Response.new
|
||||
if domain = find_domain(instance_id)
|
||||
response.status = 200
|
||||
response.body = {'domain' => domain}
|
||||
response
|
||||
else
|
||||
response.status = 400
|
||||
raise(Excon::Errors.status_error({:expects => 200}, response))
|
||||
end
|
||||
response
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,34 +0,0 @@
|
|||
module Fog
|
||||
module HP
|
||||
class DNS
|
||||
class Real
|
||||
def get_record(domain_id,record_id)
|
||||
response = request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:path => "domains/#{domain_id}/records/#{record_id}",
|
||||
)
|
||||
response
|
||||
end
|
||||
end
|
||||
class Mock
|
||||
def get_record(domain_id,record_id)
|
||||
if record = find_record(domain_id,record_id)
|
||||
response.status = 200
|
||||
response.body = record
|
||||
response
|
||||
else
|
||||
response.status = 400
|
||||
raise(Excon::Errors.status_error({:expects => 200}, response))
|
||||
end
|
||||
|
||||
response
|
||||
end
|
||||
|
||||
def find_record(domain_id, record_id)
|
||||
list_records_in_a_domain(domain_id).body['records'].detect { |_| _['id'] == record_id }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,40 +0,0 @@
|
|||
module Fog
|
||||
module HP
|
||||
class DNS
|
||||
class Real
|
||||
# Get servers for existing domain
|
||||
#
|
||||
# ==== Parameters
|
||||
# * instance_id<~Integer> - Id of the domain with servers
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# *TBD
|
||||
def get_servers_hosting_domain(instance_id)
|
||||
request(
|
||||
:expects => [200, 203],
|
||||
:method => 'GET',
|
||||
:path => "domains/#{instance_id}/servers.json"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_servers_hosting_domain(instance_id)
|
||||
if domain = find_domain(instance_id)
|
||||
response.status = 200
|
||||
response.body = {'domain' => domain}
|
||||
response
|
||||
else
|
||||
response.status = 400
|
||||
raise(Excon::Errors.status_error({:expects => 200}, response))
|
||||
end
|
||||
response
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,33 +0,0 @@
|
|||
module Fog
|
||||
module HP
|
||||
module DNS
|
||||
class Real
|
||||
# List all flavors (IDs and names only)
|
||||
|
||||
def list_domains
|
||||
request(
|
||||
:expects => [200],
|
||||
:method => 'GET',
|
||||
:path => 'domains',
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
def list_domains
|
||||
response = Excon::Response.new
|
||||
response.status = 200
|
||||
response.body = {
|
||||
"domains" => [
|
||||
{ "name" => "domain1.com.", "created_at" => "2012-11-01T20:11:08.000000", "email" => "nsadmin@example.org", "ttl" => 3600, "serial" => 1351800668, "id" => "09494b72-b65b-4297-9efb-187f65a0553e" },
|
||||
{ "name" => "domain2.com.", "created_at" => "2012-11-01T20:09:48.000000", "email" => "nsadmin@example.org", "ttl" => 3600, "serial" => 1351800588, "id" => "89acac79-38e7-497d-807c-a011e1310438" }
|
||||
]
|
||||
}
|
||||
response
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,50 +0,0 @@
|
|||
module Fog
|
||||
module HP
|
||||
class DNS
|
||||
class Real
|
||||
def list_records_in_a_domain(domain_id)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
class Mock
|
||||
def list_records_in_a_domain(domain_id)
|
||||
response = Excon::Response.new
|
||||
response.status = 200
|
||||
response.body = {
|
||||
"records" => [
|
||||
{
|
||||
"id" => "2e32e609-3a4f-45ba-bdef-e50eacd345ad",
|
||||
"name" => "www.example.com.",
|
||||
"type" => "A",
|
||||
"ttl" => 3600,
|
||||
"created_at" => "2012-11-02T19:56:26.000000",
|
||||
"updated_at" => "2012-11-04T13:22:36.000000",
|
||||
"data" => "15.185.172.153",
|
||||
"domain_id" => "89acac79-38e7-497d-807c-a011e1310438",
|
||||
"tenant_id" => null,
|
||||
"priority" => null,
|
||||
"version" => 1,
|
||||
},
|
||||
{
|
||||
"id" => "8e9ecf3e-fb92-4a3a-a8ae-7596f167bea3",
|
||||
"name" => "host1.example.com.",
|
||||
"type" => "A",
|
||||
"ttl" => 3600,
|
||||
"created_at" => "2012-11-04T13:57:50.000000",
|
||||
"updated_at" => null,
|
||||
"data" => "15.185.172.154",
|
||||
"domain_id" => "89acac79-38e7-497d-807c-a011e1310438",
|
||||
"tenant_id" => null,
|
||||
"priority" => null,
|
||||
"version" => 1
|
||||
}
|
||||
]
|
||||
}
|
||||
response
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,33 +0,0 @@
|
|||
module Fog
|
||||
module HP
|
||||
class DNS
|
||||
|
||||
class Real
|
||||
def update_domain(domain_id,options)
|
||||
request(
|
||||
:body => MultiJson.encode(options),
|
||||
:expects => 200,
|
||||
:method => 'PUT',
|
||||
:path => "domains/#{domain_id}"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def update_domain(domain_id, options)
|
||||
response = Excon::Response.new
|
||||
if domain = list_domains.body['domains'].detect { |_| _['id'] == domain_id }
|
||||
if options['name']
|
||||
domain['name'] = options['name']
|
||||
end
|
||||
response.status = 200
|
||||
response.body = domain
|
||||
response
|
||||
else
|
||||
raise Fog::HP::DNS::NotFound
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,39 +0,0 @@
|
|||
module Fog
|
||||
module HP
|
||||
class DNS
|
||||
|
||||
class Real
|
||||
def update_record(domain_id, record_id, options)
|
||||
request(
|
||||
:body => MultiJson.encode(options),
|
||||
:expects => 200,
|
||||
:method => 'PUT',
|
||||
:path => "domains/#{domain_id}/records/#{record_id}"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
def update_record(domain_id , record_id, options)
|
||||
if record = find_record(domain_id, record_id)
|
||||
if options['name']
|
||||
domain['name'] = options['name']
|
||||
end
|
||||
response.status = 200
|
||||
response.body = record
|
||||
response
|
||||
else
|
||||
raise Fog::HP::DNS::NotFound
|
||||
end
|
||||
response
|
||||
end
|
||||
|
||||
def find_record(domain_id, record_id)
|
||||
list_records_in_a_domain(domain_id).body['records'].detect { |_| _['id'] == record_id }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,17 +0,0 @@
|
|||
Shindo.tests("HP::DNS | create domain tests", ['hp', 'dns', 'domain']) do
|
||||
|
||||
@create_format = {
|
||||
"id " => String,
|
||||
"name" => String,
|
||||
"ttl" => Integer,
|
||||
"serial" => Integer,
|
||||
"email" => String,
|
||||
"created_at" => String
|
||||
}
|
||||
|
||||
tests('success') do
|
||||
tests("#create_domain").formats(@create_format) do
|
||||
HP[:dns].create_domain_now("name","joe@blow.com")
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
Shindo.tests("HP::DNS | delete domain tests", ['hp', 'dns', 'domain']) do
|
||||
tests('success') do
|
||||
|
||||
end
|
||||
tests('failure') do
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
Shindo.tests("HP::DNS | get domain tests", ['hp', 'dns', 'domain']) do
|
||||
tests('success') do
|
||||
|
||||
end
|
||||
tests('failure') do
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
Shindo.tests("HP::DNS | get servers hosting domain tests", ['hp', 'dns', 'domain']) do
|
||||
tests('success') do
|
||||
|
||||
end
|
||||
tests('failure') do
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
Shindo.tests("HP::DNS | list domains tests", ['hp', 'dns', 'domain']) do
|
||||
tests('success') do
|
||||
|
||||
end
|
||||
tests('failure') do
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
Shindo.tests("HP::DNS | list records tests", ['hp', 'dns', 'records']) do
|
||||
tests('success') do
|
||||
|
||||
end
|
||||
tests('failure') do
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
Shindo.tests("HP::DNS | list records tests", ['hp', 'dns', 'domains']) do
|
||||
tests('success') do
|
||||
|
||||
end
|
||||
tests('failure') do
|
||||
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in a new issue