fog 1.32.0 → 1.33.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +59 -0
  3. data/Gemfile +1 -0
  4. data/Rakefile +4 -4
  5. data/fog.gemspec +3 -2
  6. data/lib/fog/linode/requests/compute/avail_datacenters.rb +8 -7
  7. data/lib/fog/openstack.rb +1 -0
  8. data/lib/fog/openstack/compute.rb +7 -1
  9. data/lib/fog/openstack/core.rb +28 -54
  10. data/lib/fog/openstack/identity.rb +1 -0
  11. data/lib/fog/openstack/identity_v3.rb +10 -9
  12. data/lib/fog/openstack/models/baremetal/chassis.rb +3 -14
  13. data/lib/fog/openstack/models/baremetal/chassis_collection.rb +5 -5
  14. data/lib/fog/openstack/models/baremetal/driver.rb +2 -8
  15. data/lib/fog/openstack/models/baremetal/drivers.rb +3 -5
  16. data/lib/fog/openstack/models/baremetal/node.rb +3 -14
  17. data/lib/fog/openstack/models/baremetal/nodes.rb +4 -4
  18. data/lib/fog/openstack/models/baremetal/port.rb +3 -14
  19. data/lib/fog/openstack/models/baremetal/ports.rb +4 -4
  20. data/lib/fog/openstack/models/collection.rb +45 -0
  21. data/lib/fog/openstack/models/compute/address.rb +2 -2
  22. data/lib/fog/openstack/models/compute/addresses.rb +3 -5
  23. data/lib/fog/openstack/models/compute/aggregate.rb +2 -8
  24. data/lib/fog/openstack/models/compute/aggregates.rb +3 -5
  25. data/lib/fog/openstack/models/compute/availability_zone.rb +14 -0
  26. data/lib/fog/openstack/models/compute/availability_zones.rb +22 -0
  27. data/lib/fog/openstack/models/compute/flavor.rb +2 -8
  28. data/lib/fog/openstack/models/compute/flavors.rb +6 -6
  29. data/lib/fog/openstack/models/compute/host.rb +1 -1
  30. data/lib/fog/openstack/models/compute/hosts.rb +4 -6
  31. data/lib/fog/openstack/models/compute/image.rb +2 -8
  32. data/lib/fog/openstack/models/compute/images.rb +4 -6
  33. data/lib/fog/openstack/models/compute/key_pair.rb +2 -2
  34. data/lib/fog/openstack/models/compute/key_pairs.rb +3 -4
  35. data/lib/fog/openstack/models/compute/metadata.rb +3 -2
  36. data/lib/fog/openstack/models/compute/metadatum.rb +2 -2
  37. data/lib/fog/openstack/models/compute/network.rb +2 -2
  38. data/lib/fog/openstack/models/compute/networks.rb +3 -2
  39. data/lib/fog/openstack/models/compute/security_group.rb +2 -2
  40. data/lib/fog/openstack/models/compute/security_group_rule.rb +2 -2
  41. data/lib/fog/openstack/models/compute/security_group_rules.rb +2 -2
  42. data/lib/fog/openstack/models/compute/security_groups.rb +3 -5
  43. data/lib/fog/openstack/models/compute/server.rb +20 -1
  44. data/lib/fog/openstack/models/compute/servers.rb +9 -5
  45. data/lib/fog/openstack/models/compute/service.rb +2 -8
  46. data/lib/fog/openstack/models/compute/services.rb +4 -4
  47. data/lib/fog/openstack/models/compute/snapshot.rb +2 -8
  48. data/lib/fog/openstack/models/compute/snapshots.rb +5 -5
  49. data/lib/fog/openstack/models/compute/tenant.rb +2 -2
  50. data/lib/fog/openstack/models/compute/tenants.rb +3 -4
  51. data/lib/fog/openstack/models/compute/volume.rb +2 -8
  52. data/lib/fog/openstack/models/compute/volumes.rb +5 -5
  53. data/lib/fog/openstack/models/identity_v2/ec2_credential.rb +3 -9
  54. data/lib/fog/openstack/models/identity_v2/ec2_credentials.rb +3 -5
  55. data/lib/fog/openstack/models/identity_v2/role.rb +3 -3
  56. data/lib/fog/openstack/models/identity_v2/roles.rb +3 -5
  57. data/lib/fog/openstack/models/identity_v2/tenant.rb +5 -9
  58. data/lib/fog/openstack/models/identity_v2/tenants.rb +3 -5
  59. data/lib/fog/openstack/models/identity_v2/user.rb +2 -8
  60. data/lib/fog/openstack/models/identity_v2/users.rb +3 -5
  61. data/lib/fog/openstack/models/identity_v3/domain.rb +5 -9
  62. data/lib/fog/openstack/models/identity_v3/domains.rb +3 -5
  63. data/lib/fog/openstack/models/identity_v3/endpoint.rb +5 -9
  64. data/lib/fog/openstack/models/identity_v3/endpoints.rb +3 -5
  65. data/lib/fog/openstack/models/identity_v3/group.rb +5 -9
  66. data/lib/fog/openstack/models/identity_v3/groups.rb +3 -5
  67. data/lib/fog/openstack/models/identity_v3/os_credential.rb +3 -3
  68. data/lib/fog/openstack/models/identity_v3/os_credentials.rb +3 -5
  69. data/lib/fog/openstack/models/identity_v3/policies.rb +3 -5
  70. data/lib/fog/openstack/models/identity_v3/policy.rb +5 -9
  71. data/lib/fog/openstack/models/identity_v3/project.rb +5 -8
  72. data/lib/fog/openstack/models/identity_v3/projects.rb +21 -10
  73. data/lib/fog/openstack/models/identity_v3/role.rb +3 -8
  74. data/lib/fog/openstack/models/identity_v3/role_assignment.rb +3 -3
  75. data/lib/fog/openstack/models/identity_v3/role_assignments.rb +3 -5
  76. data/lib/fog/openstack/models/identity_v3/roles.rb +3 -5
  77. data/lib/fog/openstack/models/identity_v3/service.rb +3 -3
  78. data/lib/fog/openstack/models/identity_v3/services.rb +3 -5
  79. data/lib/fog/openstack/models/identity_v3/token.rb +3 -3
  80. data/lib/fog/openstack/models/identity_v3/tokens.rb +3 -3
  81. data/lib/fog/openstack/models/identity_v3/user.rb +3 -9
  82. data/lib/fog/openstack/models/identity_v3/users.rb +3 -5
  83. data/lib/fog/openstack/models/image/image.rb +2 -13
  84. data/lib/fog/openstack/models/image/images.rb +5 -5
  85. data/lib/fog/openstack/models/metering/resource.rb +2 -7
  86. data/lib/fog/openstack/models/metering/resources.rb +3 -3
  87. data/lib/fog/openstack/models/model.rb +44 -0
  88. data/lib/fog/openstack/models/network/floating_ip.rb +2 -7
  89. data/lib/fog/openstack/models/network/floating_ips.rb +3 -5
  90. data/lib/fog/openstack/models/network/lb_health_monitor.rb +2 -12
  91. data/lib/fog/openstack/models/network/lb_health_monitors.rb +3 -5
  92. data/lib/fog/openstack/models/network/lb_member.rb +2 -12
  93. data/lib/fog/openstack/models/network/lb_members.rb +3 -5
  94. data/lib/fog/openstack/models/network/lb_pool.rb +2 -12
  95. data/lib/fog/openstack/models/network/lb_pools.rb +3 -5
  96. data/lib/fog/openstack/models/network/lb_vip.rb +2 -12
  97. data/lib/fog/openstack/models/network/lb_vips.rb +3 -5
  98. data/lib/fog/openstack/models/network/network.rb +2 -12
  99. data/lib/fog/openstack/models/network/networks.rb +3 -5
  100. data/lib/fog/openstack/models/network/port.rb +2 -13
  101. data/lib/fog/openstack/models/network/ports.rb +3 -5
  102. data/lib/fog/openstack/models/network/router.rb +2 -13
  103. data/lib/fog/openstack/models/network/routers.rb +3 -5
  104. data/lib/fog/openstack/models/network/security_group.rb +2 -2
  105. data/lib/fog/openstack/models/network/security_group_rule.rb +2 -2
  106. data/lib/fog/openstack/models/network/security_group_rules.rb +3 -5
  107. data/lib/fog/openstack/models/network/security_groups.rb +3 -5
  108. data/lib/fog/openstack/models/network/subnet.rb +3 -14
  109. data/lib/fog/openstack/models/network/subnets.rb +3 -5
  110. data/lib/fog/openstack/models/orchestration/event.rb +2 -2
  111. data/lib/fog/openstack/models/orchestration/events.rb +5 -7
  112. data/lib/fog/openstack/models/orchestration/resource.rb +2 -2
  113. data/lib/fog/openstack/models/orchestration/resource_schemas.rb +2 -2
  114. data/lib/fog/openstack/models/orchestration/resources.rb +3 -5
  115. data/lib/fog/openstack/models/orchestration/stack.rb +3 -7
  116. data/lib/fog/openstack/models/orchestration/stacks.rb +5 -5
  117. data/lib/fog/openstack/models/orchestration/template.rb +2 -2
  118. data/lib/fog/openstack/models/orchestration/templates.rb +1 -1
  119. data/lib/fog/openstack/models/planning/plan.rb +2 -13
  120. data/lib/fog/openstack/models/planning/plans.rb +3 -5
  121. data/lib/fog/openstack/models/planning/role.rb +2 -8
  122. data/lib/fog/openstack/models/planning/roles.rb +3 -6
  123. data/lib/fog/openstack/models/storage/directories.rb +4 -6
  124. data/lib/fog/openstack/models/storage/directory.rb +2 -2
  125. data/lib/fog/openstack/models/storage/file.rb +15 -2
  126. data/lib/fog/openstack/models/storage/files.rb +7 -8
  127. data/lib/fog/openstack/models/volume/availability_zone.rb +13 -0
  128. data/lib/fog/openstack/models/volume/availability_zones.rb +17 -0
  129. data/lib/fog/openstack/models/volume/transfer.rb +36 -0
  130. data/lib/fog/openstack/models/volume/transfers.rb +38 -0
  131. data/lib/fog/openstack/models/volume/volume.rb +9 -8
  132. data/lib/fog/openstack/models/volume/volume_type.rb +2 -8
  133. data/lib/fog/openstack/models/volume/volume_types.rb +3 -6
  134. data/lib/fog/openstack/models/volume/volumes.rb +5 -6
  135. data/lib/fog/openstack/requests/compute/list_servers.rb +8 -5
  136. data/lib/fog/openstack/requests/compute/list_servers_detail.rb +9 -6
  137. data/lib/fog/openstack/requests/compute/list_zones.rb +6 -5
  138. data/lib/fog/openstack/requests/compute/list_zones_detailed.rb +55 -0
  139. data/lib/fog/openstack/requests/compute/shelve_offload_server.rb +24 -0
  140. data/lib/fog/openstack/requests/compute/shelve_server.rb +24 -0
  141. data/lib/fog/openstack/requests/compute/unshelve_server.rb +24 -0
  142. data/lib/fog/openstack/requests/identity_v3/get_project.rb +2 -2
  143. data/lib/fog/openstack/requests/network/create_subnet.rb +1 -1
  144. data/lib/fog/openstack/requests/network/update_subnet.rb +8 -7
  145. data/lib/fog/openstack/requests/volume/accept_transfer.rb +24 -0
  146. data/lib/fog/openstack/requests/volume/create_transfer.rb +27 -0
  147. data/lib/fog/openstack/requests/volume/delete_transfer.rb +17 -0
  148. data/lib/fog/openstack/requests/volume/extend_volume.rb +25 -0
  149. data/lib/fog/openstack/requests/volume/get_transfer_details.rb +17 -0
  150. data/lib/fog/openstack/requests/volume/list_transfers.rb +18 -0
  151. data/lib/fog/openstack/requests/volume/list_transfers_detailed.rb +18 -0
  152. data/lib/fog/openstack/requests/volume/list_zones.rb +32 -0
  153. data/lib/fog/openstack/storage.rb +3 -1
  154. data/lib/fog/openstack/volume.rb +16 -0
  155. data/lib/fog/rackspace/examples/compute_v2/create_network.rb +1 -1
  156. data/lib/fog/vcloud_director/generators/compute/edge_gateway_service_configuration.rb +31 -30
  157. data/lib/fog/vcloud_director/models/compute/task.rb +2 -2
  158. data/lib/fog/version.rb +1 -1
  159. data/lib/fog/vsphere/compute.rb +1 -0
  160. data/lib/fog/vsphere/requests/compute/get_resource_pool.rb +1 -1
  161. data/lib/fog/vsphere/requests/compute/get_virtual_machine.rb +4 -3
  162. data/lib/fog/vsphere/requests/compute/list_clusters.rb +1 -1
  163. data/lib/fog/vsphere/requests/compute/list_vm_interfaces.rb +2 -2
  164. data/lib/fog/vsphere/requests/compute/vm_clone.rb +101 -30
  165. data/lib/fog/vsphere/requests/compute/vm_execute.rb +47 -0
  166. data/lib/tasks/changelog_task.rb +1 -0
  167. data/spec/fog/openstack/identity_v3/{idv3.yml → common_setup.yml} +0 -0
  168. data/spec/fog/openstack/identity_v3/idv3_project_hier_crud_list.yml +1394 -0
  169. data/spec/fog/openstack/identity_v3_spec.rb +255 -196
  170. data/spec/fog/openstack/network/common_setup.yml +131 -0
  171. data/spec/fog/openstack/network/subnets_crud.yml +140 -0
  172. data/spec/fog/openstack/network_spec.rb +43 -0
  173. data/spec/fog/openstack/shared_context.rb +98 -0
  174. data/spec/fog/openstack/volume/{volume_common_setup.yml → common_setup.yml} +0 -0
  175. data/spec/fog/openstack/volume/volume_extend.yml +762 -0
  176. data/spec/fog/openstack/volume/volume_transfer_and_accept.yml +1078 -0
  177. data/spec/fog/openstack/volume/volume_transfer_and_delete.yml +695 -0
  178. data/spec/fog/openstack/volume_spec.rb +232 -67
  179. data/tests/openstack/models/storage/file_tests.rb +26 -0
  180. data/tests/openstack/requests/compute/availability_zone_tests.rb +18 -0
  181. data/tests/openstack/requests/compute/server_tests.rb +12 -0
  182. data/tests/openstack/requests/network/subnet_tests.rb +2 -2
  183. data/tests/openstack/requests/volume/availability_zone_tests.rb +13 -0
  184. data/tests/vcloud_director/requests/compute/edge_gateway_tests.rb +2 -2
  185. metadata +61 -26
  186. data/lib/fog/dynect.rb +0 -1
  187. data/lib/fog/dynect/core.rb +0 -26
  188. data/lib/fog/dynect/dns.rb +0 -157
  189. data/lib/fog/dynect/models/dns/record.rb +0 -67
  190. data/lib/fog/dynect/models/dns/records.rb +0 -48
  191. data/lib/fog/dynect/models/dns/zone.rb +0 -56
  192. data/lib/fog/dynect/models/dns/zones.rb +0 -25
  193. data/lib/fog/dynect/requests/dns/delete_record.rb +0 -55
  194. data/lib/fog/dynect/requests/dns/delete_zone.rb +0 -41
  195. data/lib/fog/dynect/requests/dns/get_all_records.rb +0 -56
  196. data/lib/fog/dynect/requests/dns/get_node_list.rb +0 -55
  197. data/lib/fog/dynect/requests/dns/get_record.rb +0 -83
  198. data/lib/fog/dynect/requests/dns/get_zone.rb +0 -57
  199. data/lib/fog/dynect/requests/dns/post_record.rb +0 -71
  200. data/lib/fog/dynect/requests/dns/post_session.rb +0 -43
  201. data/lib/fog/dynect/requests/dns/post_zone.rb +0 -70
  202. data/lib/fog/dynect/requests/dns/put_record.rb +0 -76
  203. data/lib/fog/dynect/requests/dns/put_zone.rb +0 -76
  204. data/tests/dynect/requests/dns/dns_tests.rb +0 -258
