mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge branch 'slicehost_dns'
updated fog.gemspec to match newer version 0.3.31
This commit is contained in:
commit
41ab3c2229
18 changed files with 514 additions and 19 deletions
|
@ -514,6 +514,7 @@ Gem::Specification.new do |s|
|
|||
lib/fog/slicehost/parsers/compute/get_images.rb
|
||||
lib/fog/slicehost/parsers/compute/get_slice.rb
|
||||
lib/fog/slicehost/parsers/compute/get_slices.rb
|
||||
lib/fog/slicehost/parsers/compute/get_zones.rb
|
||||
lib/fog/slicehost/requests/compute/create_slice.rb
|
||||
lib/fog/slicehost/requests/compute/delete_slice.rb
|
||||
lib/fog/slicehost/requests/compute/get_backups.rb
|
||||
|
@ -523,6 +524,7 @@ Gem::Specification.new do |s|
|
|||
lib/fog/slicehost/requests/compute/get_images.rb
|
||||
lib/fog/slicehost/requests/compute/get_slice.rb
|
||||
lib/fog/slicehost/requests/compute/get_slices.rb
|
||||
lib/fog/slicehost/requests/compute/get_zones.rb
|
||||
lib/fog/slicehost/requests/compute/reboot_slice.rb
|
||||
lib/fog/terremark.rb
|
||||
lib/fog/terremark/bin.rb
|
||||
|
|
|
@ -24,6 +24,14 @@ module Fog
|
|||
request :get_slice
|
||||
request :get_slices
|
||||
request :reboot_slice
|
||||
request :create_zone
|
||||
request :delete_zone
|
||||
request :get_zones
|
||||
request :get_zone
|
||||
request :create_record
|
||||
request :delete_record
|
||||
request :get_records
|
||||
request :get_record
|
||||
|
||||
class Mock
|
||||
|
||||
|
|
26
lib/fog/slicehost/parsers/compute/create_record.rb
Normal file
26
lib/fog/slicehost/parsers/compute/create_record.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Slicehost
|
||||
module Compute
|
||||
|
||||
class CreateRecord < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = {}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'zone-id', 'ttl', 'id'
|
||||
@response[name] = @value.to_i
|
||||
when 'record-type', 'name', 'data', 'active', 'aux'
|
||||
@response[name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
26
lib/fog/slicehost/parsers/compute/create_zone.rb
Normal file
26
lib/fog/slicehost/parsers/compute/create_zone.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Slicehost
|
||||
module Compute
|
||||
|
||||
class CreateZone < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = {}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'ttl', 'id'
|
||||
@response[name] = @value.to_i
|
||||
when 'origin', 'active'
|
||||
@response[name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
26
lib/fog/slicehost/parsers/compute/get_record.rb
Normal file
26
lib/fog/slicehost/parsers/compute/get_record.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Slicehost
|
||||
module Compute
|
||||
|
||||
class GetRecord < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = { }
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'zone-id', 'ttl'
|
||||
@response[name] = @value.to_i
|
||||
when 'record-type', 'name', 'data', 'active', 'aux'
|
||||
@response[name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
30
lib/fog/slicehost/parsers/compute/get_records.rb
Normal file
30
lib/fog/slicehost/parsers/compute/get_records.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Slicehost
|
||||
module Compute
|
||||
|
||||
class GetRecords < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@record = {}
|
||||
@response = { 'records' => [] }
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'zone-id', 'ttl'
|
||||
@record[name] = @value.to_i
|
||||
when 'record-type', 'name', 'data', 'active', 'aux'
|
||||
@record[name] = @value
|
||||
when 'record'
|
||||
@response['records'] << @record
|
||||
@record = {}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
26
lib/fog/slicehost/parsers/compute/get_zone.rb
Normal file
26
lib/fog/slicehost/parsers/compute/get_zone.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Slicehost
|
||||
module Compute
|
||||
|
||||
class GetZone < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@response = {}
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'ttl', 'id'
|
||||
@response[name] = @value.to_i
|
||||
when 'origin', 'active'
|
||||
@response[name] = @value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
30
lib/fog/slicehost/parsers/compute/get_zones.rb
Normal file
30
lib/fog/slicehost/parsers/compute/get_zones.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
module Fog
|
||||
module Parsers
|
||||
module Slicehost
|
||||
module Compute
|
||||
|
||||
class GetZones < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@zone = {}
|
||||
@response = { 'zones' => [] }
|
||||
end
|
||||
|
||||
def end_element(name)
|
||||
case name
|
||||
when 'ttl', 'id'
|
||||
@zone[name] = @value.to_i
|
||||
when 'active', 'origin'
|
||||
@zone[name] = @value
|
||||
when 'zone'
|
||||
@response['zones'] << @zone
|
||||
@zone = {}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
61
lib/fog/slicehost/requests/compute/create_record.rb
Normal file
61
lib/fog/slicehost/requests/compute/create_record.rb
Normal file
|
@ -0,0 +1,61 @@
|
|||
module Fog
|
||||
module Slicehost
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
require 'fog/slicehost/parsers/compute/create_record'
|
||||
|
||||
# Create a new record in a DNS zone - or update an existing one
|
||||
# ==== Parameters
|
||||
# * record_type<~String> - type of DNS record to create (A, CNAME, etc)
|
||||
# * zone_id<~Integer> - ID of the zone to update
|
||||
# * name<~String> - host name this DNS record is for
|
||||
# * data<~String> - data for the DNS record (ie for an A record, the IP address)
|
||||
# * options<~Hash> - extra parameters that are not mandatory
|
||||
# * ttl<~Integer> - time to live in seconds
|
||||
# * active<~String> - whether this record is active or not ('Y' or 'N')
|
||||
# * aux<~String> - extra data required by the record
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'name'<~String> - as above
|
||||
# * 'id'<~Integer> - Id of zone/domain - used in future API calls for this zone
|
||||
# * 'ttl'<~Integer> - as above
|
||||
# * 'data'<~String> - as above
|
||||
# * 'active'<~String> - as above
|
||||
# * 'aux'<~String> - as above
|
||||
def create_record( record_type, zone_id, name, data, options = {})
|
||||
|
||||
optional_tags= ''
|
||||
options.each { |option, value|
|
||||
case option
|
||||
when :ttl
|
||||
optional_tags+= "<ttl type='integer'>#{value}</ttl>"
|
||||
when :active
|
||||
optional_tags+= "<active>#{value}</active>"
|
||||
when :aux
|
||||
optional_tags+= "<aux>#{value}</aux>"
|
||||
end
|
||||
}
|
||||
|
||||
request(
|
||||
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><record><record_type>#{record_type}</record_type><zone_id type="integer">#{zone_id}</zone_id><name>#{name}</name><data>#{data}</data>#{optional_tags}</record>},
|
||||
:expects => 201,
|
||||
:method => 'POST',
|
||||
:parser => Fog::Parsers::Slicehost::Compute::CreateRecord.new,
|
||||
:path => 'records.xml'
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def create_record( record_type, zone_id, name, data)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -5,7 +5,7 @@ module Fog
|
|||
|
||||
require 'fog/slicehost/parsers/compute/create_slice'
|
||||
|
||||
# Get list of slices
|
||||
# Create a new slice
|
||||
# ==== Parameters
|
||||
# * flavor_id<~Integer> - Id of flavor to create slice with
|
||||
# * image_id<~Integer> - Id of image to create slice with
|
||||
|
@ -13,7 +13,7 @@ module Fog
|
|||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Array>:
|
||||
# * body<~Hash>:
|
||||
# * 'addresses'<~Array> - Ip addresses for the slice
|
||||
# * 'backup-id'<~Integer> - Id of backup slice was booted from
|
||||
# * 'bw-in'<~Integer> - Incoming bandwidth total for current billing cycle, in Gigabytes
|
||||
|
|
54
lib/fog/slicehost/requests/compute/create_zone.rb
Normal file
54
lib/fog/slicehost/requests/compute/create_zone.rb
Normal file
|
@ -0,0 +1,54 @@
|
|||
module Fog
|
||||
module Slicehost
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
require 'fog/slicehost/parsers/compute/create_zone'
|
||||
|
||||
# Create a new zone for Slicehost's DNS servers to serve/host
|
||||
# ==== Parameters
|
||||
# * origin<~String> - domain name to host (ie example.com)
|
||||
# * options<~Hash> - optional paramaters
|
||||
# * ttl<~Integer> - TimeToLive (ttl) for the domain, in seconds (> 60)
|
||||
# * active<~String> - whether zone is active in Slicehost DNS server - 'Y' or 'N'
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'origin'<~String> - as above
|
||||
# * 'id'<~Integer> - Id of zone/domain - used in future API calls
|
||||
# * 'ttl'<~Integer> - as above
|
||||
# * 'active'<~String> - as above
|
||||
def create_zone(origin, options = {})
|
||||
|
||||
optional_tags= ''
|
||||
options.each { |option, value|
|
||||
case option
|
||||
when :ttl
|
||||
optional_tags+= "<ttl type='interger'>#{value}</ttl>"
|
||||
when :active
|
||||
optional_tags+= "<active>#{value}</active>"
|
||||
end
|
||||
}
|
||||
|
||||
request(
|
||||
:body => %Q{<?xml version="1.0" encoding="UTF-8"?><zone><origin>#{origin}</origin>#{optional_tags}</zone>},
|
||||
:expects => 201,
|
||||
:method => 'POST',
|
||||
:parser => Fog::Parsers::Slicehost::Compute::CreateZone.new,
|
||||
:path => 'zones.xml'
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def create_zone(origin, ttl, active)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
31
lib/fog/slicehost/requests/compute/delete_record.rb
Normal file
31
lib/fog/slicehost/requests/compute/delete_record.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
module Fog
|
||||
module Slicehost
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
# Delete a record from the specified DNS zone
|
||||
# ==== Parameters
|
||||
# * record_id<~Integer> - Id of DNS record to delete
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>: - HTTP status code will be result
|
||||
def delete_record(record_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'DELETE',
|
||||
:path => "records/#{record_id}.xml"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def delete_record(record_id)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -3,26 +3,12 @@ module Fog
|
|||
class Compute
|
||||
class Real
|
||||
|
||||
# Get list of slices
|
||||
# Delete a given slice
|
||||
# ==== Parameters
|
||||
# * flavor_id<~Integer> - Id of flavor to create slice with
|
||||
# * image_id<~Integer> - Id of image to create slice with
|
||||
# * name<~String> - Name of slice
|
||||
# * slice_id<~Integer> - Id of slice to delete
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Array>:
|
||||
# * 'addresses'<~Array> - Ip addresses for the slice
|
||||
# * 'backup-id'<~Integer> - Id of backup slice was booted from
|
||||
# * 'bw-in'<~Integer> - Incoming bandwidth total for current billing cycle, in Gigabytes
|
||||
# * 'bw-out'<~Integer> - Outgoing bandwidth total for current billing cycle, in Gigabytes
|
||||
# * 'flavor-id'<~Integer> - Id of flavor slice was booted from
|
||||
# * 'id'<~Integer> - Id of the slice
|
||||
# * 'image-id'<~Integer> - Id of image slice was booted from
|
||||
# * 'name'<~String> - Name of the slice
|
||||
# * 'progress'<~Integer> - Progress of current action, in percentage
|
||||
# * 'root-password'<~String> - Root password of slice
|
||||
# * 'status'<~String> - Current status of the slice
|
||||
# * response<~Excon::Response>: - HTTP status code is the return value
|
||||
def delete_slice(slice_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
|
|
31
lib/fog/slicehost/requests/compute/delete_zone.rb
Normal file
31
lib/fog/slicehost/requests/compute/delete_zone.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
module Fog
|
||||
module Slicehost
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
# Delete a zone from Slicehost's DNS
|
||||
# ==== Parameters
|
||||
# * zone_id<~Integer> - Id of zone to delete
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>: - HTTP status code will be result
|
||||
def delete_zone(zone_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'DELETE',
|
||||
:path => "zones/#{zone_id}.xml"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def delete_zone(zone_id)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
40
lib/fog/slicehost/requests/compute/get_record.rb
Normal file
40
lib/fog/slicehost/requests/compute/get_record.rb
Normal file
|
@ -0,0 +1,40 @@
|
|||
module Fog
|
||||
module Slicehost
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
require 'fog/slicehost/parsers/compute/get_record'
|
||||
|
||||
# Get an individual DNS record from the specified zone
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'record_type'<~String> - type of DNS record to create (A, CNAME, etc)
|
||||
# * 'zone_id'<~Integer> - ID of the zone to update
|
||||
# * 'name'<~String> - host name this DNS record is for
|
||||
# * 'data'<~String> - data for the DNS record (ie for an A record, the IP address)
|
||||
# * 'ttl'<~Integer> - time to live in seconds
|
||||
# * 'active'<~String> - whether this record is active or not ('Y' or 'N')
|
||||
# * 'aux'<~String> - extra data required by the record
|
||||
def get_record( record_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Slicehost::Compute::GetRecords.new,
|
||||
:path => "records/#{record_id}.xml"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_record(record_id)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
41
lib/fog/slicehost/requests/compute/get_records.rb
Normal file
41
lib/fog/slicehost/requests/compute/get_records.rb
Normal file
|
@ -0,0 +1,41 @@
|
|||
module Fog
|
||||
module Slicehost
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
require 'fog/slicehost/parsers/compute/get_records'
|
||||
|
||||
# Get all the DNS records across all the DNS zones for this account
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Array>:
|
||||
# * 'addresses'<~Array> - Ip addresses for the slice
|
||||
# * 'backup-id'<~Integer> - Id of backup slice was booted from
|
||||
# * 'flavor_id'<~Integer> - Id of flavor slice was booted from
|
||||
# * 'id'<~Integer> - Id of the slice
|
||||
# * 'image-id'<~Integer> - Id of image slice was booted from
|
||||
# * 'name'<~String> - Name of the slice
|
||||
# * 'progress'<~Integer> - Progress of current action, in percentage
|
||||
# * 'status'<~String> - Current status of the slice
|
||||
def get_records
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Slicehost::Compute::GetRecords.new,
|
||||
:path => "records.xml"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_records
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
40
lib/fog/slicehost/requests/compute/get_zone.rb
Normal file
40
lib/fog/slicehost/requests/compute/get_zone.rb
Normal file
|
@ -0,0 +1,40 @@
|
|||
module Fog
|
||||
module Slicehost
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
require 'fog/slicehost/parsers/compute/get_zone'
|
||||
|
||||
# Get details of a DNS zone
|
||||
#
|
||||
# ==== Parameters
|
||||
# * zone_id<~Integer> - Id of zone to lookup
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'origin'<~String> - domain name to host (ie example.com)
|
||||
# * 'id'<~Integer> - Id of the zone
|
||||
# * 'ttl'<~Integer> - TimeToLive (ttl) for the domain, in seconds (> 60)
|
||||
# * 'active'<~String> - whether zone is active in Slicehost DNS server - 'Y' or 'N'
|
||||
def get_zone(zone_id)
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Slicehost::Compute::GetZone.new,
|
||||
:path => "/zones/#{zone_id}.xml"
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_zone(zone_id)
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
37
lib/fog/slicehost/requests/compute/get_zones.rb
Normal file
37
lib/fog/slicehost/requests/compute/get_zones.rb
Normal file
|
@ -0,0 +1,37 @@
|
|||
module Fog
|
||||
module Slicehost
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
require 'fog/slicehost/parsers/compute/get_zones'
|
||||
|
||||
# Get list of all DNS zones hosted on Slicehost (for this account)
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Array>:
|
||||
# * 'origin'<~String> - domain name to host (ie example.com)
|
||||
# * 'id'<~Integer> - Id of the zone
|
||||
# * 'ttl'<~Integer> - TimeToLive (ttl) for the domain, in seconds (> 60)
|
||||
# * 'active'<~String> - whether zone is active in Slicehost DNS server - 'Y' or 'N'
|
||||
def get_zones
|
||||
request(
|
||||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:parser => Fog::Parsers::Slicehost::Compute::GetZones.new,
|
||||
:path => 'zones.xml'
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_zones
|
||||
Fog::Mock.not_implemented
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue