fog 1.12.1 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. data/.travis.yml +1 -1
  2. data/Gemfile +5 -0
  3. data/Rakefile +14 -4
  4. data/bin/fog +22 -0
  5. data/changelog.txt +262 -0
  6. data/fog.gemspec +8 -4
  7. data/lib/fog/aws.rb +11 -0
  8. data/lib/fog/aws/auto_scaling.rb +15 -18
  9. data/lib/fog/aws/beanstalk.rb +8 -10
  10. data/lib/fog/aws/cloud_formation.rb +9 -12
  11. data/lib/fog/aws/compute.rb +8 -10
  12. data/lib/fog/aws/credential_fetcher.rb +6 -6
  13. data/lib/fog/aws/elasticache.rb +13 -17
  14. data/lib/fog/aws/elb.rb +29 -31
  15. data/lib/fog/aws/iam.rb +10 -13
  16. data/lib/fog/aws/models/auto_scaling/group.rb +6 -3
  17. data/lib/fog/aws/models/compute/spot_request.rb +1 -11
  18. data/lib/fog/aws/models/rds/log_file.rb +26 -0
  19. data/lib/fog/aws/models/rds/log_files.rb +50 -0
  20. data/lib/fog/aws/models/rds/server.rb +3 -1
  21. data/lib/fog/aws/models/rds/snapshot.rb +1 -0
  22. data/lib/fog/aws/models/rds/snapshots.rb +20 -13
  23. data/lib/fog/aws/parsers/rds/db_parser.rb +1 -1
  24. data/lib/fog/aws/parsers/rds/describe_db_log_files.rb +44 -0
  25. data/lib/fog/aws/parsers/rds/download_db_logfile_portion.rb +26 -0
  26. data/lib/fog/aws/parsers/ses/verify_domain_identity.rb +26 -0
  27. data/lib/fog/aws/parsers/storage/complete_multipart_upload.rb +1 -1
  28. data/lib/fog/aws/parsers/sts/assume_role.rb +30 -0
  29. data/lib/fog/aws/rds.rb +27 -14
  30. data/lib/fog/aws/requests/auto_scaling/create_auto_scaling_group.rb +8 -0
  31. data/lib/fog/aws/requests/auto_scaling/update_auto_scaling_group.rb +8 -1
  32. data/lib/fog/aws/requests/compute/create_volume.rb +3 -3
  33. data/lib/fog/aws/requests/rds/create_db_instance.rb +3 -1
  34. data/lib/fog/aws/requests/rds/describe_db_log_files.rb +67 -0
  35. data/lib/fog/aws/requests/rds/download_db_logfile_portion.rb +63 -0
  36. data/lib/fog/aws/requests/ses/send_raw_email.rb +1 -1
  37. data/lib/fog/aws/requests/ses/verify_domain_identity.rb +30 -0
  38. data/lib/fog/aws/requests/storage/complete_multipart_upload.rb +6 -2
  39. data/lib/fog/aws/requests/storage/get_object.rb +1 -1
  40. data/lib/fog/aws/requests/sts/assume_role.rb +46 -0
  41. data/lib/fog/aws/ses.rb +26 -9
  42. data/lib/fog/aws/storage.rb +2 -1
  43. data/lib/fog/aws/sts.rb +31 -21
  44. data/lib/fog/bin.rb +0 -1
  45. data/lib/fog/bin/openstack.rb +5 -0
  46. data/lib/fog/brightbox/compute.rb +20 -212
  47. data/lib/fog/brightbox/compute/shared.rb +232 -0
  48. data/lib/fog/brightbox/models/compute/collaboration.rb +43 -0
  49. data/lib/fog/brightbox/models/compute/collaborations.rb +23 -0
  50. data/lib/fog/brightbox/models/compute/user_collaboration.rb +29 -0
  51. data/lib/fog/brightbox/models/compute/user_collaborations.rb +23 -0
  52. data/lib/fog/brightbox/requests/compute/accept_user_collaboration.rb +21 -0
  53. data/lib/fog/brightbox/requests/compute/create_collaboration.rb +23 -0
  54. data/lib/fog/brightbox/requests/compute/delete_collaboration.rb +28 -0
  55. data/lib/fog/brightbox/requests/compute/delete_user_collaboration.rb +28 -0
  56. data/lib/fog/brightbox/requests/compute/destroy_user_collaboration.rb +21 -0
  57. data/lib/fog/brightbox/requests/compute/get_collaboration.rb +21 -0
  58. data/lib/fog/brightbox/requests/compute/get_user_collaboration.rb +21 -0
  59. data/lib/fog/brightbox/requests/compute/list_collaborations.rb +19 -0
  60. data/lib/fog/brightbox/requests/compute/list_user_collaborations.rb +19 -0
  61. data/lib/fog/brightbox/requests/compute/reject_user_collaboration.rb +21 -0
  62. data/lib/fog/brightbox/requests/compute/resend_collaboration.rb +21 -0
  63. data/lib/fog/cloudsigma/docs/getting_started.md +59 -0
  64. data/lib/fog/core.rb +7 -2
  65. data/lib/fog/core/connection.rb +62 -29
  66. data/lib/fog/core/deprecated/connection.rb +24 -0
  67. data/lib/fog/core/parser.rb +1 -1
  68. data/lib/fog/digitalocean/examples/getting_started.md +1 -1
  69. data/lib/fog/digitalocean/models/compute/server.rb +2 -2
  70. data/lib/fog/google/compute.rb +31 -7
  71. data/lib/fog/google/models/compute/disk.rb +80 -0
  72. data/lib/fog/google/models/compute/disks.rb +28 -0
  73. data/lib/fog/google/models/compute/image.rb +36 -0
  74. data/lib/fog/google/models/compute/server.rb +46 -33
  75. data/lib/fog/google/models/compute/servers.rb +15 -8
  76. data/lib/fog/google/requests/compute/delete_server.rb +5 -2
  77. data/lib/fog/google/requests/compute/get_disk.rb +3 -0
  78. data/lib/fog/google/requests/compute/get_server.rb +7 -1
  79. data/lib/fog/google/requests/compute/insert_disk.rb +8 -2
  80. data/lib/fog/google/requests/compute/insert_server.rb +51 -22
  81. data/lib/fog/google/requests/compute/list_machine_types.rb +3 -2
  82. data/lib/fog/google/requests/storage/get_object.rb +1 -1
  83. data/lib/fog/hp/requests/storage/get_object.rb +1 -1
  84. data/lib/fog/hp/storage.rb +26 -9
  85. data/lib/fog/ibm/requests/compute/create_instance.rb +20 -15
  86. data/lib/fog/internet_archive/requests/storage/get_object.rb +1 -1
  87. data/lib/fog/{core/json.rb → json.rb} +13 -2
  88. data/lib/fog/metering.rb +25 -0
  89. data/lib/fog/openstack.rb +1 -0
  90. data/lib/fog/openstack/metering.rb +215 -0
  91. data/lib/fog/openstack/models/compute/flavors.rb +2 -2
  92. data/lib/fog/openstack/models/compute/metadata.rb +1 -1
  93. data/lib/fog/openstack/models/compute/server.rb +5 -2
  94. data/lib/fog/openstack/models/image/images.rb +1 -1
  95. data/lib/fog/openstack/models/metering/meter.rb +0 -0
  96. data/lib/fog/openstack/models/metering/meters.rb +0 -0
  97. data/lib/fog/openstack/models/metering/resource.rb +24 -0
  98. data/lib/fog/openstack/models/metering/resources.rb +25 -0
  99. data/lib/fog/openstack/models/volume/volume.rb +3 -1
  100. data/lib/fog/openstack/models/volume/volumes.rb +2 -1
  101. data/lib/fog/openstack/network.rb +1 -1
  102. data/lib/fog/openstack/requests/compute/create_flavor.rb +1 -1
  103. data/lib/fog/openstack/requests/compute/create_server.rb +19 -1
  104. data/lib/fog/openstack/requests/compute/detach_volume.rb +2 -1
  105. data/lib/fog/openstack/requests/compute/list_flavors_detail.rb +4 -3
  106. data/lib/fog/openstack/requests/compute/list_security_groups.rb +1 -1
  107. data/lib/fog/openstack/requests/identity/create_tenant.rb +2 -2
  108. data/lib/fog/openstack/requests/metering/get_resource.rb +32 -0
  109. data/lib/fog/openstack/requests/metering/get_samples.rb +55 -0
  110. data/lib/fog/openstack/requests/metering/get_statistics.rb +56 -0
  111. data/lib/fog/openstack/requests/metering/list_meters.rb +50 -0
  112. data/lib/fog/openstack/requests/metering/list_resources.rb +32 -0
  113. data/lib/fog/openstack/requests/volume/create_volume.rb +4 -2
  114. data/lib/fog/rackspace.rb +16 -1
  115. data/lib/fog/rackspace/block_storage.rb +13 -28
  116. data/lib/fog/rackspace/cdn.rb +10 -24
  117. data/lib/fog/rackspace/compute.rb +17 -45
  118. data/lib/fog/rackspace/compute_v2.rb +13 -33
  119. data/lib/fog/rackspace/databases.rb +13 -29
  120. data/lib/fog/rackspace/dns.rb +27 -23
  121. data/lib/fog/rackspace/identity.rb +10 -26
  122. data/lib/fog/rackspace/load_balancers.rb +13 -29
  123. data/lib/fog/rackspace/mock_data.rb +3 -3
  124. data/lib/fog/rackspace/models/compute/server.rb +1 -1
  125. data/lib/fog/rackspace/models/dns/zones.rb +34 -21
  126. data/lib/fog/rackspace/models/identity/users.rb +2 -2
  127. data/lib/fog/rackspace/models/storage/file.rb +1 -0
  128. data/lib/fog/rackspace/requests/dns/list_domains.rb +2 -2
  129. data/lib/fog/rackspace/requests/storage/delete_multiple_objects.rb +75 -0
  130. data/lib/fog/rackspace/requests/storage/delete_static_large_object.rb +50 -0
  131. data/lib/fog/rackspace/requests/storage/get_object.rb +3 -1
  132. data/lib/fog/rackspace/requests/storage/put_dynamic_obj_manifest.rb +44 -0
  133. data/lib/fog/rackspace/requests/storage/put_object_manifest.rb +3 -30
  134. data/lib/fog/rackspace/requests/storage/put_static_obj_manifest.rb +60 -0
  135. data/lib/fog/rackspace/service.rb +43 -1
  136. data/lib/fog/rackspace/storage.rb +25 -43
  137. data/lib/fog/riakcs/provisioning.rb +2 -1
  138. data/lib/fog/riakcs/usage.rb +2 -1
  139. data/lib/fog/vcloud/requests/compute/configure_vm_cpus.rb +1 -1
  140. data/lib/fog/vcloud/requests/compute/configure_vm_memory.rb +1 -1
  141. data/lib/fog/version.rb +1 -1
  142. data/lib/fog/vsphere/requests/compute/get_folder.rb +1 -1
  143. data/lib/fog/xenserver/compute.rb +2 -0
  144. data/lib/fog/xenserver/models/compute/server.rb +9 -7
  145. data/lib/fog/xenserver/requests/compute/snapshot_revert.rb +22 -0
  146. data/lib/fog/xenserver/requests/compute/snapshot_server.rb +22 -0
  147. data/lib/fog/xml.rb +21 -0
  148. data/lib/fog/xml/sax_parser_connection.rb +43 -0
  149. data/lib/tasks/changelog_task.rb +1 -0
  150. data/tests/aws/models/auto_scaling/groups_test.rb +22 -0
  151. data/tests/aws/requests/compute/volume_tests.rb +3 -3
  152. data/tests/aws/requests/rds/helper.rb +14 -0
  153. data/tests/aws/requests/rds/log_file_tests.rb +19 -0
  154. data/tests/aws/requests/ses/verified_domain_identity_tests.rb +16 -0
  155. data/tests/aws/requests/sts/assume_role_tests.rb +19 -0
  156. data/tests/brightbox/requests/compute/collaboration_tests.rb +41 -0
  157. data/tests/brightbox/requests/compute/helper.rb +46 -2
  158. data/tests/brightbox/requests/compute/user_collaboration_tests.rb +67 -0
  159. data/tests/core/connection_tests.rb +26 -0
  160. data/tests/helper.rb +13 -0
  161. data/tests/openstack/requests/metering/meter_tests.rb +52 -0
  162. data/tests/openstack/requests/metering/resource_tests.rb +19 -0
  163. data/tests/openvz/helper.rb +14 -8
  164. data/tests/rackspace/block_storage_tests.rb +9 -0
  165. data/tests/rackspace/compute_tests.rb +9 -0
  166. data/tests/rackspace/compute_v2_tests.rb +9 -0
  167. data/tests/rackspace/databases_tests.rb +9 -0
  168. data/tests/rackspace/dns_tests.rb +20 -0
  169. data/tests/rackspace/helper.rb +12 -1
  170. data/tests/rackspace/identity_tests.rb +25 -0
  171. data/tests/rackspace/load_balancer_tests.rb +10 -0
  172. data/tests/rackspace/models/block_storage/volume_tests.rb +2 -2
  173. data/tests/rackspace/models/compute_v2/metadata_tests.rb +2 -2
  174. data/tests/rackspace/models/compute_v2/server_tests.rb +22 -21
  175. data/tests/rackspace/models/dns/zones_tests.rb +19 -5
  176. data/tests/rackspace/models/storage/file_tests.rb +22 -6
  177. data/tests/rackspace/rackspace_tests.rb +35 -0
  178. data/tests/rackspace/requests/block_storage/snapshot_tests.rb +2 -3
  179. data/tests/rackspace/requests/block_storage/volume_type_tests.rb +4 -11
  180. data/tests/rackspace/requests/compute_v2/address_tests.rb +1 -1
  181. data/tests/rackspace/requests/compute_v2/attachment_tests.rb +8 -9
  182. data/tests/rackspace/requests/compute_v2/flavor_tests.rb +1 -1
  183. data/tests/rackspace/requests/compute_v2/metadata_tests.rb +4 -4
  184. data/tests/rackspace/requests/databases/database_tests.rb +23 -20
  185. data/tests/rackspace/requests/databases/user_tests.rb +6 -6
  186. data/tests/rackspace/requests/identity/user_tests.rb +4 -1
  187. data/tests/rackspace/requests/load_balancers/usage_tests.rb +4 -2
  188. data/tests/rackspace/requests/storage/large_object_tests.rb +303 -59
  189. data/tests/rackspace/requests/storage/object_tests.rb +73 -18
  190. data/tests/rackspace/service_tests.rb +83 -0
  191. data/tests/rackspace/storage_tests.rb +9 -0
  192. data/tests/xenserver/models/compute/server_tests.rb +11 -1
  193. metadata +89 -19
  194. data/tests/core/user_agent_tests.rb +0 -6
@@ -0,0 +1,43 @@
1
+ module Fog
2
+ module XML
3
+ class SAXParserConnection < Fog::Core::Connection
4
+
5
+ # Makes a request using the connection using Excon
6
+ #
7
+ # @param [Hash] params
8
+ # @option params [String] :body text to be sent over a socket
9
+ # @option params [Hash<Symbol, String>] :headers The default headers to supply in a request
10
+ # @option params [String] :host The destination host's reachable DNS name or IP, in the form of a String
11
+ # @option params [String] :path appears after 'scheme://host:port/'
12
+ # @option params [Fixnum] :port The port on which to connect, to the destination host
13
+ # @option params [Hash] :query appended to the 'scheme://host:port/path/' in the form of '?key=value'
14
+ # @option params [String] :scheme The protocol; 'https' causes OpenSSL to be used
15
+ # @option params [Proc] :response_block
16
+ # @option params [Nokogiri::XML::SAX::Document] :parser
17
+ #
18
+ # @return [Excon::Response]
19
+ #
20
+ # @raise [Excon::Errors::StubNotFound]
21
+ # @raise [Excon::Errors::Timeout]
22
+ # @raise [Excon::Errors::SocketError]
23
+ #
24
+ def request(parser, params)
25
+ reset unless @persistent
26
+
27
+ # Prepare the SAX parser
28
+ data_stream = Nokogiri::XML::SAX::PushParser.new(parser)
29
+ params[:response_block] = lambda do |chunk, remaining, total|
30
+ data_stream << chunk
31
+ end
32
+
33
+ # Make request which read chunks into parser
34
+ response = @excon.request(params)
35
+
36
+ # Cease parsing and override response.body with parsed data
37
+ data_stream.finish
38
+ response.body = parser.response
39
+ response
40
+ end
41
+ end
42
+ end
43
+ end
@@ -60,6 +60,7 @@ module Fog
60
60
  'Dylan Egan',
61
61
  'geemus',
62
62
  'Henry Addison',
63
+ 'James Bence',
63
64
  'Kevin Menard',
64
65
  'Kyle Rames',
65
66
  'Lincoln Stoll',
@@ -0,0 +1,22 @@
1
+ Shindo.tests('AWS::AutoScaling | group', ['aws', 'auto_scaling_m']) do
2
+
3
+ params = {
4
+ :id => uniq_id,
5
+ :auto_scaling_group_name => "name",
6
+ :availability_zones => [],
7
+ :launch_configuration_name => "lc"
8
+ }
9
+
10
+ lc_params = {
11
+ :id => params[:launch_configuration_name],
12
+ :image_id => "image-id",
13
+ :instance_type => "instance-type",
14
+ }
15
+
16
+ Fog::AWS[:auto_scaling].configurations.new(lc_params).save
17
+
18
+ model_tests(Fog::AWS[:auto_scaling].groups, params, true) do
19
+ @instance.update
20
+ end
21
+
22
+ end
@@ -192,9 +192,9 @@ Shindo.tests('Fog::Compute[:aws] | volume requests', ['aws']) do
192
192
  Fog::Compute[:aws].create_volume(@server.availability_zone, 10, 'VolumeType' => 'io1', 'Iops' => 99)
193
193
  end
194
194
 
195
- # iops invalid value (greater than 2000)
196
- tests("#create_volume('#{@server.availability_zone}', 1024, 'VolumeType' => 'io1', 'Iops' => 2001)").raises(Fog::Compute::AWS::Error) do
197
- Fog::Compute[:aws].create_volume(@server.availability_zone, 1024, 'VolumeType' => 'io1', 'Iops' => 2001)
195
+ # iops invalid value (greater than 4000)
196
+ tests("#create_volume('#{@server.availability_zone}', 1024, 'VolumeType' => 'io1', 'Iops' => 4001)").raises(Fog::Compute::AWS::Error) do
197
+ Fog::Compute[:aws].create_volume(@server.availability_zone, 1024, 'VolumeType' => 'io1', 'Iops' => 4001)
198
198
  end
199
199
 
200
200
  @volume.destroy
@@ -105,6 +105,19 @@ class AWS
105
105
 
106
106
  })
107
107
 
108
+ DB_LOG_FILE = {
109
+ 'LastWritten' => Time,
110
+ 'Size' => Integer,
111
+ 'LogFileName' => String
112
+ }
113
+
114
+ DESCRIBE_DB_LOG_FILES = BASIC.merge({
115
+ 'DescribeDBLogFilesResult' => {
116
+ 'Marker' => Fog::Nullable::String,
117
+ 'DBLogFiles' => [DB_LOG_FILE]
118
+ }
119
+ })
120
+
108
121
  SNAPSHOT={
109
122
  'AllocatedStorage' => Integer,
110
123
  'AvailabilityZone' => String,
@@ -137,6 +150,7 @@ class AWS
137
150
  'DBSecurityGroupName' => String
138
151
  }],
139
152
  'DBSubnetGroupName' => Fog::Nullable::String,
153
+ 'PubliclyAccessible' => Fog::Boolean,
140
154
  'Endpoint' => {
141
155
  'Address' => Fog::Nullable::String,
142
156
  'Port' => Fog::Nullable::Integer
@@ -0,0 +1,19 @@
1
+ Shindo.tests('AWS::RDS | log file requests', %w[aws rds]) do
2
+ tests('success') do
3
+ pending if Fog.mocking?
4
+
5
+ suffix = rand(65536).to_s(16)
6
+ @db_instance_id = "fog-test-#{suffix}"
7
+
8
+ tests('#describe_db_log_files').formats(AWS::RDS::Formats::DESCRIBE_DB_LOG_FILES) do
9
+ result = Fog::AWS[:rds].describe_db_log_files(@db_instance_id).body['DescribeDBLogFilesResult']
10
+ returns(true) { result['DBLogFiles'].size > 0 }
11
+ result
12
+ end
13
+
14
+ end
15
+
16
+ tests('failures') do
17
+ raises(Fog::AWS::RDS::NotFound) {Fog::AWS[:rds].describe_db_log_files('doesntexist')}
18
+ end
19
+ end
@@ -0,0 +1,16 @@
1
+ Shindo.tests('AWS::SES | verified domain identity requests', ['aws', 'ses']) do
2
+
3
+ tests('success') do
4
+
5
+ tests("#verify_domain_identity('example.com')").formats(AWS::SES::Formats::BASIC) do
6
+ pending if Fog.mocking?
7
+ Fog::AWS[:ses].verify_domain_identity('example.com').body
8
+ end
9
+
10
+ end
11
+
12
+ tests('failure') do
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,19 @@
1
+ Shindo.tests('AWS::STS | assume role', ['aws']) do
2
+
3
+ @policy = {"Statement" => [{"Effect" => "Allow", "Action" => "*", "Resource" => "*"}]}
4
+
5
+ @response_format = {
6
+ 'SessionToken' => String,
7
+ 'SecretAccessKey' => String,
8
+ 'Expiration' => String,
9
+ 'AccessKeyId' => String,
10
+ 'Arn' => String,
11
+ 'RequestId' => String
12
+ }
13
+
14
+ tests("#assume_role('rolename', 'assumed_role_session', 'external_id', #{@policy.inspect}, 900)").formats(@response_format) do
15
+ pending if Fog.mocking?
16
+ Fog::AWS[:sts].assume_role("rolename","assumed_role_session","external_id", @policy, 900).body
17
+ end
18
+
19
+ end
@@ -0,0 +1,41 @@
1
+ Shindo.tests('Fog::Compute[:brightbox] | collaboration requests', ['brightbox']) do
2
+
3
+ tests('success') do
4
+
5
+ tests("#create_collaboration") do
6
+ pending if Fog.mocking?
7
+ collaboration = Fog::Compute[:brightbox].create_collaboration(:email => "paul@example.com", :role => "admin")
8
+ @collaboration_id = collaboration['id']
9
+ formats(Brightbox::Compute::Formats::Full::COLLABORATION, false) { collaboration }
10
+ end
11
+
12
+
13
+ tests("#list_collaborations") do
14
+ pending if Fog.mocking?
15
+ result = Fog::Compute[:brightbox].list_collaborations
16
+
17
+ formats(Brightbox::Compute::Formats::Collection::COLLABORATIONS, false) { result }
18
+ end
19
+
20
+ tests("#get_collaboration") do
21
+ pending if Fog.mocking?
22
+ result = Fog::Compute[:brightbox].get_collaboration(@collaboration_id)
23
+ formats(Brightbox::Compute::Formats::Full::COLLABORATION, false) { result }
24
+ end
25
+
26
+
27
+ tests("#destroy_collaboration") do
28
+ pending if Fog.mocking?
29
+ result = Fog::Compute[:brightbox].destroy_collaboration(@collaboration_id)
30
+ formats(Brightbox::Compute::Formats::Full::COLLABORATION, false) { result }
31
+ end
32
+ end
33
+
34
+ tests("failure") do
35
+ tests("get_collaboration('col-abcde')").raises(Excon::Errors::NotFound) do
36
+ pending if Fog.mocking?
37
+ Fog::Compute[:brightbox].get_collaboration("col-abcde")
38
+ end
39
+ end
40
+
41
+ end
@@ -8,6 +8,7 @@ module Fog
8
8
  module LoadBalancer; end
9
9
  module Server; end
10
10
  module ServerGroup; end
11
+ module User; end
11
12
  module Zone; end
12
13
  end
13
14
  end
@@ -34,6 +35,9 @@ NilClass.send :include, Fog::Brightbox::Nullable::Server
34
35
  Hash.send :include, Fog::Brightbox::Nullable::ServerGroup
35
36
  NilClass.send :include, Fog::Brightbox::Nullable::ServerGroup
36
37
 
38
+ Hash.send :include, Fog::Brightbox::Nullable::User
39
+ NilClass.send :include, Fog::Brightbox::Nullable::User
40
+
37
41
  Hash.send :include, Fog::Brightbox::Nullable::Zone
38
42
  NilClass.send :include, Fog::Brightbox::Nullable::Zone
39
43
 
@@ -75,8 +79,8 @@ class Brightbox
75
79
  raise "No available images!" if images.empty?
76
80
  images.select { |img| img["official"] && img["virtual_size"] != 0 }.sort_by { |img| img["disk_size"] }.first || images.first
77
81
  end
78
-
79
82
  end
83
+
80
84
  module Formats
81
85
  module Struct
82
86
  CIP_PORT_TRANSLATOR = {
@@ -231,6 +235,20 @@ class Brightbox
231
235
  "email_address" => String
232
236
  }
233
237
 
238
+
239
+ COLLABORATION = {
240
+ "id" => String,
241
+ "resource_type" => String,
242
+ "url" => String,
243
+ "status" => String,
244
+ "email" => Fog::Nullable::String,
245
+ "role" => String,
246
+ "role_label" => String,
247
+ "user" => Fog::Brightbox::Nullable::User,
248
+ "account" => Brightbox::Compute::Formats::Nested::ACCOUNT,
249
+ "inviter" => Brightbox::Compute::Formats::Nested::USER
250
+ }
251
+
234
252
  ZONE = {
235
253
  "id" => String,
236
254
  "resource_type" => String,
@@ -413,6 +431,19 @@ class Brightbox
413
431
  "default_account" => NilClass
414
432
  }
415
433
 
434
+ COLLABORATION = {
435
+ "id" => String,
436
+ "resource_type" => String,
437
+ "url" => String,
438
+ "status" => String,
439
+ "role" => String,
440
+ "role_label" => String,
441
+ "email" => Fog::Nullable::String,
442
+ "user" => Fog::Brightbox::Nullable::User,
443
+ "account" => Brightbox::Compute::Formats::Nested::ACCOUNT,
444
+ "inviter" => Brightbox::Compute::Formats::Nested::USER
445
+ }
446
+
416
447
  ZONE = {
417
448
  "id" => String,
418
449
  "resource_type" => String,
@@ -656,13 +687,25 @@ class Brightbox
656
687
  "messaging_pref" => Fog::Boolean
657
688
  }
658
689
 
690
+ COLLABORATION = {
691
+ "id" => String,
692
+ "resource_type" => String,
693
+ "url" => String,
694
+ "status" => String,
695
+ "role" => String,
696
+ "role_label" => String,
697
+ "email" => Fog::Nullable::String,
698
+ "user" => Fog::Brightbox::Nullable::User,
699
+ "account" => Brightbox::Compute::Formats::Nested::ACCOUNT,
700
+ "inviter" => Brightbox::Compute::Formats::Nested::USER
701
+ }
702
+
659
703
  ZONE = {
660
704
  "id" => String,
661
705
  "resource_type" => String,
662
706
  "url" => String,
663
707
  "handle" => String
664
708
  }
665
-
666
709
  end
667
710
 
668
711
  module Collection
@@ -678,6 +721,7 @@ class Brightbox
678
721
  SERVER_TYPES = [Brightbox::Compute::Formats::Collected::SERVER_TYPE]
679
722
  USERS = [Brightbox::Compute::Formats::Collected::USER]
680
723
  ZONES = [Brightbox::Compute::Formats::Collected::ZONE]
724
+ COLLABORATIONS = [Brightbox::Compute::Formats::Collected::COLLABORATION]
681
725
  end
682
726
 
683
727
  end
@@ -0,0 +1,67 @@
1
+ Shindo.tests('Fog::Compute[:brightbox] | user collaboration requests', ['brightbox']) do
2
+
3
+ @service = Fog::Compute[:brightbox]
4
+
5
+ tests("when accessing with user application") do
6
+ pending unless @service.authenticating_as_user?
7
+ tests("success") do
8
+ tests("#list_user_collaborations") do
9
+ pending if Fog.mocking?
10
+ result = @service.list_user_collaborations
11
+
12
+ formats(Brightbox::Compute::Formats::Collection::COLLABORATIONS, false) { result }
13
+ end
14
+ end
15
+
16
+ tests("failure") do
17
+ tests("get_user_collaboration('col-abcde')").raises(Excon::Errors::NotFound) do
18
+ pending if Fog.mocking?
19
+
20
+ @service.get_user_collaboration('col-abcde')
21
+ end
22
+
23
+ tests("accept_user_collaboration('col-abcde')").raises(Excon::Errors::NotFound) do
24
+ pending if Fog.mocking?
25
+
26
+ @service.accept_user_collaboration('col-abcde')
27
+ end
28
+
29
+ tests("reject_user_collaboration('col-abcde')").raises(Excon::Errors::NotFound) do
30
+ pending if Fog.mocking?
31
+
32
+ @service.reject_user_collaboration('col-abcde')
33
+ end
34
+ end
35
+ end
36
+
37
+ tests("when accessing with API client") do
38
+ pending if @service.authenticating_as_user?
39
+ tests("forbidden") do
40
+
41
+ tests("#list_user_collaborations").raises(Excon::Errors::Forbidden) do
42
+ pending if Fog.mocking?
43
+ result = @service.list_user_collaborations
44
+
45
+ formats(Brightbox::Compute::Formats::Collection::COLLABORATIONS, false) { result }
46
+ end
47
+
48
+ tests("get_user_collaboration('col-abcde')").raises(Excon::Errors::Forbidden) do
49
+ pending if Fog.mocking?
50
+
51
+ @service.get_user_collaboration('col-abcde')
52
+ end
53
+
54
+ tests("accept_user_collaboration('col-abcde')").raises(Excon::Errors::Forbidden) do
55
+ pending if Fog.mocking?
56
+
57
+ @service.accept_user_collaboration('col-abcde')
58
+ end
59
+
60
+ tests("reject_user_collaboration('col-abcde')").raises(Excon::Errors::Forbidden) do
61
+ pending if Fog.mocking?
62
+
63
+ @service.reject_user_collaboration('col-abcde')
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,26 @@
1
+ Shindo.tests('Fog::Core::Connection', ['core']) do
2
+
3
+ raises(ArgumentError, "raises ArgumentError when no arguments given") do
4
+ Fog::Core::Connection.new
5
+ end
6
+
7
+ tests('new("http://example.com")') do
8
+ @instance = Fog::Core::Connection.new("http://example.com")
9
+ responds_to([:request, :reset])
10
+
11
+ tests('user agent').returns("fog/#{Fog::VERSION}") do
12
+ @instance.instance_variable_get(:@excon).data[:headers]['User-Agent']
13
+ end
14
+ end
15
+
16
+ tests('new("http://example.com", true)') do
17
+ Fog::Core::Connection.new("http://example.com", true)
18
+ end
19
+
20
+ tests('new("http://example.com", false, options")') do
21
+ options = {
22
+ :debug_response => false
23
+ }
24
+ Fog::Core::Connection.new("http://example.com", true, options)
25
+ end
26
+ end
@@ -1,3 +1,16 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+
4
+ unless ENV['COVERAGE'] == 'false'
5
+ SimpleCov.command_name "shindo:#{Process.pid.to_s}"
6
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
7
+ SimpleCov::Formatter::HTMLFormatter,
8
+ Coveralls::SimpleCov::Formatter
9
+ ]
10
+ SimpleCov.merge_timeout 3600
11
+ SimpleCov.start
12
+ end
13
+
1
14
  ENV['FOG_RC'] = ENV['FOG_RC'] || File.expand_path('../.fog', __FILE__)