@@ -1,71 +0,0 @@
1
- module Fog
2
- module DNS
3
- class Dynect
4
- class Real
5
- # Create a record
6
- #
7
- # ==== Parameters
8
- # * type<~String> - type of record in ['AAAA', 'ANY', 'A', 'CNAME', 'DHCID', 'DNAME', 'DNSKEY', 'DS', 'KEY', 'LOC', 'MX', 'NSA', 'NS', 'PTR', 'PX', 'RP', 'SOA', 'SPF', 'SRV', 'SSHFP', 'TXT']
9
- # * zone<~String> - zone of record
10
- # * rdata<~Hash> - rdata for record
11
- # * options<~Hash>: (options vary by type, listing below includes common parameters)
12
- # * ttl<~Integer> - ttl for the record, defaults to zone ttl
13
-
14
- def post_record(type, zone, fqdn, rdata, options = {})
15
- options.merge!('rdata' => rdata)
16
- request(
17
- :body => Fog::JSON.encode(options),
18
- :expects => 200,
19
- :method => :post,
20
- :path => ["#{type.to_s.upcase}Record", zone, fqdn].join('/')
21
- )
22
- end
23
- end
24
-
25
- class Mock
26
- def post_record(type, zone, fqdn, rdata, options = {})
27
- raise Fog::DNS::Dynect::NotFound unless zone = self.data[:zones][zone]
28
-
29
- records = zone[:records]
30
- record_id = zone[:next_record_id]
31
- zone[:next_record_id] += 1
32
-
33
- record = {
34
- :type => type,
35
- :zone => zone,
36
- :fqdn => fqdn,
37
- :rdata => rdata,
38
- :ttl => options[:ttl] || zone[:ttl],
39
- :record_id => record_id
40
- }
41
-
42
- records[type] << record
43
-
44
- response = Excon::Response.new
45
- response.status = 200
46
-
47
- response.body = {
48
- "status" => "success",
49
- "data" => {
50
- "zone" => record[:zone][:zone],
51
- "ttl" => record[:ttl],
52
- "fqdn" => record[:fqdn],
53
- "record_type" => record[:type],
54
- "rdata" => record[:rdata],
55
- "record_id" => record[:record_id]
56
- },
57
- "job_id" => Fog::Dynect::Mock.job_id,
58
- "msgs" => [{
59
- "INFO"=>"add: Record added",
60
- "SOURCE"=>"BLL",
61
- "ERR_CD"=>nil,
62
- "LVL"=>"INFO"
63
- }]
64
- }
65
-
66
- response
67
- end
68
- end
69
- end
70
- end
71
- end
@@ -1,43 +0,0 @@
1
- module Fog
2
- module DNS
3
- class Dynect
4
- class Real
5
- def post_session
6
- request(
7
- :expects => 200,
8
- :idempotent => true,
9
- :method => :post,
10
- :path => "Session",
11
- :body => Fog::JSON.encode({
12
- :customer_name => @dynect_customer,
13
- :user_name => @dynect_username,
14
- :password => @dynect_password
15
- })
16
- )
17
- end
18
- end
19
-
20
- class Mock
21
- def post_session
22
- response = Excon::Response.new
23
- response.status = 200
24
- response.body = {
25
- "status" => "success",
26
- "data" => {
27
- "token" => auth_token,
28
- "version" => Fog::Dynect::Mock.version
29
- },
30
- "job_id" => Fog::Dynect::Mock.job_id,
31
- "msgs"=>[{
32
- "INFO"=>"login: Login successful",
33
- "SOURCE"=>"BLL",
34
- "ERR_CD"=>nil,
35
- "LVL"=>"INFO"
36
- }]
37
- }
38
- response
39
- end
40
- end
41
- end
42
- end
43
- end
@@ -1,70 +0,0 @@
1
- module Fog
2
- module DNS
3
- class Dynect
4
- class Real
5
- # Create a zone
6
- #
7
- # ==== Parameters
8
- # * rname<~String> - administrative contact
9
- # * ttl<~Integer> - time to live (in seconds) for records in this zone
10
- # * zone<~String> - name of zone to host
11
- # * options<~Hash>:
12
- # * serial_style<~String> - style of serial number, in ['day', 'epoch', 'increment', 'minute']. Defaults to increment
13
-
14
- def post_zone(rname, ttl, zone, options = {})
15
- body = Fog::JSON.encode({
16
- :rname => rname,
17
- :token => auth_token,
18
- :ttl => ttl
19
- }.merge!(options))
20
-
21
- request(
22
- :body => body,
23
- :expects => 200,
24
- :method => :post,
25
- :path => 'Zone/' << zone
26
- )
27
- end
28
- end
29
-
30
- class Mock
31
- def post_zone(rname, ttl, zone, options = {})
32
- new_zone = self.data[:zones][zone] = {
33
- :next_record_id => 0,
34
- :records => Hash.new do |records_hash, type|
35
- records_hash[type] = []
36
- end,
37
- :records_to_delete => [],
38
- :rname => rname,
39
- :serial_style => options[:serial_style] || "increment",
40
- :serial => 0,
41
- :ttl => ttl,
42
- :zone => zone,
43
- :zone_type => "Primary"
44
- }
45
-
46
- response = Excon::Response.new
47
- response.status = 200
48
- response.body = {
49
- "status" => "success",
50
- "data" => {
51
- "zone_type" => new_zone[:zone_type],
52
- "serial_style" => new_zone[:serial_style],
53
- "serial" => new_zone[:serial],
54
- "zone" => zone
55
- },
56
- "job_id" => Fog::Dynect::Mock.job_id,
57
- "msgs" => [{
58
- "INFO" => "create: New zone #{zone} created. Publish it to put it on our server.",
59
- "SOURCE" => "BLL",
60
- "ERR_CD" => nil,
61
- "LVL" => "INFO"
62
- }]
63
- }
64
-
65
- response
66
- end
67
- end
68
- end
69
- end
70
- end
@@ -1,76 +0,0 @@
1
- module Fog
2
- module DNS
3
- class Dynect
4
- class Real
5
- # Update or replace a record
6
- #
7
- # ==== Parameters
8
- # * type<~String> - type of record in ['AAAA', 'ANY', 'A', 'CNAME', 'DHCID', 'DNAME', 'DNSKEY', 'DS', 'KEY', 'LOC', 'MX', 'NSA', 'NS', 'PTR', 'PX', 'RP', 'SOA', 'SPF', 'SRV', 'SSHFP', 'TXT']
9
- # * zone<~String> - zone of record
10
- # * rdata<~Hash> - rdata for record
11
- # * options<~Hash>: (options vary by type, listing below includes common parameters)
12
- # * ttl<~Integer> - ttl for the record, defaults to zone ttl
13
-
14
- def put_record(type, zone, fqdn, rdata, options = {})
15
- options.merge!('rdata' => rdata)
16
- type.to_s.upcase!
17
- options = {"#{type}Records" => [options]} unless options['record_id']
18
- path = ["#{type}Record", zone, fqdn].join('/')
19
- path += "/#{options.delete('record_id')}" if options['record_id']
20
- request(
21
- :body => Fog::JSON.encode(options),
22
- :expects => 200,
23
- :idempotent => true,
24
- :method => :put,
25
- :path => path
26
- )
27
- end
28
- end
29
-
30
- class Mock
31
- def put_record(type, zone, fqdn, rdata, options = {})
32
- raise Fog::DNS::Dynect::NotFound unless zone = self.data[:zones][zone]
33
-
34
- records = zone[:records]
35
- record_id = zone[:next_record_id]
36
- zone[:next_record_id] += 1
37
-
38
- record = {
39
- :type => type,
40
- :zone => zone,
41
- :fqdn => fqdn,
42
- :rdata => rdata,
43
- :ttl => options[:ttl] || zone[:ttl],
44
- :record_id => record_id
45
- }
46
-
47
- records[type] << record
48
-
49
- response = Excon::Response.new
50
- response.status = 200
51
-
52
- response.body = {
53
- "status" => "success",
54
- "data" => {
55
- "zone" => record[:zone][:zone],
56
- "ttl" => record[:ttl],
57
- "fqdn" => record[:fqdn],
58
- "record_type" => record[:type],
59
- "rdata" => record[:rdata],
60
- "record_id" => record[:record_id]
61
- },
62
- "job_id" => Fog::Dynect::Mock.job_id,
63
- "msgs" => [{
64
- "INFO"=>"add: Record added",
65
- "SOURCE"=>"BLL",
66
- "ERR_CD"=>nil,
67
- "LVL"=>"INFO"
68
- }]
69
- }
70
-
71
- response
72
- end
73
- end
74
- end
75
- end
76
- end
@@ -1,76 +0,0 @@
1
- module Fog
2
- module DNS
3
- class Dynect
4
- class Real
5
- # Update a zone
6
- #
7
- # ==== Parameters
8
- # * zone<~String> - name or id of zone
9
- # * options<~Hash>:
10
- # * freeze<~Boolean> - causes zone to become frozen
11
- # * publish<~Boolean> - causes all pending changes to be pushed to nameservers
12
- # * thaw<~Boolean> - causes zone to cease being frozen
13
-
14
- def put_zone(zone, options = {})
15
- request(
16
- :body => Fog::JSON.encode(options),
17
- :expects => 200,
18
- :idempotent => true,
19
- :method => :put,
20
- :path => 'Zone/' << zone
21
- )
22
- end
23
- end
24
-
25
- class Mock
26
- def put_zone(zone, options = {})
27
- raise Fog::DNS::Dynect::NotFound unless zone = self.data[:zones][zone]
28
-
29
- raise ArgumentError unless options.size == 1
30
-
31
- response = Excon::Response.new
32
- response.status = 200
33
-
34
- data = {}
35
-
36
- if options['freeze']
37
- zone['frozen'] = true
38
- info = "freeze: Your zone is now frozen"
39
- elsif options['publish']
40
- zone[:changes] = {}
41
- zone[:records_to_delete].each do |record|
42
- zone[:records][record[:type]].delete_if { |r| r[:fqdn] == record[:fqdn] && r[:record_id] == record[:record_id] }
43
- end
44
- zone[:records_to_delete] = []
45
- data = {
46
- "zone_type" => zone[:zone_type],
47
- "serial_style" => zone[:serial_style],
48
- "serial" => zone[:serial] += 1,
49
- "zone" => zone[:zone]
50
- }
51
- info = "publish: #{zone[:zone]} published"
52
- elsif options['thaw']
53
- zone[:frozen] = false
54
- info = "thaw: Your zone is now thawed, you may edit normally"
55
- else
56
- raise ArgumentError
57
- end
58
-
59
- response.body = {
60
- "status" => "success",
61
- "data" => data,
62
- "job_id" => Fog::Dynect::Mock.job_id,
63
- "msgs" => [{
64
- "INFO" => info,
65
- "SOURCE"=>"BLL",
66
- "ERR_CD"=>nil,
67
- "LVL"=>"INFO"
68
- }]
69
- }
70
-
71
- response
72
- end
73
- end
74
- end
75
- end
76
- end
@@ -1,258 +0,0 @@
1
- Shindo.tests('Dynect::dns | DNS requests', ['dynect', 'dns']) do
2
-
3
- shared_format = {
4
- 'job_id' => Integer,
5
- 'msgs' => [{
6
- 'ERR_CD' => Fog::Nullable::String,
7
- 'INFO' => String,
8
- 'LVL' => String,
9
- 'SOURCE' => String
10
- }],
11
- 'status' => String
12
- }
13
-
14
- tests "success" do
15
-
16
- @dns = Fog::DNS[:dynect]
17
- @domain = generate_unique_domain
18
- @fqdn = "www.#{@domain}"
19
-
20
- post_session_format = shared_format.merge({
21
- 'data' => {
22
- 'token' => String,
23
- 'version' => String
24
- }
25
- })
26
-
27
- tests("post_session").formats(post_session_format) do
28
- @dns.post_session.body
29
- end
30
-
31
- post_zone_format = shared_format.merge({
32
- 'data' => {
33
- 'serial' => Integer,
34
- 'zone' => String,
35
- 'zone_type' => String,
36
- 'serial_style' => String
37
- }
38
- })
39
-
40
- tests("post_zone('netops@#{@domain}', 3600, '#{@domain}')").formats(post_zone_format) do
41
- @dns.post_zone("netops@#{@domain}", 3600, @domain).body
42
- end
43
-
44
- get_zones_format = shared_format.merge({
45
- 'data' => [String]
46
- })
47
-
48
- tests("get_zone").formats(get_zones_format) do
49
- @dns.get_zone.body
50
- end
51
-
52
- get_zone_format = shared_format.merge({
53
- 'data' => {
54
- "serial" => Integer,
55
- "serial_style" => String,
56
- "zone" => String,
57
- "zone_type" => String
58
- }
59
- })
60
-
61
- tests("get_zone('zone' => '#{@domain}')").formats(get_zone_format) do
62
- @dns.get_zone('zone' => @domain).body
63
- end
64
-
65
- post_record_format = shared_format.merge({
66
- 'data' => {
67
- 'fqdn' => String,
68
- 'rdata' => {
69
- 'address' => String
70
- },
71
- 'record_id' => Integer,
72
- 'record_type' => String,
73
- 'ttl' => Integer,
74
- 'zone' => String
75
- }
76
- })
77
-
78
- tests("post_record('A', '#{@domain}', '#{@fqdn}', 'address' => '1.2.3.4')").formats(post_record_format) do
79
- @dns.post_record('A', @domain, @fqdn, {'address' => '1.2.3.4'}).body
80
- end
81
-
82
- put_record_format = shared_format.merge({
83
- 'data' => {
84
- 'fqdn' => String,
85
- 'ARecords' => [
86
- {
87
- 'rdata' => {
88
- 'address' => String
89
- }
90
- }
91
- ],
92
- 'record_id' => Integer,
93
- 'record_type' => String,
94
- 'ttl' => Integer,
95
- 'zone' => String
96
- }
97
- })
98
-
99
- tests("put_record('A', '#{@domain}', '#{@fqdn}', 'address' => '1.2.3.4')").formats(post_record_format) do
100
- @dns.put_record('A', @domain, @fqdn, {'address' => '1.2.3.4'}).body
101
- end
102
-
103
- publish_zone_format = shared_format.merge({
104
- 'data' => {
105
- 'serial' => Integer,
106
- 'serial_style' => String,
107
- 'zone' => String,
108
- 'zone_type' => String
109
- }
110
- })
111
-
112
- tests("put_zone('#{@domain}', 'publish' => true)").formats(publish_zone_format) do
113
- @dns.put_zone(@domain, 'publish' => true).body
114
- end
115
-
116
- freeze_zone_format = shared_format.merge({
117
- 'data' => {}
118
- })
119
-
120
- tests("put_zone('#{@domain}', 'freeze' => true)").formats(freeze_zone_format) do
121
- @dns.put_zone(@domain, 'freeze' => true).body
122
- end
123
-
124
- thaw_zone_format = shared_format.merge({
125
- 'data' => {}
126
- })
127
-
128
- tests("put_zone('#{@domain}', 'thaw' => true)").formats(thaw_zone_format) do
129
- @dns.put_zone(@domain, 'thaw' => true).body
130
- end
131
-
132
- get_node_list_format = shared_format.merge({
133
- 'data' => [String]
134
- })
135
-
136
- tests("get_node_list('#{@domain}')").formats(get_node_list_format) do
137
- @dns.get_node_list(@domain).body
138
- end
139
-
140
- get_all_records_format = shared_format.merge({
141
- 'data' => [String]
142
- })
143
-
144
- tests("get_all_records('#{@domain}')").formats(get_all_records_format) do
145
- @dns.get_all_records(@domain).body
146
- end
147
-
148
- get_records_format = shared_format.merge({
149
- 'data' => [String]
150
- })
151
-
152
- tests("get_record('A', '#{@domain}', '#{@fqdn}')").formats(get_records_format) do
153
- data = @dns.get_record('A', @domain, @fqdn).body
154
- @record_id = data['data'].first.split('/').last
155
- data
156
- end
157
-
158
- sleep 5 unless Fog.mocking?
159
-
160
- @dns.post_record('CNAME', @domain, "cname.#{@fqdn}", {'cname' => "#{@fqdn}."})
161
-
162
- tests("get_record('ANY', '#{@domain}', 'cname.#{@fqdn}')").formats(get_records_format) do
163
- @dns.get_record('ANY', @domain, "cname.#{@fqdn}").body
164
- end
165
-
166
- get_record_format = shared_format.merge({
167
- 'data' => {
168
- 'zone' => String,
169
- 'ttl' => Integer,
170
- 'fqdn' => String,
171
- 'record_type' => String,
172
- 'rdata' => {
173
- 'address' => String
174
- },
175
- 'record_id' => Integer
176
- }
177
- })
178
-
179
- tests("get_record('A', '#{@domain}', '#{@fqdn}', 'record_id' => '#{@record_id}')").formats(get_record_format) do
180
- @dns.get_record('A', @domain, @fqdn, 'record_id' => @record_id).body
181
- end
182
-
183
- delete_record_format = shared_format.merge({
184
- 'data' => {}
185
- })
186
-
187
- tests("delete_record('A', '#{@domain}', '#{@fqdn}', '#{@record_id}')").formats(delete_record_format) do
188
- @dns.delete_record('A', @domain, "#{@fqdn}", @record_id).body
189
- end
190
-
191
- delete_zone_format = shared_format.merge({
192
- 'data' => {}
193
- })
194
-
195
- sleep 5 unless Fog.mocking?
196
-
197
- tests("delete_zone('#{@domain}')").formats(delete_zone_format) do
198
- @dns.delete_zone(@domain).body
199
- end
200
-
201
- tests("job handling") do
202
- pending unless Fog.mocking?
203
-
204
- old_mock_value = Excon.defaults[:mock]
205
- Excon.stubs.clear
206
-
207
- tests("returns final response from a complete job").returns({"status" => "success"}) do
208
- begin
209
- Excon.defaults[:mock] = true
210
-
211
- Excon.stub({:method => :post, :path => "/REST/Session"}, {:body=>"{\"status\": \"success\", \"data\": {\"token\": \"foobar\", \"version\": \"2.3.1\"}, \"job_id\": 150583906, \"msgs\": [{\"INFO\": \"login: Login successful\", \"SOURCE\": \"BLL\", \"ERR_CD\": null, \"LVL\": \"INFO\"}]}", :headers=>{"Content-Type"=>"application/json"}, :status=>200})
212
-
213
- Excon.stub({:method => :get, :path => "/REST/Zone/example.com"}, {:status => 307, :body => '/REST/Job/150576635', :headers => {'Content-Type' => 'text/html', 'Location' => '/REST/Job/150576635'}})
214
- Excon.stub({:method => :get, :path => "/REST/Job/150576635"}, {:status => 307, :body => '{"status":"success"}', :headers => {'Content-Type' => 'application/json'}})
215
-
216
- Fog::DNS::Dynect::Real.new.request(:method => :get, :path => "Zone/example.com").body
217
- ensure
218
- Excon.stubs.clear
219
- Excon.defaults[:mock] = old_mock_value
220
- end
221
- end
222
-
223
- tests("passes expects through when polling a job").returns({"status" => "success"}) do
224
- begin
225
- Excon.defaults[:mock] = true
226
-
227
- Excon.stub({:method => :post, :path => "/REST/Session"}, {:body=>"{\"status\": \"success\", \"data\": {\"token\": \"foobar\", \"version\": \"2.3.1\"}, \"job_id\": 150583906, \"msgs\": [{\"INFO\": \"login: Login successful\", \"SOURCE\": \"BLL\", \"ERR_CD\": null, \"LVL\": \"INFO\"}]}", :headers=>{"Content-Type"=>"application/json"}, :status=>200})
228
-
229
- Excon.stub({:method => :get, :path => "/REST/Zone/example.com"}, {:status => 307, :body => '/REST/Job/150576635', :headers => {'Content-Type' => 'text/html', 'Location' => '/REST/Job/150576635'}})
230
- Excon.stub({:method => :get, :path => "/REST/Job/150576635"}, {:status => 404, :body => '{"status":"success"}', :headers => {'Content-Type' => 'application/json'}})
231
-
232
- Fog::DNS::Dynect::Real.new.request(:method => :get, :expects => 404, :path => "Zone/example.com").body
233
- ensure
234
- Excon.stubs.clear
235
- Excon.defaults[:mock] = old_mock_value
236
- end
237
- end
238
- end
239
- end
240
-
241
- tests('failure') do
242
- tests("#auth_token with expired credentials").raises(Excon::Errors::BadRequest) do
243
- pending if Fog.mocking?
244
- @dns = Fog::DNS[:dynect]
245
- @dns.instance_variable_get(:@connection).stub(:request) { raise Excon::Errors::BadRequest.new('Expected(200) <=> Actual(400 Bad Request) request => {:headers=>{"Content-Type"=>"application/json", "API-Version"=>"2.3.1", "Auth-Token"=>"auth-token", "Host"=>"api2.dynect.net:443", "Content-Length"=>0}, :host=>"api2.dynect.net", :mock=>nil, :path=>"/REST/CNAMERecord/domain.com/www.domain.com", :port=>"443", :query=>nil, :scheme=>"https", :expects=>200, :method=>:get} response => #<Excon::Response:0x00000008478b98 @body="{"status": "failure", "data": {}, "job_id": 21326025, "msgs": [{"INFO": "login: Bad or expired credentials", "SOURCE": "BLL", "ERR_CD": "INVALID_DATA", "LVL": "ERROR"}, {"INFO": "login: There was a problem with your credentials", "SOURCE": "BLL", "ERR_CD": null, "LVL": "INFO"}]}", @headers={"Server"=>"nginx/0.7.67", "Date"=>"Thu, 08 Sep 2011 20:04:21 GMT", "Content-Type"=>"application/json", "Transfer-Encoding"=>"chunked", "Connection"=>"keep-alive"}, @status=400>') }
246
- @dns.instance_variable_get(:@connection).should_receive(:request).exactly(2).times
247
- @dns.auth_token
248
- end
249
-
250
- tests("#auth_token with inactivity logout").raises(Excon::Errors::BadRequest) do
251
- pending if Fog.mocking?
252
- @dns = Fog::DNS[:dynect]
253
- @dns.instance_variable_get(:@connection).stub(:request) { raise Excon::Errors::BadRequest.new('Expected(200) <=> Actual(400 Bad Request) request => {:headers=>{"Content-Type"=>"application/json", "API-Version"=>"2.3.1", "Auth-Token"=>"auth-token", "Host"=>"api2.dynect.net:443", "Content-Length"=>0}, :host=>"api2.dynect.net", :mock=>nil, :path=>"/REST/CNAMERecord/domain.com/www.domain.com", :port=>"443", :query=>nil, :scheme=>"https", :expects=>200, :method=>:get} response => #<Excon::Response:0x00000008478b98 @body="{"status": "failure", "data": {}, "job_id": 21326025, "msgs": [{"INFO": "login: inactivity logout", "SOURCE": "BLL", "ERR_CD": "INVALID_DATA", "LVL": "ERROR"}, {"INFO": "login: There was a problem with your credentials", "SOURCE": "BLL", "ERR_CD": null, "LVL": "INFO"}]}", @headers={"Server"=>"nginx/0.7.67", "Date"=>"Thu, 08 Sep 2011 20:04:21 GMT", "Content-Type"=>"application/json", "Transfer-Encoding"=>"chunked", "Connection"=>"keep-alive"}, @status=400>') }
254
- @dns.instance_variable_get(:@connection).should_receive(:request).exactly(2).times
255
- @dns.auth_token
256
- end
257
- end
258
- end