fog 0.3.34 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +6 -6
- data/README.rdoc +26 -7
- data/Rakefile +7 -1
- data/examples/dns_tests.rb +76 -0
- data/examples/{storage.rb → storage_tests.rb} +15 -15
- data/fog.gemspec +4 -4
- data/lib/fog.rb +1 -1
- data/lib/fog/aws.rb +19 -54
- data/lib/fog/aws/dns.rb +5 -1
- data/lib/fog/aws/models/compute/security_group.rb +128 -0
- data/lib/fog/aws/models/dns/record.rb +64 -0
- data/lib/fog/aws/models/dns/records.rb +47 -0
- data/lib/fog/aws/models/dns/zone.rb +53 -0
- data/lib/fog/aws/models/dns/zones.rb +33 -0
- data/lib/fog/aws/models/storage/file.rb +14 -2
- data/lib/fog/aws/parsers/dns/create_hosted_zone.rb +1 -1
- data/lib/fog/aws/parsers/dns/list_hosted_zones.rb +3 -1
- data/lib/fog/aws/requests/simpledb/create_domain.rb +1 -0
- data/lib/fog/aws/requests/simpledb/delete_attributes.rb +0 -2
- data/lib/fog/aws/requests/simpledb/delete_domain.rb +1 -0
- data/lib/fog/aws/requests/simpledb/domain_metadata.rb +1 -0
- data/lib/fog/aws/requests/simpledb/get_attributes.rb +1 -0
- data/lib/fog/aws/requests/simpledb/list_domains.rb +3 -2
- data/lib/fog/aws/requests/simpledb/put_attributes.rb +2 -2
- data/lib/fog/aws/requests/simpledb/select.rb +1 -0
- data/lib/fog/brightbox/compute.rb +9 -0
- data/lib/fog/brightbox/models/compute/load_balancer.rb +50 -0
- data/lib/fog/brightbox/models/compute/load_balancers.rb +28 -0
- data/lib/fog/brightbox/requests/compute/add_nodes_load_balancer.rb +28 -0
- data/lib/fog/brightbox/requests/compute/create_load_balancer.rb +27 -0
- data/lib/fog/brightbox/requests/compute/destroy_load_balancer.rb +28 -0
- data/lib/fog/brightbox/requests/compute/get_load_balancer.rb +28 -0
- data/lib/fog/brightbox/requests/compute/list_load_balancers.rb +27 -0
- data/lib/fog/brightbox/requests/compute/remove_nodes_load_balancer.rb +28 -0
- data/lib/fog/brightbox/requests/compute/update_load_balancer.rb +29 -0
- data/lib/fog/core.rb +1 -0
- data/lib/fog/core/dns.rb +25 -0
- data/lib/fog/core/mock.rb +34 -0
- data/lib/fog/google/models/storage/file.rb +14 -2
- data/lib/fog/linode/dns.rb +4 -0
- data/lib/fog/linode/models/dns/record.rb +69 -0
- data/lib/fog/linode/models/dns/records.rb +37 -0
- data/lib/fog/linode/models/dns/zone.rb +84 -0
- data/lib/fog/linode/models/dns/zones.rb +29 -0
- data/lib/fog/linode/requests/dns/domain_create.rb +2 -3
- data/lib/fog/linode/requests/dns/domain_resource_create.rb +3 -4
- data/lib/fog/linode/requests/dns/domain_resource_list.rb +5 -2
- data/lib/fog/linode/requests/dns/domain_resource_update.rb +2 -2
- data/lib/fog/linode/requests/dns/domain_update.rb +2 -2
- data/lib/fog/rackspace/requests/compute/create_image.rb +1 -1
- data/lib/fog/rackspace/requests/compute/create_server.rb +1 -1
- data/lib/fog/rackspace/requests/compute/get_flavor_details.rb +19 -1
- data/lib/fog/rackspace/requests/compute/list_flavors.rb +14 -1
- data/lib/fog/rackspace/requests/compute/list_flavors_detail.rb +14 -1
- data/lib/fog/slicehost/bin.rb +1 -1
- data/lib/fog/slicehost/dns.rb +4 -0
- data/lib/fog/slicehost/models/dns/record.rb +66 -0
- data/lib/fog/slicehost/models/dns/records.rb +36 -0
- data/lib/fog/slicehost/models/dns/zone.rb +69 -0
- data/lib/fog/slicehost/models/dns/zones.rb +28 -0
- data/lib/fog/slicehost/requests/dns/create_record.rb +2 -3
- data/lib/fog/slicehost/requests/dns/get_record.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud.rb +1 -1
- data/lib/fog/zerigo/models/dns/record.rb +14 -3
- data/lib/fog/zerigo/models/dns/records.rb +1 -1
- data/lib/fog/zerigo/models/dns/zone.rb +7 -1
- data/lib/fog/zerigo/models/dns/zones.rb +1 -1
- data/spec/spec_helper.rb +0 -24
- data/tests/aws/requests/iam/helper.rb +15 -0
- data/tests/aws/requests/simpledb/attributes_tests.rb +75 -0
- data/tests/aws/requests/simpledb/domain_tests.rb +51 -0
- data/tests/aws/requests/simpledb/helper.rb +16 -0
- data/tests/compute/helper.rb +36 -0
- data/tests/compute/models/flavors_tests.rb +9 -0
- data/tests/compute/models/server_tests.rb +9 -0
- data/tests/compute/models/servers_tests.rb +9 -0
- data/tests/{aws/requests/compute → compute/requests/aws}/address_tests.rb +0 -0
- data/tests/{aws/requests/compute → compute/requests/aws}/availability_zone_tests.rb +0 -0
- data/tests/{aws → compute/requests/aws}/helper.rb +0 -12
- data/tests/{aws/requests/compute → compute/requests/aws}/image_tests.rb +0 -0
- data/tests/{aws/requests/compute → compute/requests/aws}/instance_tests.rb +0 -0
- data/tests/{aws/requests/compute → compute/requests/aws}/key_pair_tests.rb +0 -0
- data/tests/{aws/requests/compute → compute/requests/aws}/region_tests.rb +0 -0
- data/tests/{aws/requests/compute → compute/requests/aws}/security_group_tests.rb +0 -0
- data/tests/{aws/requests/compute → compute/requests/aws}/snapshot_tests.rb +0 -0
- data/tests/{aws/requests/compute → compute/requests/aws}/tag_tests.rb +0 -0
- data/tests/{aws/requests/compute → compute/requests/aws}/volume_tests.rb +0 -0
- data/tests/{bluebox/requests/compute → compute/requests/bluebox}/block_tests.rb +0 -0
- data/tests/{bluebox → compute/requests/bluebox}/helper.rb +0 -0
- data/tests/{bluebox/requests/compute → compute/requests/bluebox}/product_tests.rb +0 -0
- data/tests/{bluebox/requests/compute → compute/requests/bluebox}/template_tests.rb +0 -0
- data/tests/{brightbox/requests/compute → compute/requests/brightbox}/account_tests.rb +0 -0
- data/tests/{brightbox/requests/compute → compute/requests/brightbox}/api_client_tests.rb +0 -0
- data/tests/{brightbox/requests/compute → compute/requests/brightbox}/cloud_ip_tests.rb +15 -7
- data/tests/{brightbox → compute/requests/brightbox}/helper.rb +68 -22
- data/tests/{brightbox/requests/compute → compute/requests/brightbox}/image_tests.rb +0 -0
- data/tests/{brightbox/requests/compute → compute/requests/brightbox}/interface_tests.rb +0 -0
- data/tests/compute/requests/brightbox/load_balancer_tests.rb +74 -0
- data/tests/{brightbox/requests/compute → compute/requests/brightbox}/server_tests.rb +1 -0
- data/tests/{brightbox/requests/compute → compute/requests/brightbox}/server_type_tests.rb +1 -0
- data/tests/{brightbox/requests/compute → compute/requests/brightbox}/user_tests.rb +0 -0
- data/tests/{brightbox/requests/compute → compute/requests/brightbox}/zone_tests.rb +1 -0
- data/tests/{go_grid/requests/compute → compute/requests/go_grid}/image_tests.rb +0 -0
- data/tests/{linode/requests/compute → compute/requests/linode}/datacenter_tests.rb +0 -0
- data/tests/{linode/requests/compute → compute/requests/linode}/distribution_tests.rb +0 -0
- data/tests/{linode → compute/requests/linode}/helper.rb +0 -0
- data/tests/{linode/requests/compute → compute/requests/linode}/linode_tests.rb +0 -0
- data/tests/{linode/requests/compute → compute/requests/linode}/linodeplans_tests.rb +0 -0
- data/tests/{rackspace/requests/compute → compute/requests/rackspace}/address_tests.rb +0 -0
- data/tests/{rackspace/requests/compute → compute/requests/rackspace}/flavor_tests.rb +0 -0
- data/tests/{rackspace → compute/requests/rackspace}/helper.rb +0 -0
- data/tests/{rackspace/requests/compute → compute/requests/rackspace}/image_tests.rb +7 -9
- data/tests/compute/requests/rackspace/resize_tests.rb +33 -0
- data/tests/{rackspace/requests/compute → compute/requests/rackspace}/server_tests.rb +0 -0
- data/tests/{slicehost/requests/compute → compute/requests/slicehost}/backup_tests.rb +0 -0
- data/tests/{slicehost/requests/compute → compute/requests/slicehost}/flavor_tests.rb +0 -0
- data/tests/{slicehost/requests/compute → compute/requests/slicehost}/image_tests.rb +0 -0
- data/tests/{slicehost/requests/compute → compute/requests/slicehost}/slice_tests.rb +0 -0
- data/tests/dns/helper.rb +19 -0
- data/tests/dns/models/record_tests.rb +25 -0
- data/tests/dns/models/records_tests.rb +25 -0
- data/tests/dns/models/zone_tests.rb +13 -0
- data/tests/dns/models/zones_tests.rb +13 -0
- data/tests/{aws/requests/dns → dns/requests/aws}/dns_tests.rb +0 -0
- data/tests/{linode/requests/dns → dns/requests/linode}/dns_tests.rb +0 -0
- data/tests/{slicehost/requests/dns_tests → dns/requests/slicehost}/dns_tests.rb +0 -0
- data/tests/{zerigo/requests/dns → dns/requests/zerigo}/dns_tests.rb +0 -0
- data/tests/helper.rb +1 -100
- data/tests/helpers/{collection_tests.rb → collection_helper.rb} +0 -0
- data/tests/helpers/compute/{flavors_tests.rb → flavors_helper.rb} +0 -0
- data/tests/helpers/compute/{server_tests.rb → server_helper.rb} +0 -0
- data/tests/helpers/compute/{servers_tests.rb → servers_helper.rb} +0 -0
- data/tests/helpers/formats_helper.rb +68 -0
- data/tests/{helper_tests.rb → helpers/formats_helper_tests.rb} +0 -0
- data/tests/helpers/{model_tests.rb → model_helper.rb} +0 -0
- data/tests/helpers/responds_to_helper.rb +13 -0
- data/tests/helpers/succeeds_helper.rb +12 -0
- data/tests/storage/helper.rb +16 -0
- data/tests/storage/models/directories_tests.rb +13 -0
- data/tests/storage/models/directory_test.rb +24 -0
- data/tests/storage/models/file_tests.rb +41 -0
- data/tests/storage/models/files_tests.rb +26 -0
- data/tests/{aws/requests/storage → storage/requests/aws}/bucket_tests.rb +0 -0
- data/tests/{aws/requests/storage → storage/requests/aws}/multipart_upload_tests.rb +0 -0
- data/tests/{aws/requests/storage → storage/requests/aws}/object_tests.rb +0 -0
- data/tests/{google/requests/storage → storage/requests/google}/bucket_tests.rb +0 -0
- data/tests/{google/requests/storage → storage/requests/google}/object_tests.rb +0 -0
- data/tests/{rackspace/requests/storage → storage/requests/rackspace}/container_tests.rb +0 -0
- data/tests/{rackspace/requests/storage → storage/requests/rackspace}/object_tests.rb +0 -0
- metadata +195 -224
- data/examples/bluebox_create.rb +0 -33
- data/examples/dns_methods.rb +0 -389
- data/spec/aws/requests/simpledb/batch_put_attributes_spec.rb +0 -31
- data/spec/aws/requests/simpledb/create_domain_spec.rb +0 -29
- data/spec/aws/requests/simpledb/delete_attributes_spec.rb +0 -39
- data/spec/aws/requests/simpledb/delete_domain_spec.rb +0 -28
- data/spec/aws/requests/simpledb/domain_metadata_spec.rb +0 -52
- data/spec/aws/requests/simpledb/get_attributes_spec.rb +0 -67
- data/spec/aws/requests/simpledb/list_domains_spec.rb +0 -30
- data/spec/aws/requests/simpledb/put_attributes_spec.rb +0 -49
- data/spec/aws/requests/simpledb/select_spec.rb +0 -27
- data/tests/aws/models/compute/flavors_tests.rb +0 -5
- data/tests/aws/models/compute/server_tests.rb +0 -6
- data/tests/aws/models/compute/servers_tests.rb +0 -6
- data/tests/aws/models/storage/directories_tests.rb +0 -5
- data/tests/aws/models/storage/directory_tests.rb +0 -5
- data/tests/aws/models/storage/file_tests.rb +0 -5
- data/tests/aws/models/storage/files_tests.rb +0 -5
- data/tests/bluebox/models/compute/flavors_tests.rb +0 -5
- data/tests/bluebox/models/compute/server_tests.rb +0 -5
- data/tests/bluebox/models/compute/servers_tests.rb +0 -6
- data/tests/brightbox/models/compute/flavors_tests.rb +0 -5
- data/tests/brightbox/models/compute/server_tests.rb +0 -6
- data/tests/brightbox/models/compute/servers_tests.rb +0 -6
- data/tests/go_grid/helper.rb +0 -0
- data/tests/google/models/storage/directories_tests.rb +0 -5
- data/tests/google/models/storage/directory_tests.rb +0 -5
- data/tests/google/models/storage/file_tests.rb +0 -5
- data/tests/google/models/storage/files_tests.rb +0 -5
- data/tests/helpers/storage/directories_tests.rb +0 -7
- data/tests/helpers/storage/directory_tests.rb +0 -18
- data/tests/helpers/storage/file_tests.rb +0 -27
- data/tests/helpers/storage/files_tests.rb +0 -13
- data/tests/local/models/storage/directories_tests.rb +0 -5
- data/tests/local/models/storage/directory_tests.rb +0 -5
- data/tests/local/models/storage/file_tests.rb +0 -5
- data/tests/local/models/storage/files_tests.rb +0 -5
- data/tests/rackspace/models/compute/flavors_tests.rb +0 -5
- data/tests/rackspace/models/compute/server_tests.rb +0 -6
- data/tests/rackspace/models/compute/servers_tests.rb +0 -6
- data/tests/rackspace/models/storage/directories_tests.rb +0 -5
- data/tests/rackspace/models/storage/directory_tests.rb +0 -5
- data/tests/rackspace/models/storage/file_tests.rb +0 -5
- data/tests/rackspace/models/storage/files_tests.rb +0 -5
- data/tests/rackspace/requests/compute/resize_tests.rb +0 -47
- data/tests/slicehost/helper.rb +0 -1
- data/tests/slicehost/models/compute/flavors_tests.rb +0 -5
- data/tests/slicehost/models/compute/server_tests.rb +0 -6
- data/tests/slicehost/models/compute/servers_tests.rb +0 -6
- data/tests/zerigo/helper.rb +0 -0
data/examples/bluebox_create.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# For example only - you'd want to use your own AMI id.
|
4
|
-
unless defined?(GENTOO_AMI)
|
5
|
-
GENTOO_AMI = 'ami-5ee70037'
|
6
|
-
end
|
7
|
-
|
8
|
-
require 'rubygems'
|
9
|
-
require 'fog'
|
10
|
-
|
11
|
-
@bluebox_api_key = "CHANGEME"
|
12
|
-
@aws_access_key_id = "CHANGEME"
|
13
|
-
@aws_secret_access_key = "CHANGEME"
|
14
|
-
|
15
|
-
@flavor_id = "94fd37a7-2606-47f7-84d5-9000deda52ae" # Block 1GB Virtual Server
|
16
|
-
@image_id = "03807e08-a13d-44e4-b011-ebec7ef2c928" # Ubuntu 10.04 x64 LTS
|
17
|
-
|
18
|
-
# Grab our current list of servers
|
19
|
-
@bbg_servers = Fog::Bluebox.new(:bluebox_api_key => @bluebox_api_key).servers
|
20
|
-
@ec2_servers = Fog::AWS::EC2.new(:aws_access_key_id => @aws_access_key_id, :aws_secret_access_key => @aws_secret_access_key).servers
|
21
|
-
|
22
|
-
# Create a new server.
|
23
|
-
@server = @bbg_servers.new(:flavor_id => @flavor_id, :image_id => @image_id,
|
24
|
-
:name => "My Server", :password => "MyPassword")
|
25
|
-
|
26
|
-
# Save the server, triggering its creation
|
27
|
-
@server.save
|
28
|
-
|
29
|
-
if @server.status == 'error'
|
30
|
-
# The create failed - create a new server on Amazon instead
|
31
|
-
@server = @ec2_servers.new(:image_id => GENTOO_AMI)
|
32
|
-
@server.save
|
33
|
-
end
|
data/examples/dns_methods.rb
DELETED
@@ -1,389 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require File.join(File.dirname(File.expand_path(__FILE__)), '..', 'lib', 'fog')
|
5
|
-
require 'fog/core/bin'
|
6
|
-
|
7
|
-
#mark true for each cloud you wish to enable/run the sample for
|
8
|
-
RUN_AWS_SAMPLE = true
|
9
|
-
RUN_LINODE_SAMPLE = false
|
10
|
-
RUN_SLICEHOST_SAMPLE = false
|
11
|
-
RUN_ZERIGO_SAMPLE = false
|
12
|
-
|
13
|
-
#domain to use in examples
|
14
|
-
TEST_DOMAIN = 'test-343246324434.com'
|
15
|
-
|
16
|
-
# example of how to use AWS Route 53 DNS calls
|
17
|
-
def show_aws_dns_usage
|
18
|
-
|
19
|
-
begin
|
20
|
-
|
21
|
-
#use to keep track of zone we create
|
22
|
-
zone_id= nil
|
23
|
-
|
24
|
-
# see if domain is already hosted on AWS
|
25
|
-
# important to check as AWS will let you create multiple zones with the same domain name
|
26
|
-
options= { :max_items => 200 }
|
27
|
-
response = AWS[:dns].list_hosted_zones( options)
|
28
|
-
if response.status == 200
|
29
|
-
zones = response.body['HostedZones']
|
30
|
-
zones.each { |zone|
|
31
|
-
domain_name = zone['Name']
|
32
|
-
if domain_name.chop == TEST_DOMAIN
|
33
|
-
zone_id = zone['Id'].sub('/hostedzone/', '')
|
34
|
-
end
|
35
|
-
}
|
36
|
-
end
|
37
|
-
|
38
|
-
#if domain not yet created, do so now
|
39
|
-
if zone_id.nil?
|
40
|
-
options= { :comment => 'test domain - not for production use' }
|
41
|
-
response = AWS[:dns].create_hosted_zone( TEST_DOMAIN, options)
|
42
|
-
if response.status == 201
|
43
|
-
zone_id = response.body['HostedZone']['Id']
|
44
|
-
change_id = response.body['ChangeInfo']['Id']
|
45
|
-
status = response.body['ChangeInfo']['Status']
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
#get details about zone including name servers (which AWS adds automatically)
|
50
|
-
response = AWS[:dns].get_hosted_zone( zone_id)
|
51
|
-
if response.status == 200
|
52
|
-
zone_info = response.body['HostedZone']
|
53
|
-
name_servers = response.body['NameServers']
|
54
|
-
num_ns_servers = name_servers.count
|
55
|
-
end
|
56
|
-
|
57
|
-
#add an A record for www
|
58
|
-
change_batch = []
|
59
|
-
host = 'www.' + TEST_DOMAIN
|
60
|
-
ip_addr = '1.2.3.4'
|
61
|
-
record = { :name => host, :type => 'A', :resource_records => [ip_addr], :ttl => 3600 }
|
62
|
-
|
63
|
-
resource_record_set = record.merge( :action => 'CREATE' )
|
64
|
-
change_batch << resource_record_set
|
65
|
-
options = { :comment => 'add A record for www'}
|
66
|
-
response = AWS[:dns].change_resource_record_sets( zone_id, change_batch, options)
|
67
|
-
if response.status == 200
|
68
|
-
change_id = response.body['Id']
|
69
|
-
status = response.body['Status']
|
70
|
-
end
|
71
|
-
|
72
|
-
debugger
|
73
|
-
|
74
|
-
#wait until new zone is live across all name servers
|
75
|
-
while status == 'PENDING'
|
76
|
-
sleep 2
|
77
|
-
response = AWS[:dns].get_change( change_id)
|
78
|
-
if response.status == 200
|
79
|
-
change_id = response.body['Id']
|
80
|
-
status = response.body['Status']
|
81
|
-
end
|
82
|
-
puts "your changes are #{status}"
|
83
|
-
end
|
84
|
-
|
85
|
-
# get resource records for zone
|
86
|
-
response = AWS[:dns].list_resource_record_sets( zone_id)
|
87
|
-
if response.status == 200
|
88
|
-
record_sets= response.body['ResourceRecordSets']
|
89
|
-
num_records= record_sets.count
|
90
|
-
end
|
91
|
-
|
92
|
-
#now delete record for www
|
93
|
-
resource_record_set = record.merge( :action => 'DELETE' )
|
94
|
-
change_batch = []
|
95
|
-
change_batch << resource_record_set
|
96
|
-
options = { :comment => 'remove A record for www'}
|
97
|
-
response = AWS[:dns].change_resource_record_sets( zone_id, change_batch, options)
|
98
|
-
if response.status == 200
|
99
|
-
change_id = response.body['Id']
|
100
|
-
status = response.body['Status']
|
101
|
-
end
|
102
|
-
|
103
|
-
#delete the zone
|
104
|
-
response = AWS[:dns].delete_hosted_zone( zone_id)
|
105
|
-
if response.status == 200
|
106
|
-
change_id = response.body['ChangeInfo']['Id']
|
107
|
-
end
|
108
|
-
|
109
|
-
|
110
|
-
rescue
|
111
|
-
#opps, ran into a problem
|
112
|
-
puts $!.message
|
113
|
-
return false
|
114
|
-
end
|
115
|
-
|
116
|
-
true
|
117
|
-
end
|
118
|
-
|
119
|
-
|
120
|
-
# example of how to use Linode DNS calls
|
121
|
-
def show_linode_dns_usage
|
122
|
-
|
123
|
-
begin
|
124
|
-
|
125
|
-
#create a zone for a domain
|
126
|
-
type = 'master'
|
127
|
-
options = { :SOA_email => 'netops@sample-domain.com', :description => "Sample-Domain Inc", :status => 0}
|
128
|
-
response = Linode[:compute].domain_create( TEST_DOMAIN, type, options)
|
129
|
-
if response.status == 200
|
130
|
-
master_zone_id = response.body['DATA']['DomainID']
|
131
|
-
puts "created zone for #{TEST_DOMAIN} - ID: #{master_zone_id}"
|
132
|
-
end
|
133
|
-
|
134
|
-
#create a slave zone
|
135
|
-
domain = 'sample-slave-domain.com'
|
136
|
-
type = 'slave'
|
137
|
-
options = { :master_ips => '1.2.3.4; 1.2.3.5'}
|
138
|
-
response = Linode[:compute].domain_create( domain, type, options)
|
139
|
-
if response.status == 200
|
140
|
-
slave_zone_id = response.body['DATA']['DomainID']
|
141
|
-
puts "created slave zone for #{domain} - ID: #{slave_zone_id}"
|
142
|
-
end
|
143
|
-
|
144
|
-
#get a list of zones Linode hosted for account
|
145
|
-
response = Linode[:compute].domain_list()
|
146
|
-
if response.status == 200
|
147
|
-
zones = response.body['DATA']
|
148
|
-
num_zones = zones.count
|
149
|
-
puts "Linode is hosting #{num_zones} DNS zones for this account:"
|
150
|
-
zones.each { |zone|
|
151
|
-
puts " #{zone['DOMAIN']}\n"
|
152
|
-
}
|
153
|
-
end
|
154
|
-
|
155
|
-
#add an A and a MX record
|
156
|
-
domain= 'www.' + TEST_DOMAIN
|
157
|
-
options = { :name => domain, :target => '4.5.6.7', :ttl_sec => 7200 }
|
158
|
-
response = Linode[:compute].domain_resource_create( master_zone_id, 'A', options)
|
159
|
-
if response.status == 200
|
160
|
-
resource_id = response.body['DATA']['ResourceID']
|
161
|
-
puts "added an A record for #{domain} - ID: #{resource_id}"
|
162
|
-
end
|
163
|
-
|
164
|
-
domain= 'mail.' + TEST_DOMAIN
|
165
|
-
options = { :target => domain, :priority => 1 }
|
166
|
-
response = Linode[:compute].domain_resource_create( master_zone_id, 'MX', options)
|
167
|
-
if response.status == 200
|
168
|
-
resource_id = response.body['DATA']['ResourceID']
|
169
|
-
puts "added a MX record for #{TEST_DOMAIN} - ID: #{resource_id}"
|
170
|
-
end
|
171
|
-
|
172
|
-
#change MX to have a lower priority
|
173
|
-
options = { :priority => 5 }
|
174
|
-
response = Linode[:compute].domain_resource_update( master_zone_id, resource_id, options)
|
175
|
-
if response.status == 200
|
176
|
-
resource_id = response.body['DATA']['ResourceID']
|
177
|
-
puts "updated MX record for #{TEST_DOMAIN} with new priority - ID: #{resource_id}"
|
178
|
-
end
|
179
|
-
|
180
|
-
#get the list of resource records for the domain
|
181
|
-
response = Linode[:compute].domain_resource_list( master_zone_id)
|
182
|
-
if response.status == 200
|
183
|
-
num_records = response.body['DATA'].count
|
184
|
-
puts "#{TEST_DOMAIN} zone has #{num_records} resource records"
|
185
|
-
end
|
186
|
-
|
187
|
-
#finally cleanup by deleting the zone we created
|
188
|
-
response = Linode[:compute].domain_delete( master_zone_id)
|
189
|
-
if response.status == 200
|
190
|
-
puts "deleted #{TEST_DOMAIN} zone"
|
191
|
-
end
|
192
|
-
response = Linode[:compute].domain_delete( slave_zone_id)
|
193
|
-
if response.status == 200
|
194
|
-
puts "deleted slave zone"
|
195
|
-
end
|
196
|
-
|
197
|
-
rescue
|
198
|
-
#opps, ran into a problem
|
199
|
-
puts $!.message
|
200
|
-
return false
|
201
|
-
end
|
202
|
-
|
203
|
-
true
|
204
|
-
end
|
205
|
-
|
206
|
-
|
207
|
-
# example of how to use Slicehost DNS calls
|
208
|
-
def show_slicehost_dns_usage
|
209
|
-
|
210
|
-
begin
|
211
|
-
#create a zone for a domain
|
212
|
-
zone_id = 0
|
213
|
-
options = { :ttl => 1800, :active => 'N' }
|
214
|
-
response= Slicehost[:compute].create_zone( TEST_DOMAIN, options)
|
215
|
-
if response.status == 201
|
216
|
-
zone_id= response.body['id']
|
217
|
-
puts "created zone for #{TEST_DOMAIN} - ID: #{zone_id}"
|
218
|
-
end
|
219
|
-
|
220
|
-
#add an A record for website
|
221
|
-
record_id = 0
|
222
|
-
options = { :ttl => 3600, :active => 'N' }
|
223
|
-
host = "www.#{TEST_DOMAIN}"
|
224
|
-
response= Slicehost[:compute].create_record( 'A', zone_id, host, "1.2.3.4", options)
|
225
|
-
if response.status == 201
|
226
|
-
record_id= response.body['id']
|
227
|
-
puts "created 'A' record for #{host} - ID: #{record_id}"
|
228
|
-
end
|
229
|
-
|
230
|
-
#get a list of zones Slicehost hosted for account
|
231
|
-
response = Slicehost[:compute].get_zones()
|
232
|
-
if response.status == 200
|
233
|
-
zones = response.body['zones']
|
234
|
-
num_zones= zones.count
|
235
|
-
puts "Slicehost is hosting #{num_zones} DNS zones for this account"
|
236
|
-
zones.each { |zone|
|
237
|
-
puts " #{zone['origin']}\n"
|
238
|
-
}
|
239
|
-
end
|
240
|
-
|
241
|
-
#now get details on www record for the zone
|
242
|
-
if record_id > 0
|
243
|
-
response = Slicehost[:compute].get_record( record_id)
|
244
|
-
if response.status == 200
|
245
|
-
record = response.body['records'][0]
|
246
|
-
name = record['name']
|
247
|
-
type = record['record-type']
|
248
|
-
puts "got details on record #{record_id} -is an #{type} record for #{name} domain"
|
249
|
-
end
|
250
|
-
end
|
251
|
-
|
252
|
-
#finally cleanup by deleting the zone we created
|
253
|
-
if zone_id > 0
|
254
|
-
response = Slicehost[:compute].delete_zone( zone_id)
|
255
|
-
if response.status == 200
|
256
|
-
puts "#{TEST_DOMAIN} removed from Slicehost DNS"
|
257
|
-
end
|
258
|
-
end
|
259
|
-
|
260
|
-
rescue
|
261
|
-
#opps, ran into a problem
|
262
|
-
puts $!.message
|
263
|
-
return false
|
264
|
-
end
|
265
|
-
|
266
|
-
true
|
267
|
-
end
|
268
|
-
|
269
|
-
# example of how to use Zerigo DNS calls
|
270
|
-
def show_zerigo_dns_usage
|
271
|
-
|
272
|
-
begin
|
273
|
-
#create a domain
|
274
|
-
options = { :nx_ttl => 1800 }
|
275
|
-
response = Zerigo[:compute].create_zone( "sample-domain.com", 3600, 'pri_sec', options)
|
276
|
-
if response.status == 201
|
277
|
-
zone_id = response.body['id']
|
278
|
-
end
|
279
|
-
|
280
|
-
#update zone
|
281
|
-
options = { :notes => "domain for client ABC"}
|
282
|
-
response = Zerigo[:compute].update_zone( zone_id, options)
|
283
|
-
if response.status == 200
|
284
|
-
puts "update of zone #{zone_id} worked"
|
285
|
-
end
|
286
|
-
|
287
|
-
#get details on the zone
|
288
|
-
response = Zerigo[:compute].get_zone( zone_id)
|
289
|
-
if response.status == 200
|
290
|
-
domain = response.body['domain']
|
291
|
-
hosts = response.body['hosts']
|
292
|
-
end
|
293
|
-
|
294
|
-
#get zone stats
|
295
|
-
response = Zerigo[:compute].get_zone_stats( zone_id)
|
296
|
-
if response.status == 200
|
297
|
-
queries = response.body['queries']
|
298
|
-
end
|
299
|
-
|
300
|
-
#list all domains on this accont
|
301
|
-
response= Zerigo[:compute].list_zones()
|
302
|
-
if response.status == 200
|
303
|
-
zone_count = response.headers['X-Query-Count'].to_i
|
304
|
-
end
|
305
|
-
|
306
|
-
#add an A record to the zone
|
307
|
-
options = { :hostname => 'www' }
|
308
|
-
response = Zerigo[:compute].create_host( zone_id, 'A', '1.2.3.4', options )
|
309
|
-
if response.status == 201
|
310
|
-
host_id = response.body['id']
|
311
|
-
end
|
312
|
-
|
313
|
-
#add an MX record to the zone
|
314
|
-
options = { :priority => 5 }
|
315
|
-
response = Zerigo[:compute].create_host( zone_id, 'MX', 'mail.sample-domain.com', options)
|
316
|
-
if response.status == 201
|
317
|
-
mail_host_id = response.body['id']
|
318
|
-
end
|
319
|
-
|
320
|
-
#update the record
|
321
|
-
options = { :priority => 10 }
|
322
|
-
response = Zerigo[:compute].update_host( mail_host_id, options)
|
323
|
-
if response.status == 200
|
324
|
-
#updated priority
|
325
|
-
end
|
326
|
-
|
327
|
-
#find a specific record
|
328
|
-
response = Zerigo[:compute].find_hosts( "sample-domain.com" )
|
329
|
-
if response.status == 200
|
330
|
-
hosts= response.body['hosts']
|
331
|
-
num_records = hosts.count
|
332
|
-
end
|
333
|
-
|
334
|
-
#get host record
|
335
|
-
response = Zerigo[:compute].get_host( host_id)
|
336
|
-
if response.status == 200
|
337
|
-
fqdn = response.body['fqdn']
|
338
|
-
end
|
339
|
-
|
340
|
-
#list hosts
|
341
|
-
response = Zerigo[:compute].list_hosts( zone_id)
|
342
|
-
if response.status == 200
|
343
|
-
hosts = response.body['hosts']
|
344
|
-
end
|
345
|
-
|
346
|
-
#delete the host record
|
347
|
-
response = Zerigo[:compute].delete_host( host_id)
|
348
|
-
if response.status == 200
|
349
|
-
puts "host record #{host_id} deleted from zone"
|
350
|
-
end
|
351
|
-
|
352
|
-
#delete the zone we created
|
353
|
-
response = Zerigo[:compute].delete_zone( zone_id)
|
354
|
-
if response.status == 200
|
355
|
-
puts "deleted zone #{zone_id}"
|
356
|
-
end
|
357
|
-
|
358
|
-
rescue
|
359
|
-
#opps, ran into a problem
|
360
|
-
puts $!.message
|
361
|
-
return false
|
362
|
-
end
|
363
|
-
|
364
|
-
end
|
365
|
-
|
366
|
-
######################################
|
367
|
-
|
368
|
-
# make sure Fog credentials file has been setup
|
369
|
-
# (will throw exception if not)
|
370
|
-
Fog::credentials
|
371
|
-
|
372
|
-
# AWS Route 53
|
373
|
-
if RUN_AWS_SAMPLE and Fog::credentials[:aws_access_key_id] and Fog::credentials[:aws_secret_access_key]
|
374
|
-
show_aws_dns_usage
|
375
|
-
end
|
376
|
-
|
377
|
-
# Linode
|
378
|
-
if RUN_LINODE_SAMPLE and Fog::credentials[:linode_api_key]
|
379
|
-
show_linode_dns_usage
|
380
|
-
end
|
381
|
-
|
382
|
-
# Slicehost
|
383
|
-
if RUN_SLICEHOST_SAMPLE and Fog::credentials[:slicehost_password]
|
384
|
-
show_slicehost_dns_usage
|
385
|
-
end
|
386
|
-
|
387
|
-
if RUN_ZERIGO_SAMPLE and Fog::credentials[:zerigo_email] and Fog::credentials[:zerigo_password]
|
388
|
-
show_zerigo_dns_usage
|
389
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
-
|
3
|
-
describe 'SimpleDB.batch_put_attributes' do
|
4
|
-
describe 'success' do
|
5
|
-
|
6
|
-
before(:all) do
|
7
|
-
@domain_name = "fog_domain_#{Time.now.to_i}"
|
8
|
-
AWS[:sdb].create_domain(@domain_name)
|
9
|
-
end
|
10
|
-
|
11
|
-
after(:all) do
|
12
|
-
AWS[:sdb].delete_domain(@domain_name)
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should return proper attributes' do
|
16
|
-
actual = AWS[:sdb].batch_put_attributes(@domain_name, { 'a' => { 'b' => 'c' }, 'x' => { 'y' => 'z' } })
|
17
|
-
actual.body['RequestId'].should be_a(String)
|
18
|
-
actual.body['BoxUsage'].should be_a(Float)
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
describe 'failure' do
|
23
|
-
|
24
|
-
it 'should raise a BadRequest error if the domain does not exist' do
|
25
|
-
lambda {
|
26
|
-
AWS[:sdb].batch_put_attributes('notadomain', { 'a' => { 'b' => 'c' }, 'x' => { 'y' => 'z' } })
|
27
|
-
}.should raise_error(Excon::Errors::BadRequest)
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|