fog 1.16.0 → 1.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. data/.travis.yml +6 -0
  2. data/README.md +25 -0
  3. data/changelog.txt +108 -0
  4. data/fog.gemspec +7 -5
  5. data/lib/fog/aws.rb +8 -2
  6. data/lib/fog/aws/cloud_formation.rb +0 -1
  7. data/lib/fog/aws/compute.rb +1 -1
  8. data/lib/fog/aws/elb.rb +0 -1
  9. data/lib/fog/aws/iam.rb +4 -1
  10. data/lib/fog/aws/models/iam/access_key.rb +5 -1
  11. data/lib/fog/aws/models/iam/access_keys.rb +0 -1
  12. data/lib/fog/aws/parsers/compute/describe_reserved_instances.rb +2 -1
  13. data/lib/fog/aws/parsers/storage/get_bucket_tagging.rb +37 -0
  14. data/lib/fog/aws/requests/compute/copy_image.rb +1 -1
  15. data/lib/fog/aws/requests/compute/describe_reserved_instances.rb +1 -0
  16. data/lib/fog/aws/requests/compute/purchase_reserved_instances_offering.rb +1 -0
  17. data/lib/fog/aws/requests/iam/create_access_key.rb +22 -15
  18. data/lib/fog/aws/requests/iam/list_access_keys.rb +15 -11
  19. data/lib/fog/aws/requests/iam/update_access_key.rb +22 -0
  20. data/lib/fog/aws/requests/storage/delete_bucket_tagging.rb +46 -0
  21. data/lib/fog/aws/requests/storage/get_bucket_tagging.rb +53 -0
  22. data/lib/fog/aws/requests/storage/put_bucket_tagging.rb +60 -0
  23. data/lib/fog/aws/storage.rb +32 -19
  24. data/lib/fog/brightbox/models/compute/load_balancer.rb +47 -2
  25. data/lib/fog/core/logger.rb +4 -5
  26. data/lib/fog/core/service.rb +1 -1
  27. data/lib/fog/google/README.md +2 -2
  28. data/lib/fog/google/compute.rb +2 -1
  29. data/lib/fog/google/examples/bootstrap.rb +1 -1
  30. data/lib/fog/google/examples/get_list_images.rb +1 -2
  31. data/lib/fog/google/examples/network.rb +2 -0
  32. data/lib/fog/google/models/compute/disk.rb +23 -0
  33. data/lib/fog/google/models/compute/snapshot.rb +1 -0
  34. data/lib/fog/google/requests/compute/insert_server.rb +1 -1
  35. data/lib/fog/google/requests/compute/insert_snapshot.rb +49 -0
  36. data/lib/fog/google/storage.rb +54 -29
  37. data/lib/fog/hp.rb +0 -4
  38. data/lib/fog/hp/block_storage.rb +2 -2
  39. data/lib/fog/hp/cdn.rb +2 -2
  40. data/lib/fog/hp/compute.rb +2 -2
  41. data/lib/fog/hp/storage.rb +3 -3
  42. data/lib/fog/linode/compute.rb +1 -1
  43. data/lib/fog/linode/dns.rb +1 -1
  44. data/lib/fog/rackspace/block_storage.rb +0 -2
  45. data/lib/fog/vcloud_director/compute.rb +76 -2
  46. data/lib/fog/vcloud_director/generators/compute/{edge_gateway.rb → edge_gateway_service_configuration.rb} +2 -1
  47. data/lib/fog/vcloud_director/requests/compute/delete_disk.rb +33 -0
  48. data/lib/fog/vcloud_director/requests/compute/delete_media.rb +82 -2
  49. data/lib/fog/vcloud_director/requests/compute/get_disk.rb +99 -1
  50. data/lib/fog/vcloud_director/requests/compute/get_disk_owner.rb +45 -0
  51. data/lib/fog/vcloud_director/requests/compute/get_edge_gateway.rb +33 -19
  52. data/lib/fog/vcloud_director/requests/compute/get_media.rb +75 -4
  53. data/lib/fog/vcloud_director/requests/compute/get_media_owner.rb +34 -4
  54. data/lib/fog/vcloud_director/requests/compute/get_task.rb +122 -3
  55. data/lib/fog/vcloud_director/requests/compute/get_task_list.rb +80 -37
  56. data/lib/fog/vcloud_director/requests/compute/{get_vms_disks_attached_to.rb → get_vms_disk_attached_to.rb} +16 -2
  57. data/lib/fog/vcloud_director/requests/compute/post_cancel_task.rb +18 -0
  58. data/lib/fog/vcloud_director/requests/compute/post_clone_media.rb +52 -1
  59. data/lib/fog/vcloud_director/requests/compute/post_configure_edge_gateway_services.rb +14 -2
  60. data/lib/fog/vcloud_director/requests/compute/post_instantiate_vapp_template.rb +2 -2
  61. data/lib/fog/vcloud_director/requests/compute/post_upload_disk.rb +133 -0
  62. data/lib/fog/vcloud_director/requests/compute/post_upload_media.rb +48 -4
  63. data/lib/fog/vcloud_director/requests/compute/put_guest_customization_section_vapp.rb +103 -26
  64. data/lib/fog/vcloud_director/requests/compute/put_network_connection_system_section_vapp.rb +90 -32
  65. data/lib/fog/version.rb +1 -1
  66. data/lib/fog/vsphere/compute.rb +29 -14
  67. data/lib/fog/vsphere/models/compute/server.rb +18 -6
  68. data/lib/fog/vsphere/requests/compute/create_vm.rb +1 -0
  69. data/lib/fog/vsphere/requests/compute/vm_clone.rb +2 -9
  70. data/lib/fog/vsphere/requests/compute/vm_reconfig_cpus.rb +2 -2
  71. data/lib/fog/xenserver/requests/compute/create_server.rb +1 -1
  72. data/tests/aws/requests/compute/instance_tests.rb +1 -0
  73. data/tests/aws/requests/storage/bucket_tests.rb +19 -3
  74. data/tests/brightbox/compute/schema.rb +1 -0
  75. data/tests/core/credential_tests.rb +7 -1
  76. data/tests/core/parser_tests.rb +1 -1
  77. data/tests/rackspace/block_storage_tests.rb +1 -1
  78. data/tests/rackspace/cdn_tests.rb +1 -1
  79. data/tests/rackspace/compute_tests.rb +1 -1
  80. data/tests/rackspace/compute_v2_tests.rb +1 -1
  81. data/tests/rackspace/databases_tests.rb +1 -1
  82. data/tests/rackspace/dns_tests.rb +1 -1
  83. data/tests/rackspace/load_balancer_tests.rb +1 -1
  84. data/tests/rackspace/storage_tests.rb +1 -1
  85. data/tests/vcloud_director/ensure_list_tests.rb +30 -2
  86. data/tests/vcloud_director/requests/compute/disk_tests.rb +160 -5
  87. data/tests/vcloud_director/requests/compute/edge_gateway_tests.rb +59 -1
  88. data/tests/vcloud_director/requests/compute/helper.rb +5 -1
  89. data/tests/vcloud_director/requests/compute/media_tests.rb +109 -99
  90. data/tests/vcloud_director/requests/compute/schema_helper.rb +15 -2
  91. data/tests/vcloud_director/requests/compute/task_tests.rb +21 -6
  92. metadata +27 -21
@@ -9,6 +9,8 @@ rvm:
9
9
  - 1.9.2
10
10
  - 1.9.3
11
11
  - 2.0.0
12
+ - jruby-18mode
13
+ - jruby-19mode
12
14
 
13
15
  script: bundle exec rake travis
14
16
 
@@ -22,6 +24,10 @@ matrix:
22
24
  gemfile: Gemfile.1.8.7
23
25
  - rvm: 2.0.0
24
26
  gemfile: Gemfile.1.8.7
27
+ - rvm: jruby-18mode
28
+ gemfile: Gemfile
29
+ - rvm: jruby-19mode
30
+ gemfile: Gemfile.1.8.7
25
31
 
26
32
  notifications:
27
33
  email: false
data/README.md CHANGED
@@ -135,6 +135,31 @@ for more details and examples. Once you are ready to start scripting fog, here i
135
135
 
136
136
  geemus says: "That should give you everything you need to get started, but let me know if there is anything I can do to help!"
137
137
 
138
+ ## Versioning
139
+
140
+ Fog library aims to adhere to [Semantic Versioning 2.0.0][semver], although it does not
141
+ address challenges of multi-provider libraries. Semantic versioning is only guaranteed for
142
+ the common API, not any provider-specific extensions. You may also need to update your
143
+ configuration from time to time (even between Fog releases) as providers update or deprecate
144
+ services.
145
+
146
+ However, we still aim for forwards compatibility within Fog major versions. As a result of this policy, you can (and
147
+ should) specify a dependency on this gem using the [Pessimistic Version
148
+ Constraint][pvc] with two digits of precision. For example:
149
+
150
+ ```ruby
151
+ spec.add_dependency 'fog', '~> 1.0'
152
+ ```
153
+
154
+ This means your project is compatible with Fog 1.0 up until 2.0. You can also set a higher minimum version:
155
+
156
+ ```ruby
157
+ spec.add_dependency 'fog', '~> 1.16'
158
+ ```
159
+
160
+ [semver]: http://semver.org/
161
+ [pvc]: http://guides.rubygems.org/patterns/
162
+
138
163
  ## Contributing
139
164
 
140
165
  * Find something you would like to work on.
@@ -1,3 +1,111 @@
1
+ 1.17.0 10/29/2013 9f0627eec16e636bfe86895bbd36f89d7a017737
2
+ ==========================================================
3
+
4
+ Stats! { 'collaborators' => 53, 'downloads' => 3531286, 'forks' => 964, 'open_issues' => 177, 'watchers' => 2765 }
5
+
6
+ MVP! Chris Roberts
7
+
8
+ [Brightbox]
9
+ Add SSL settings to load balancer. thanks Paul Thornthwaite
10
+
11
+ [aws|iam]
12
+ Don't pass :host to Excon request. thanks Robert Bousquet
13
+
14
+ [aws|storage]
15
+ ensure connection uses correct scheme, host and port. thanks Brian D. Burns
16
+ remove unused :path option. thanks Brian D. Burns
17
+
18
+ [core]
19
+ log warning for unrecognized arguments. thanks Brian D. Burns
20
+ identify origin of log messages. thanks Brian D. Burns
21
+ Make `ruby-libvirt` dependency optional. thanks Paul Thornthwaite
22
+
23
+ [google|compute]
24
+ examples tweaks. thanks Nat Welch
25
+ Fix externalIP setup. thanks Nat Welch
26
+
27
+ [google|storage]
28
+ ensure connection uses correct URI. thanks Brian D. Burns
29
+
30
+ [jruby]
31
+ Ignore failures until fully supported. thanks Paul Thornthwaite
32
+
33
+ [linode|compute]
34
+ Avoid passing host to request. thanks Fletcher Nichol
35
+
36
+ [linode|dns]
37
+ avoid passing host to request. thanks geemus
38
+
39
+ [misc]
40
+ Create a Snapshot based on a Disk. thanks Akshay Moghe
41
+ Add s3 bucket tagging support. thanks Chris Roberts
42
+ Add mocks in for bucket tagging and include in bucket tests. thanks Chris Roberts
43
+ Store tag information in mock and check for set tags in `put_bucket_tagging`. thanks Chris Roberts
44
+ Namespace tagging and move tagging tests prior to bucket deletion. thanks Chris Roberts
45
+ Return `body` out of test so we have proper value to match against expected `returns`. thanks Chris Roberts
46
+ Move mock storage initialization and remove storage checks. thanks Chris Roberts
47
+ AWS IAM userless key management. thanks Jacob Burkhart & Shai Rosenfeld
48
+ Removed errant :host argument. thanks Jon Topper
49
+ aws/compute: Hotfix, wrong Name argument for copy_image. thanks Jonas Pfenniger
50
+ Added testing in JRuby for Travis. thanks Kevin Menard
51
+ Don't load a couple MRI-only development dependencies on JRuby. thanks Kevin Menard
52
+ Temporary hack around #2279 to get fog loading on JRuby. thanks Kevin Menard
53
+ Added logging message for JRuby users to know they're at a disadvantage. thanks Kevin Menard
54
+ Scope the Unicode module so NameErrors make more sense. thanks Kevin Menard
55
+ Handle another case of the 'unicode' gem breaking things on JRuby. thanks Kevin Menard
56
+ Added a JRuby workaround in a test that's failing due to a JRuby bug. thanks Kevin Menard
57
+ Bound the 'myns' XML namespace to keep Nokogiri on JRuby happy. thanks Kevin Menard
58
+ Replaced the 'unicode' gem with 'unf' so it'll work with JRuby. thanks Kevin Menard
59
+ Made the 'unf' dependency optional. thanks Kevin Menard
60
+ Added a development dependency on 'unf' so the AWS escaping tests will pass. thanks Kevin Menard
61
+ Don't ignore JRuby failures in Travis any longer, since all known ones have been addressed. thanks Kevin Menard
62
+ Semantic Versioning (and Pessimistic Versioning Constraint) notice. thanks Max Lincoln
63
+ Update GCE to v1beta16. thanks Nat Welch
64
+ @icco can't spell. thanks Nat Welch
65
+ Fix bug in list images example. thanks Nat Welch
66
+ typo. thanks Nat Welch
67
+ Forgot to update Google Readme. thanks Nat Welch
68
+ allow custom hp_service_type. thanks Omar Reiss
69
+ applied hp_service_type fix on all services. thanks Omar Reiss
70
+ add v1 auth fix #2248. thanks Peter Bonnell
71
+ Add EnableLogging field to FirewallService XML. thanks Philip Potter
72
+ ensuring that edgegateway list elements are list. thanks Sneha Somwanshi
73
+ corrected name of edgegateway generator. thanks Sneha Somwanshi
74
+ tests for configure edge gateways. thanks Sneha Somwanshi
75
+ added comment on test. thanks Sneha Somwanshi
76
+ Add a reload() method to the vSphere service. thanks Timur Alperovich
77
+ Assign service to clone_result before new instance of vm. thanks Xavier Fontrodona
78
+ add end date for aws instance reservations. thanks aabes
79
+ - update compute api version to 2013/10/01 - add 'end' to described_reserved_instance. thanks aabes
80
+ fix mock for purchase ri. thanks aabes
81
+ Update create_server.rb. thanks avic85
82
+ Removed host params for excon connections. thanks ccloes
83
+ Invalid Excon request keys: :host, :port. thanks wenlock
84
+
85
+ [rackspace]
86
+ setting rackspace_region to nil in default tests to override any settings loaded via Fog.credentials. thanks Kyle Rames
87
+
88
+ [rackspace|block_storage]
89
+ fixing merge issue. thanks Kyle Rames
90
+
91
+ [vSphere]
92
+ Implemented feature to specify a socket cpu layout as specified in vmware API. If not used numCoresPerSocket is left out and default VMware behaviour is used. [vSphere] also fixed bug in vm_reconfig_memory: wrong memory value passed to reconfig_hardware (memory in bytes instead of memory in MB). thanks Marc Grimme
93
+
94
+ [vcloud_director]
95
+ improoved tests for #ensure_list!. thanks Dan Abel
96
+ fixes so that non configured gateway are supported. thanks Dan Abel
97
+ Change input options structure. thanks Nick Osborn
98
+ strftime not iso8601 for ruby 1.8.7. thanks Nick Osborn
99
+ Mocking for tasks. thanks Nick Osborn
100
+ strftime not iso8601 for ruby 1.8.7. thanks Nick Osborn
101
+ Consistent usage of ensure_list! in get_disk. thanks Nick Osborn
102
+ Fix ruby 1.9-isms in media_tests. thanks Nick Osborn
103
+
104
+ [vsphere|compute]
105
+ Small code cleanup. thanks Kevin Menard
106
+ cleanup merge conflicts with clone method. thanks Mick Pollard
107
+
108
+
1
109
  1.16.0 10/16/2013 13a86cd41e8ea10022fb822cb0b4340cbf2c023d
2
110
  ==========================================================
3
111
 
@@ -6,8 +6,8 @@ Gem::Specification.new do |s|
6
6
  ## If your rubyforge_project name is different, then edit it and comment out
7
7
  ## the sub! line in the Rakefile
8
8
  s.name = 'fog'
9
- s.version = '1.16.0'
10
- s.date = '2013-10-16'
9
+ s.version = '1.17.0'
10
+ s.date = '2013-10-29'
11
11
  s.rubyforge_project = 'fog'
12
12
 
13
13
  ## Make sure your summary is short. The description may be as long
@@ -50,11 +50,10 @@ Gem::Specification.new do |s|
50
50
  s.add_dependency('net-ssh', '>=2.1.3')
51
51
  s.add_dependency('nokogiri', '~>1.5')
52
52
  s.add_dependency('ruby-hmac')
53
- s.add_dependency('unicode', "~> 0.4.4")
54
53
 
55
54
  ## List your development dependencies here. Development dependencies are
56
55
  ## those that are only needed during development
57
- s.add_development_dependency('jekyll')
56
+ s.add_development_dependency('jekyll') unless RUBY_PLATFORM == 'java'
58
57
  s.add_development_dependency('rake')
59
58
  s.add_development_dependency('rbvmomi')
60
59
  s.add_development_dependency('yard')
@@ -65,7 +64,10 @@ Gem::Specification.new do |s|
65
64
  s.add_development_dependency('fission')
66
65
  s.add_development_dependency('pry')
67
66
  s.add_development_dependency('google-api-client', '~>0.6.2')
68
- # s.add_development_dependency('ruby-libvirt','~>0.4.0')
67
+ s.add_development_dependency('unf')
68
+ if ENV["FOG_USE_LIBVIRT"] && RUBY_PLATFORM != 'java'
69
+ s.add_development_dependency('ruby-libvirt','~>0.4.0')
70
+ end
69
71
 
70
72
  s.files = `git ls-files`.split("\n")
71
73
  s.test_files = `git ls-files -- {spec,tests}/*`.split("\n")
@@ -1,7 +1,13 @@
1
1
  require 'fog/core'
2
2
  require 'fog/aws/credential_fetcher'
3
3
  require 'fog/aws/signaturev4'
4
- require 'unicode'
4
+
5
+ begin
6
+ require 'unf/normalizer'
7
+ rescue LoadError
8
+ Fog::Logger.warning("Unable to load the 'unf' gem. Your AWS strings may not be properly encoded.")
9
+ end
10
+
5
11
  module Fog
6
12
  module AWS
7
13
  extend Fog::Provider
@@ -86,7 +92,7 @@ module Fog
86
92
  end
87
93
 
88
94
  def self.escape(string)
89
- string = Unicode::normalize_C(string)
95
+ string = defined?(::UNF::Normalizer) ? ::UNF::Normalizer.normalize(string, :nfc) : string
90
96
  string.gsub(/([^a-zA-Z0-9_.\-~]+)/) {
91
97
  "%" + $1.unpack("H2" * $1.bytesize).join("%").upcase
92
98
  }
@@ -103,7 +103,6 @@ module Fog
103
103
  :expects => 200,
104
104
  :idempotent => idempotent,
105
105
  :headers => { 'Content-Type' => 'application/x-www-form-urlencoded' },
106
- :host => @host,
107
106
  :method => 'POST',
108
107
  :parser => parser
109
108
  })
@@ -372,7 +372,7 @@ module Fog
372
372
  @region = options[:region] ||= 'us-east-1'
373
373
  @instrumentor = options[:instrumentor]
374
374
  @instrumentor_name = options[:instrumentor_name] || 'fog.aws.compute'
375
- @version = options[:version] || '2013-08-15'
375
+ @version = options[:version] || '2013-10-01'
376
376
 
377
377
  if @endpoint = options[:endpoint]
378
378
  endpoint = URI.parse(@endpoint)
@@ -189,7 +189,6 @@ module Fog
189
189
  :expects => 200,
190
190
  :headers => { 'Content-Type' => 'application/x-www-form-urlencoded' },
191
191
  :idempotent => idempotent,
192
- :host => @host,
193
192
  :method => 'POST',
194
193
  :parser => parser
195
194
  })
@@ -88,6 +88,10 @@ module Fog
88
88
  hash[key] = {
89
89
  :owner_id => Fog::AWS::Mock.owner_id,
90
90
  :server_certificates => {},
91
+ :access_keys => [{
92
+ "Status" => "Active",
93
+ "AccessKeyId" => key
94
+ }],
91
95
  :users => Hash.new do |uhash, ukey|
92
96
  uhash[ukey] = {
93
97
  :user_id => Fog::AWS::Mock.key_id,
@@ -205,7 +209,6 @@ module Fog
205
209
  :expects => 200,
206
210
  :idempotent => idempotent,
207
211
  :headers => { 'Content-Type' => 'application/x-www-form-urlencoded' },
208
- :host => @host,
209
212
  :method => 'POST',
210
213
  :parser => parser
211
214
  })
@@ -14,7 +14,11 @@ module Fog
14
14
  def save
15
15
  requires :username
16
16
 
17
- data = service.create_access_key('UserName'=> username).body["AccessKey"]
17
+ if !persisted?
18
+ data = service.create_access_key('UserName'=> username).body["AccessKey"]
19
+ else
20
+ data = service.update_access_key(id, status, "UserName" => username).body["AccessKey"]
21
+ end
18
22
  merge_attributes(data)
19
23
  true
20
24
  end
@@ -11,7 +11,6 @@ module Fog
11
11
 
12
12
  def initialize(attributes = {})
13
13
  @username = attributes[:username]
14
- raise ArgumentError.new("Can't get an access_key's user without a username") unless @username
15
14
  super
16
15
  end
17
16
 
@@ -23,9 +23,10 @@ module Fog
23
23
  @reserved_instance = {}
24
24
  when 'requestId'
25
25
  @response[name] = value
26
- when 'start'
26
+ when 'start','end'
27
27
  @reserved_instance[name] = Time.parse(value)
28
28
  end
29
+
29
30
  end
30
31
 
31
32
  end
@@ -0,0 +1,37 @@
1
+ module Fog
2
+ module Parsers
3
+ module Storage
4
+ module AWS
5
+
6
+ class GetBucketTagging < Fog::Parsers::Base
7
+
8
+ def reset
9
+ @in_tag = {}
10
+ @response = {'BucketTagging' => {}}
11
+ end
12
+
13
+ def start_element(name, *args)
14
+ super
15
+ if name == 'Tag'
16
+ @in_tag = {}
17
+ end
18
+ end
19
+
20
+ def end_element(name)
21
+ case name
22
+ when 'Tag'
23
+ @response['BucketTagging'].merge!(@in_tag)
24
+ @in_tag = {}
25
+ when 'Key'
26
+ @in_tag[value] = nil
27
+ when 'Value'
28
+ @in_tag = {@in_tag.keys.first => value}
29
+ end
30
+ end
31
+
32
+ end
33
+
34
+ end
35
+ end
36
+ end
37
+ end
@@ -26,7 +26,7 @@ module Fog
26
26
  'Action' => 'CopyImage',
27
27
  'SourceImageId' => source_image_id,
28
28
  'SourceRegion' => source_region,
29
- 'Name' => source_region,
29
+ 'Name' => name,
30
30
  'Description' => description,
31
31
  'ClientToken' => client_token,
32
32
  :parser => Fog::Parsers::Compute::AWS::CopyImage.new
@@ -25,6 +25,7 @@ module Fog
25
25
  # * 'start'<~Time> - start time for reservation
26
26
  # * 'state'<~String> - state of reserved instance purchase, in .[pending-payment, active, payment-failed, retired]
27
27
  # * 'usagePrice"<~Float> - usage price of reserved instances, per hour
28
+ # * 'end' - time reservation stopped being applied (i.e sold or canceled - as of version 2013/10/01)
28
29
  #
29
30
  # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeReservedInstances.html]
30
31
  def describe_reserved_instances(filters = {})
@@ -45,6 +45,7 @@ module Fog
45
45
  self.data[:reserved_instances][reserved_instances_id] = reserved_instance_offering.merge({
46
46
  'reservedInstancesId' => reserved_instances_id,
47
47
  'start' => Time.now,
48
+ 'end' => Time.now,
48
49
  'instanceCount' => instance_count,
49
50
  'state' => 'payment-pending',
50
51
  'tagSet' => []
@@ -36,23 +36,30 @@ module Fog
36
36
  def create_access_key(options)
37
37
  #FIXME: Not 100% correct as AWS will use the signing credentials when there is no 'UserName' in the options hash
38
38
  # Also doesn't raise an error when there are too many keys
39
- user_name = options['UserName']
40
- if data[:users].has_key? user_name
41
- key = { 'SecretAccessKey' => Fog::Mock.random_base64(40),
42
- 'Status' => 'Active',
43
- 'AccessKeyId' => Fog::AWS::Mock.key_id(20),
44
- 'UserName' => user_name
45
- }
46
-
47
- data[:users][user_name][:access_keys] << key
48
-
49
- Excon::Response.new.tap do |response|
50
- response.status = 200
51
- response.body = { 'AccessKey' => key,
52
- 'RequestId' => Fog::AWS::Mock.request_id }
39
+ if user = options['UserName']
40
+ if data[:users].has_key? user
41
+ access_keys_data = data[:users][user][:access_keys]
42
+ else
43
+ raise Fog::AWS::IAM::NotFound.new('The user with name #{user_name} cannot be found.')
53
44
  end
54
45
  else
55
- raise Fog::AWS::IAM::NotFound.new('The user with name booboboboob cannot be found.')
46
+ access_keys_data = data[:access_keys]
47
+ end
48
+
49
+ key = { 'SecretAccessKey' => Fog::Mock.random_base64(40),
50
+ 'Status' => 'Active',
51
+ 'AccessKeyId' => Fog::AWS::Mock.key_id(20),
52
+ }
53
+ if user
54
+ key["UserName"] = user
55
+ end
56
+
57
+ access_keys_data << key
58
+
59
+ Excon::Response.new.tap do |response|
60
+ response.status = 200
61
+ response.body = { 'AccessKey' => key,
62
+ 'RequestId' => Fog::AWS::Mock.request_id }
56
63
  end
57
64
  end
58
65
  end
@@ -40,19 +40,23 @@ module Fog
40
40
 
41
41
  def list_access_keys(options = {})
42
42
  #FIXME: Doesn't do anything with options, aside from UserName
43
- user = options['UserName']
44
-
45
- if data[:users].has_key? user
46
- Excon::Response.new.tap do |response|
47
- response.body = { 'AccessKeys' => data[:users][user][:access_keys].map do |akey|
48
- {'Status' => akey['Status'], 'AccessKeyId' => akey['AccessKeyId']}
49
- end,
50
- 'IsTruncated' => false,
51
- 'RequestId' => Fog::AWS::Mock.request_id }
52
- response.status = 200
43
+ if user = options['UserName']
44
+ if data[:users].has_key? user
45
+ access_keys_data = data[:users][user][:access_keys]
46
+ else
47
+ raise Fog::AWS::IAM::NotFound.new("The user with name #{user} cannot be found.")
53
48
  end
54
49
  else
55
- raise Fog::AWS::IAM::NotFound.new("The user with name #{user} cannot be found.")
50
+ access_keys_data = data[:access_keys]
51
+ end
52
+
53
+ Excon::Response.new.tap do |response|
54
+ response.body = { 'AccessKeys' => access_keys_data.map do |akey|
55
+ {'Status' => akey['Status'], 'AccessKeyId' => akey['AccessKeyId']}
56
+ end,
57
+ 'IsTruncated' => false,
58
+ 'RequestId' => Fog::AWS::Mock.request_id }
59
+ response.status = 200
56
60
  end
57
61
  end
58
62
  end