fog 0.3.25 → 0.3.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/Gemfile.lock +9 -9
  2. data/fog.gemspec +10 -5
  3. data/lib/fog.rb +1 -1
  4. data/lib/fog/aws/compute.rb +1 -1
  5. data/lib/fog/aws/models/compute/address.rb +2 -2
  6. data/lib/fog/aws/models/compute/addresses.rb +44 -0
  7. data/lib/fog/aws/models/compute/flavors.rb +124 -0
  8. data/lib/fog/aws/models/compute/images.rb +31 -3
  9. data/lib/fog/aws/models/compute/key_pairs.rb +48 -0
  10. data/lib/fog/aws/models/compute/security_groups.rb +57 -1
  11. data/lib/fog/aws/models/compute/servers.rb +79 -0
  12. data/lib/fog/aws/models/compute/snapshots.rb +1 -1
  13. data/lib/fog/aws/models/compute/tags.rb +1 -1
  14. data/lib/fog/aws/models/compute/volume.rb +2 -2
  15. data/lib/fog/aws/models/compute/volumes.rb +69 -0
  16. data/lib/fog/aws/requests/cdn/post_distribution.rb +1 -1
  17. data/lib/fog/aws/requests/compute/create_image.rb +7 -1
  18. data/lib/fog/aws/requests/compute/create_snapshot.rb +7 -1
  19. data/lib/fog/bluebox/compute.rb +1 -1
  20. data/lib/fog/go_grid/compute.rb +1 -1
  21. data/lib/fog/new_servers/compute.rb +1 -1
  22. data/lib/fog/rackspace/cdn.rb +1 -1
  23. data/lib/fog/rackspace/compute.rb +5 -1
  24. data/lib/fog/rackspace/models/compute/server.rb +1 -1
  25. data/lib/fog/rackspace/requests/compute/confirm_resized_server.rb +34 -0
  26. data/lib/fog/rackspace/requests/compute/reboot_server.rb +5 -7
  27. data/lib/fog/rackspace/requests/compute/resize_server.rb +39 -0
  28. data/lib/fog/rackspace/requests/compute/revert_resized_server.rb +35 -0
  29. data/lib/fog/rackspace/requests/compute/server_action.rb +33 -0
  30. data/lib/fog/rackspace/storage.rb +1 -1
  31. data/lib/fog/slicehost/compute.rb +1 -1
  32. data/spec/aws/models/compute/volume_spec.rb +50 -28
  33. data/spec/aws/models/compute/volumes_spec.rb +1 -1
  34. data/tests/aws/requests/storage/bucket_tests.rb +6 -5
  35. data/tests/helper.rb +4 -0
  36. data/tests/rackspace/requests/compute/resize_tests.rb +47 -0
  37. metadata +14 -10
@@ -10,12 +10,8 @@ module Fog
10
10
  # * type<~String> - Type of reboot, must be in ['HARD', 'SOFT']
11
11
  #
12
12
  def reboot_server(server_id, type = 'SOFT')
13
- request(
14
- :body => { 'reboot' => { 'type' => type }}.to_json,
15
- :expects => 202,
16
- :method => 'POST',
17
- :path => "servers/#{server_id}/action.json"
18
- )
13
+ body = { 'reboot' => { 'type' => type }}
14
+ server_action(server_id, body)
19
15
  end
20
16
 
21
17
  end
@@ -23,7 +19,9 @@ module Fog
23
19
  class Mock
24
20
 
25
21
  def reboot_server(server_id, type = 'SOFT')
26
- Fog::Mock.not_implemented
22
+ response = Excon::Response.new
23
+ response.status = 202
24
+ response
27
25
  end
28
26
 
29
27
  end
@@ -0,0 +1,39 @@
1
+ module Fog
2
+ module Rackspace
3
+ class Compute
4
+ class Real
5
+
6
+ # Reboot an existing server
7
+ #
8
+ # ==== Parameters
9
+ # * server_id<~Integer> - Id of server to resize
10
+ # * size<~String> - new size. call list_flavors to get available flavors
11
+ #
12
+ def resize_server(server_id, flavor_id)
13
+ body = { 'resize' => { 'flavorId' => flavor_id }}
14
+ server_action(server_id, body)
15
+ end
16
+
17
+ end
18
+
19
+ class Mock
20
+
21
+ # FIXME: should probably transition instead of skipping to VERIFY_RESIZE
22
+ def resize_server(server_id, flavor_id)
23
+ response = Excon::Response.new
24
+ response.status = 202
25
+
26
+ # keep track of this for reverts
27
+ @data[:servers][server_id]['old_flavorId'] = @data[:servers][server_id]['flavorId']
28
+
29
+ @data[:servers][server_id]['flavorId'] = flavor_id
30
+ @data[:last_modified][:servers][server_id] = Time.now
31
+ @data[:servers][server_id]['status'] = 'VERIFY_RESIZE'
32
+
33
+ response
34
+ end
35
+
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,35 @@
1
+ module Fog
2
+ module Rackspace
3
+ class Compute
4
+ class Real
5
+
6
+ # Revert resizing
7
+ #
8
+ # ==== Parameters
9
+ # * server_id<~Integer> - Id of server to revert
10
+ #
11
+ def revert_resized_server(server_id)
12
+ body = { 'revertResize' => nil }
13
+ server_action(server_id, body)
14
+ end
15
+
16
+ end
17
+
18
+ class Mock
19
+
20
+ def revert_resized_server(server_id)
21
+ response = Excon::Response.new
22
+ response.status = 202
23
+
24
+ @data[:servers][server_id]['flavorId'] = @data[:servers][server_id]['old_flavorId']
25
+ @data[:servers][server_id].delete('old_flavorId')
26
+ @data[:last_modified][:servers][server_id] = Time.now
27
+ @data[:servers][server_id]['status'] = 'ACTIVE'
28
+
29
+ response
30
+ end
31
+
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,33 @@
1
+ module Fog
2
+ module Rackspace
3
+ class Compute
4
+ class Real
5
+
6
+ # Reboot an existing server
7
+ #
8
+ # ==== Parameters
9
+ # * server_id<~Integer> - Id of server to reboot
10
+ # * body<~.to_json object> - Body of the request, describes the action (see reboot_server as an example)
11
+ # * expect<~Integer> - expected return, 202 except for confirm resize (204)
12
+ #
13
+ def server_action(server_id, body, expects=202)
14
+ request(
15
+ :body => body.to_json,
16
+ :expects => expects,
17
+ :method => 'POST',
18
+ :path => "servers/#{server_id}/action.json"
19
+ )
20
+ end
21
+
22
+ end
23
+
24
+ class Mock
25
+
26
+ def server_action(server_id, body)
27
+ Fog::Mock.not_implemented
28
+ end
29
+
30
+ end
31
+ end
32
+ end
33
+ end
@@ -111,7 +111,7 @@ module Fog
111
111
  :host => @host,
112
112
  :path => "#{@path}/#{params[:path]}",
113
113
  }), &block)
114
- rescue Excon::Errors::Error => error
114
+ rescue Excon::Errors::HTTPStatusError => error
115
115
  raise case error
116
116
  when Excon::Errors::NotFound
117
117
  Fog::Rackspace::Storage::NotFound.slurp(error)
@@ -73,7 +73,7 @@ module Fog
73
73
 
74
74
  begin
75
75
  response = @connection.request(params.merge!({:host => @host}))
76
- rescue Excon::Errors::Error => error
76
+ rescue Excon::Errors::HTTPStatusError => error
77
77
  raise case error
78
78
  when Excon::Errors::NotFound
79
79
  Fog::Slicehost::Compute::NotFound.slurp(error)
@@ -67,42 +67,64 @@ describe 'Fog::AWS::Compute::Volume' do
67
67
  @volume = AWS[:compute].volumes.new(:availability_zone => @server.availability_zone, :size => 1, :device => '/dev/sdz1')
68
68
  end
69
69
 
70
- after(:each) do
71
- if @volume.id
72
- @volume.wait_for { state == 'in-use' }
73
- @volume.server = nil
74
- @volume.wait_for { ready? }
75
- @volume.destroy
70
+ describe "when set to a server" do
71
+ after(:each) do
72
+ if @volume.id
73
+ @volume.wait_for { state == 'in-use' }
74
+ @volume.server = nil
75
+ @volume.wait_for { ready? }
76
+ @volume.destroy
77
+ end
76
78
  end
77
- end
78
79
 
79
- it "should not attach to server if the volume has not been saved" do
80
- @volume.server = @server
81
- @volume.server_id.should_not == @server.id
82
- end
80
+ it "should not attach to server if the volume has not been saved" do
81
+ @volume.server = @server
82
+ @volume.server_id.should_not == @server.id
83
+ end
83
84
 
84
- it "should change the availability_zone if the volume has not been saved" do
85
- @volume.server = @server
86
- @volume.availability_zone.should == @server.availability_zone
87
- end
85
+ it "should change the availability_zone if the volume has not been saved" do
86
+ @volume.server = @server
87
+ @volume.availability_zone.should == @server.availability_zone
88
+ end
88
89
 
89
- it "should attach to server when the volume is saved" do
90
- @volume.server = @server
91
- @volume.save.should be_true
92
- @volume.server_id.should == @server.id
93
- end
90
+ it "should attach to server when the volume is saved" do
91
+ @volume.server = @server
92
+ @volume.save.should be_true
93
+ @volume.server_id.should == @server.id
94
+ end
95
+
96
+ it "should attach to server to an already saved volume" do
97
+ @volume.save.should be_true
98
+ @volume.server = @server
99
+ @volume.server_id.should == @server.id
100
+ end
101
+
102
+ it "should not change the availability_zone if the volume has been saved" do
103
+ @volume.save.should be_true
104
+ @volume.server = @server
105
+ @volume.availability_zone.should == @server.availability_zone
106
+ end
94
107
 
95
- it "should attach to server to an already saved volume" do
96
- @volume.save.should be_true
97
- @volume.server = @server
98
- @volume.server_id.should == @server.id
99
108
  end
100
109
 
101
- it "should not change the availability_zone if the volume has been saved" do
102
- @volume.save.should be_true
103
- @volume.server = @server
104
- @volume.availability_zone.should == @server.availability_zone
110
+ describe "when set to nil" do
111
+ after(:each) do
112
+ @volume.destroy
113
+ end
114
+
115
+ it "should detach from server if the volume has been saved" do
116
+ @volume.server = @server
117
+ @volume.save.should be_true
118
+ @server.reload.volumes.map(&:id).should include(@volume.id)
119
+
120
+ @volume.server = nil
121
+ @volume.wait_for { ready? }
122
+ @volume.server_id.should be_nil
123
+ @server.reload.volumes.map(&:id).should_not include(@volume.id)
124
+ end
125
+
105
126
  end
127
+
106
128
  end
107
129
 
108
130
  describe "#reload" do
@@ -39,7 +39,7 @@ describe 'Fog::AWS::Compute::Volumes' do
39
39
  describe "#get" do
40
40
 
41
41
  it "should return a Fog::AWS::Compute::Volume if a matching volume exists" do
42
- volume = AWS[:compute].volumes.create(:availability_zone => 'us-east-1a', :size => 1, :device => 'dev/sdz1')
42
+ volume = AWS[:compute].volumes.create(:availability_zone => 'us-east-1a', :size => 1)
43
43
  volume.wait_for { ready? }
44
44
  get = AWS[:compute].volumes.get(volume.id)
45
45
  volume.attributes.should == get.attributes
@@ -3,11 +3,12 @@ Shindo.tests('AWS::Storage | bucket requests', ['aws']) do
3
3
  tests('success') do
4
4
 
5
5
  @bucket_format = {
6
- 'IsTruncated' => Fog::Boolean,
7
- 'Marker' => NilClass,
8
- 'MaxKeys' => Integer,
9
- 'Name' => String,
10
- 'Prefix' => NilClass,
6
+ 'CommonPrefixes' => [],
7
+ 'IsTruncated' => Fog::Boolean,
8
+ 'Marker' => NilClass,
9
+ 'MaxKeys' => Integer,
10
+ 'Name' => String,
11
+ 'Prefix' => NilClass,
11
12
  'Contents' => [{
12
13
  'ETag' => String,
13
14
  'Key' => String,
@@ -24,6 +24,10 @@ require 'tests/helpers/storage/directories_tests'
24
24
  require 'tests/helpers/storage/file_tests'
25
25
  require 'tests/helpers/storage/files_tests'
26
26
 
27
+ # Use so you can run in mock mode from the command line:
28
+ #
29
+ # FOG_MOCK=true fog
30
+
27
31
  if ENV["FOG_MOCK"] == "true"
28
32
  Fog.mock!
29
33
  end
@@ -0,0 +1,47 @@
1
+ Shindo.tests('Rackspace::Compute | resize request', ['rackspace']) do
2
+
3
+ tests('confirm') do
4
+
5
+ @server = Rackspace[:compute].servers.create(:flavor_id => 1, :image_id => 19)
6
+
7
+ @server.wait_for { ready? }
8
+
9
+ tests("#resize_server(#{@server.id}, 2)").succeeds do
10
+ Rackspace[:compute].resize_server(@server.id, 2)
11
+ end
12
+
13
+ @server.wait_for { status == 'VERIFY_RESIZE' }
14
+
15
+ tests("#confirm_resized_server(#{@server.id})").succeeds do
16
+ Rackspace[:compute].confirm_resized_server(@server.id)
17
+ end
18
+
19
+ @server.wait_for { ready? }
20
+
21
+ @server.destroy
22
+
23
+ end
24
+
25
+ tests('revert') do
26
+
27
+ @server = Rackspace[:compute].servers.create(:flavor_id => 1, :image_id => 19)
28
+
29
+ @server.wait_for { ready? }
30
+
31
+ tests("#resize_server(#{@server.id}, 2)").succeeds do
32
+ Rackspace[:compute].resize_server(@server.id, 2)
33
+ end
34
+
35
+ @server.wait_for { status == 'VERIFY_RESIZE' }
36
+
37
+ tests("#revert_resized_server(#{@server.id})").succeeds do
38
+ Rackspace[:compute].revert_resized_server(@server.id)
39
+ end
40
+
41
+ @server.wait_for { ready? }
42
+
43
+ @server.destroy
44
+
45
+ end
46
+
47
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 25
9
- version: 0.3.25
8
+ - 26
9
+ version: 0.3.26
10
10
  platform: ruby
11
11
  authors:
12
12
  - geemus (Wesley Beary)
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-23 00:00:00 -08:00
17
+ date: 2010-12-01 00:00:00 -08:00
18
18
  default_executable: fog
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -39,8 +39,8 @@ dependencies:
39
39
  segments:
40
40
  - 0
41
41
  - 2
42
- - 4
43
- version: 0.2.4
42
+ - 8
43
+ version: 0.2.8
44
44
  requirement: *id002
45
45
  name: excon
46
46
  - !ruby/object:Gem::Dependency
@@ -86,7 +86,7 @@ dependencies:
86
86
  type: :runtime
87
87
  version_requirements: &id006 !ruby/object:Gem::Requirement
88
88
  requirements:
89
- - - ~>
89
+ - - ">="
90
90
  - !ruby/object:Gem::Version
91
91
  segments:
92
92
  - 2
@@ -100,14 +100,13 @@ dependencies:
100
100
  type: :runtime
101
101
  version_requirements: &id007 !ruby/object:Gem::Requirement
102
102
  requirements:
103
- - - ~>
103
+ - - ">="
104
104
  - !ruby/object:Gem::Version
105
105
  segments:
106
106
  - 1
107
107
  - 4
108
- - 3
109
- - 1
110
- version: 1.4.3.1
108
+ - 4
109
+ version: 1.4.4
111
110
  requirement: *id007
112
111
  name: nokogiri
113
112
  - !ruby/object:Gem::Dependency
@@ -571,6 +570,7 @@ files:
571
570
  - lib/fog/rackspace/requests/cdn/get_containers.rb
572
571
  - lib/fog/rackspace/requests/cdn/head_container.rb
573
572
  - lib/fog/rackspace/requests/cdn/put_container.rb
573
+ - lib/fog/rackspace/requests/compute/confirm_resized_server.rb
574
574
  - lib/fog/rackspace/requests/compute/create_image.rb
575
575
  - lib/fog/rackspace/requests/compute/create_server.rb
576
576
  - lib/fog/rackspace/requests/compute/delete_image.rb
@@ -588,6 +588,9 @@ files:
588
588
  - lib/fog/rackspace/requests/compute/list_servers.rb
589
589
  - lib/fog/rackspace/requests/compute/list_servers_detail.rb
590
590
  - lib/fog/rackspace/requests/compute/reboot_server.rb
591
+ - lib/fog/rackspace/requests/compute/resize_server.rb
592
+ - lib/fog/rackspace/requests/compute/revert_resized_server.rb
593
+ - lib/fog/rackspace/requests/compute/server_action.rb
591
594
  - lib/fog/rackspace/requests/compute/update_server.rb
592
595
  - lib/fog/rackspace/requests/storage/delete_container.rb
593
596
  - lib/fog/rackspace/requests/storage/delete_object.rb
@@ -910,6 +913,7 @@ files:
910
913
  - tests/rackspace/requests/compute/address_tests.rb
911
914
  - tests/rackspace/requests/compute/flavor_tests.rb
912
915
  - tests/rackspace/requests/compute/image_tests.rb
916
+ - tests/rackspace/requests/compute/resize_tests.rb
913
917
  - tests/rackspace/requests/compute/server_tests.rb
914
918
  - tests/rackspace/requests/storage/container_tests.rb
915
919
  - tests/rackspace/requests/storage/object_tests.rb