2
15
  ENV['FOG_CREDENTIAL'] = ENV['FOG_CREDENTIAL'] || 'default'
3
16
 
@@ -0,0 +1,52 @@
1
+ Shindo.tests('Fog::Metering[:openstack] | meter requests', ['openstack']) do
2
+
3
+ @sample_format = {
4
+ 'counter_name' => String,
5
+ 'user_id' => String,
6
+ 'resource_id' => String,
7
+ 'timestamp' => String,
8
+ 'resource_metadata' => Hash,
9
+ 'source' => String,
10
+ 'counter_unit' => String,
11
+ 'counter_volume' => Float,
12
+ 'project_id' => String,
13
+ 'message_id' => String,
14
+ 'counter_type' => String
15
+ }
16
+
17
+ @meter_format = {
18
+ 'user_id' => String,
19
+ 'name' => String,
20
+ 'resource_id' => String,
21
+ 'project_id' => String,
22
+ 'type' => String,
23
+ 'unit' => String
24
+ }
25
+
26
+ @statistics_format = {
27
+ 'count' => Integer,
28
+ 'duration_start' => String,
29
+ 'min' => Float,
30
+ 'max' => Float,
31
+ 'duration_end' => String,
32
+ 'period' => Integer,
33
+ 'period_end' => String,
34
+ 'duration' => Float,
35
+ 'period_start' => String,
36
+ 'avg' => Float,
37
+ 'sum' => Float
38
+ }
39
+ tests('success') do
40
+ tests('#list_meters').formats([@meter_format]) do
41
+ Fog::Metering[:openstack].list_meters.body
42
+ end
43
+
44
+ tests('#get_samples').formats([@sample_format]) do
45
+ Fog::Metering[:openstack].get_samples('test').body
46
+ end
47
+
48
+ tests('#get_statistics').formats([@statistics_format]) do
49
+ Fog::Metering[:openstack].get_statistics('test').body
50
+ end
51
+ end
52
+ end