fog 0.0.31 → 0.0.32
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +0 -2
- data/Rakefile +12 -7
- data/VERSION +1 -1
- data/bin/fog +16 -18
- data/fog.gemspec +34 -8
- data/lib/fog.rb +11 -0
- data/lib/fog/aws/models/ec2/address.rb +4 -0
- data/lib/fog/aws/models/ec2/instance.rb +17 -0
- data/lib/fog/aws/models/ec2/key_pair.rb +4 -0
- data/lib/fog/aws/models/ec2/security_group.rb +8 -0
- data/lib/fog/aws/models/ec2/snapshot.rb +7 -1
- data/lib/fog/aws/models/ec2/volume.rb +9 -1
- data/lib/fog/aws/models/s3/bucket.rb +10 -0
- data/lib/fog/aws/models/s3/buckets.rb +10 -4
- data/lib/fog/aws/models/s3/object.rb +5 -0
- data/lib/fog/aws/requests/ec2/allocate_address.rb +1 -1
- data/lib/fog/aws/requests/ec2/associate_address.rb +2 -2
- data/lib/fog/aws/requests/ec2/attach_volume.rb +2 -2
- data/lib/fog/aws/requests/ec2/authorize_security_group_ingress.rb +1 -1
- data/lib/fog/aws/requests/ec2/create_key_pair.rb +2 -2
- data/lib/fog/aws/requests/ec2/create_security_group.rb +2 -2
- data/lib/fog/aws/requests/ec2/create_snapshot.rb +2 -2
- data/lib/fog/aws/requests/ec2/create_volume.rb +1 -1
- data/lib/fog/aws/requests/ec2/delete_key_pair.rb +1 -1
- data/lib/fog/aws/requests/ec2/delete_security_group.rb +2 -2
- data/lib/fog/aws/requests/ec2/delete_snapshot.rb +2 -2
- data/lib/fog/aws/requests/ec2/delete_volume.rb +2 -2
- data/lib/fog/aws/requests/ec2/describe_addresses.rb +2 -2
- data/lib/fog/aws/requests/ec2/describe_availability_zones.rb +1 -1
- data/lib/fog/aws/requests/ec2/describe_images.rb +1 -1
- data/lib/fog/aws/requests/ec2/describe_instances.rb +2 -2
- data/lib/fog/aws/requests/ec2/describe_key_pairs.rb +2 -2
- data/lib/fog/aws/requests/ec2/describe_regions.rb +1 -1
- data/lib/fog/aws/requests/ec2/describe_security_groups.rb +2 -2
- data/lib/fog/aws/requests/ec2/describe_snapshots.rb +2 -2
- data/lib/fog/aws/requests/ec2/describe_volumes.rb +2 -2
- data/lib/fog/aws/requests/ec2/detach_volume.rb +2 -2
- data/lib/fog/aws/requests/ec2/disassociate_address.rb +2 -2
- data/lib/fog/aws/requests/ec2/get_console_output.rb +2 -2
- data/lib/fog/aws/requests/ec2/reboot_instances.rb +2 -2
- data/lib/fog/aws/requests/ec2/release_address.rb +2 -2
- data/lib/fog/aws/requests/ec2/revoke_security_group_ingress.rb +1 -1
- data/lib/fog/aws/requests/ec2/run_instances.rb +1 -1
- data/lib/fog/aws/requests/ec2/terminate_instances.rb +2 -2
- data/lib/fog/aws/requests/s3/copy_object.rb +2 -2
- data/lib/fog/aws/requests/s3/delete_bucket.rb +3 -3
- data/lib/fog/aws/requests/s3/delete_object.rb +8 -7
- data/lib/fog/aws/requests/s3/get_bucket.rb +2 -2
- data/lib/fog/aws/requests/s3/get_bucket_location.rb +2 -2
- data/lib/fog/aws/requests/s3/get_object.rb +2 -2
- data/lib/fog/aws/requests/s3/get_request_payment.rb +2 -2
- data/lib/fog/aws/requests/s3/get_service.rb +1 -1
- data/lib/fog/aws/requests/s3/put_bucket.rb +8 -6
- data/lib/fog/aws/requests/s3/put_object.rb +9 -9
- data/lib/fog/aws/requests/s3/put_request_payment.rb +2 -2
- data/lib/fog/aws/requests/simpledb/batch_put_attributes.rb +2 -2
- data/lib/fog/aws/requests/simpledb/create_domain.rb +1 -1
- data/lib/fog/aws/requests/simpledb/delete_attributes.rb +2 -2
- data/lib/fog/aws/requests/simpledb/delete_domain.rb +1 -1
- data/lib/fog/aws/requests/simpledb/domain_metadata.rb +2 -2
- data/lib/fog/aws/requests/simpledb/get_attributes.rb +2 -2
- data/lib/fog/aws/requests/simpledb/list_domains.rb +1 -1
- data/lib/fog/aws/s3.rb +1 -12
- data/lib/fog/collection.rb +16 -8
- data/lib/fog/model.rb +36 -14
- data/lib/fog/rackspace/models/servers/image.rb +40 -0
- data/lib/fog/rackspace/models/servers/images.rb +50 -0
- data/lib/fog/rackspace/models/servers/server.rb +18 -2
- data/lib/fog/rackspace/requests/servers/create_image.rb +18 -1
- data/lib/fog/rackspace/requests/servers/create_server.rb +5 -5
- data/lib/fog/rackspace/requests/servers/delete_image.rb +16 -1
- data/lib/fog/rackspace/requests/servers/delete_server.rb +4 -4
- data/lib/fog/rackspace/requests/servers/get_server_details.rb +2 -2
- data/lib/fog/rackspace/requests/servers/list_addresses.rb +2 -2
- data/lib/fog/rackspace/requests/servers/list_images.rb +10 -0
- data/lib/fog/rackspace/requests/servers/list_images_detail.rb +16 -1
- data/lib/fog/rackspace/requests/servers/list_private_addresses.rb +2 -2
- data/lib/fog/rackspace/requests/servers/list_public_addresses.rb +2 -2
- data/lib/fog/rackspace/requests/servers/list_servers.rb +1 -1
- data/lib/fog/rackspace/requests/servers/list_servers_detail.rb +2 -2
- data/lib/fog/rackspace/requests/servers/update_server.rb +2 -2
- data/lib/fog/rackspace/servers.rb +8 -2
- data/lib/fog/slicehost.rb +66 -0
- data/lib/fog/slicehost/parsers/create_slice.rb +29 -0
- data/lib/fog/slicehost/parsers/get_backups.rb +30 -0
- data/lib/fog/slicehost/parsers/get_flavors.rb +28 -0
- data/lib/fog/slicehost/parsers/get_images.rb +28 -0
- data/lib/fog/slicehost/parsers/get_slices.rb +33 -0
- data/lib/fog/slicehost/requests/create_slice.rb +50 -0
- data/lib/fog/slicehost/requests/delete_slice.rb +48 -0
- data/lib/fog/slicehost/requests/get_backups.rb +38 -0
- data/lib/fog/slicehost/requests/get_flavors.rb +38 -0
- data/lib/fog/slicehost/requests/get_images.rb +36 -0
- data/lib/fog/slicehost/requests/get_slices.rb +44 -0
- data/spec/aws/requests/s3/put_object_spec.rb +8 -0
- data/spec/rackspace/requests/servers/create_image_spec.rb +1 -1
- data/spec/rackspace/requests/servers/create_server_spec.rb +1 -1
- data/spec/rackspace/requests/servers/delete_image_spec.rb +7 -5
- data/spec/rackspace/requests/servers/delete_server_spec.rb +1 -1
- data/spec/rackspace/requests/servers/get_server_details_spec.rb +1 -1
- data/spec/rackspace/requests/servers/list_addresses_spec.rb +1 -1
- data/spec/rackspace/requests/servers/list_private_addresses_spec.rb +1 -1
- data/spec/rackspace/requests/servers/list_public_addresses_spec.rb +1 -1
- data/spec/rackspace/requests/servers/list_servers_detail_spec.rb +1 -1
- data/spec/rackspace/requests/servers/list_servers_spec.rb +1 -1
- data/spec/rackspace/requests/servers/reboot_server_spec.rb +1 -1
- data/spec/rackspace/requests/servers/update_server_spec.rb +1 -1
- data/spec/slicehost/requests/create_slice_spec.rb +29 -0
- data/spec/slicehost/requests/delete_slice_spec.rb +18 -0
- data/spec/slicehost/requests/get_backups_spec.rb +17 -0
- data/spec/slicehost/requests/get_flavors_spec.rb +17 -0
- data/spec/slicehost/requests/get_images_spec.rb +15 -0
- data/spec/slicehost/requests/get_slices_spec.rb +23 -0
- data/spec/spec_helper.rb +20 -22
- metadata +29 -4
- data/lib/fog/aws/models/s3/owner.rb +0 -18
data/lib/fog/collection.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
module Fog
|
2
2
|
class Collection < Array
|
3
3
|
|
4
|
+
def self._load(marhsalled)
|
5
|
+
new(Marshal.load(marshalled))
|
6
|
+
end
|
7
|
+
|
4
8
|
def self.attribute(name, other_names = [])
|
5
9
|
class_eval <<-EOS, __FILE__, __LINE__
|
6
10
|
attr_accessor :#{name}
|
@@ -24,6 +28,10 @@ module Fog
|
|
24
28
|
@attributes ||= []
|
25
29
|
end
|
26
30
|
|
31
|
+
def _dump
|
32
|
+
Marshal.dump(attributes)
|
33
|
+
end
|
34
|
+
|
27
35
|
def attributes
|
28
36
|
attributes = {}
|
29
37
|
for attribute in self.class.attributes
|
@@ -32,6 +40,14 @@ module Fog
|
|
32
40
|
attributes
|
33
41
|
end
|
34
42
|
|
43
|
+
def connection=(new_connection)
|
44
|
+
@connection = new_connection
|
45
|
+
end
|
46
|
+
|
47
|
+
def connection
|
48
|
+
@connection
|
49
|
+
end
|
50
|
+
|
35
51
|
def create(attributes = {})
|
36
52
|
object = new(attributes)
|
37
53
|
object.save
|
@@ -85,14 +101,6 @@ module Fog
|
|
85
101
|
|
86
102
|
private
|
87
103
|
|
88
|
-
def connection=(new_connection)
|
89
|
-
@connection = new_connection
|
90
|
-
end
|
91
|
-
|
92
|
-
def connection
|
93
|
-
@connection
|
94
|
-
end
|
95
|
-
|
96
104
|
def remap_attributes(attributes, mapping)
|
97
105
|
for key, value in mapping
|
98
106
|
if attributes.key?(key)
|
data/lib/fog/model.rb
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
module Fog
|
2
2
|
class Model
|
3
3
|
|
4
|
+
def self._load(marshalled)
|
5
|
+
new(Marshal.load(marshalled))
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.aliases
|
9
|
+
@aliases ||= {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.attributes
|
13
|
+
@attributes ||= []
|
14
|
+
end
|
15
|
+
|
4
16
|
def self.attribute(name, other_names = [])
|
5
17
|
class_eval <<-EOS, __FILE__, __LINE__
|
6
18
|
attr_accessor :#{name}
|
@@ -17,12 +29,8 @@ module Fog
|
|
17
29
|
self.attribute(name, other_names)
|
18
30
|
end
|
19
31
|
|
20
|
-
def
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.attributes
|
25
|
-
@attributes ||= []
|
32
|
+
def _dump
|
33
|
+
Marshal.dump(attributes)
|
26
34
|
end
|
27
35
|
|
28
36
|
def attributes
|
@@ -37,6 +45,14 @@ module Fog
|
|
37
45
|
@collection
|
38
46
|
end
|
39
47
|
|
48
|
+
def connection=(new_connection)
|
49
|
+
@connection = new_connection
|
50
|
+
end
|
51
|
+
|
52
|
+
def connection
|
53
|
+
@connection
|
54
|
+
end
|
55
|
+
|
40
56
|
def identity
|
41
57
|
send(self.class.instance_variable_get('@identity'))
|
42
58
|
end
|
@@ -73,20 +89,26 @@ module Fog
|
|
73
89
|
merge_attributes(new_attributes)
|
74
90
|
end
|
75
91
|
|
92
|
+
def requires(*args)
|
93
|
+
missing = []
|
94
|
+
for arg in [:connection] | args
|
95
|
+
missing << arg unless send("#{arg}")
|
96
|
+
end
|
97
|
+
unless missing.empty?
|
98
|
+
if missing.length == 1
|
99
|
+
raise(ArgumentError, "#{missing.first} is required for this operation")
|
100
|
+
else
|
101
|
+
raise(ArgumentError, "#{missing[0...-1].join(", ")} and #{missing[-1]} are required for this operation")
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
76
106
|
private
|
77
107
|
|
78
108
|
def collection=(new_collection)
|
79
109
|
@collection = new_collection
|
80
110
|
end
|
81
111
|
|
82
|
-
def connection=(new_connection)
|
83
|
-
@connection = new_connection
|
84
|
-
end
|
85
|
-
|
86
|
-
def connection
|
87
|
-
@connection
|
88
|
-
end
|
89
|
-
|
90
112
|
def remap_attributes(attributes, mapping)
|
91
113
|
for key, value in mapping
|
92
114
|
if attributes.key?(key)
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Fog
|
2
|
+
module Rackspace
|
3
|
+
class Servers
|
4
|
+
|
5
|
+
class Image < Fog::Model
|
6
|
+
|
7
|
+
identity :id
|
8
|
+
|
9
|
+
attribute :name
|
10
|
+
attribute :created
|
11
|
+
attribute :updated
|
12
|
+
attribute :status
|
13
|
+
attribute :server_id, 'serverId'
|
14
|
+
|
15
|
+
def server=(new_server)
|
16
|
+
requires :id
|
17
|
+
|
18
|
+
@server_id = new_server.id
|
19
|
+
end
|
20
|
+
|
21
|
+
def destroy
|
22
|
+
requires :id
|
23
|
+
|
24
|
+
connection.delete_image(@id)
|
25
|
+
true
|
26
|
+
end
|
27
|
+
|
28
|
+
def save
|
29
|
+
requires :server_id
|
30
|
+
|
31
|
+
data = connection.create_server(@server_id)
|
32
|
+
merge_attributes(data.body['image'])
|
33
|
+
true
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Fog
|
2
|
+
module Rackspace
|
3
|
+
class Servers
|
4
|
+
|
5
|
+
def addresses(attributes = {})
|
6
|
+
Fog::AWS::EC2::Addresses.new({
|
7
|
+
:connection => self
|
8
|
+
}.merge!(attributes))
|
9
|
+
end
|
10
|
+
|
11
|
+
def images(attributes = {})
|
12
|
+
Fog::Rackspace::Servers::Images.new({
|
13
|
+
:connection => self
|
14
|
+
}.merge!(attributes))
|
15
|
+
end
|
16
|
+
|
17
|
+
class Images < Fog::Collection
|
18
|
+
|
19
|
+
model Fog::Rackspace::Servers::Image
|
20
|
+
|
21
|
+
attribute :server
|
22
|
+
|
23
|
+
def all
|
24
|
+
data = connection.list_images_detail.body
|
25
|
+
servers = Fog::Rackspace::Servers::Images.new({
|
26
|
+
:connection => connection
|
27
|
+
})
|
28
|
+
for image in data['images']
|
29
|
+
servers << Fog::Rackspace::Servers::Image.new({
|
30
|
+
:collection => images,
|
31
|
+
:connection => connection
|
32
|
+
}.merge!(image))
|
33
|
+
end
|
34
|
+
if server
|
35
|
+
images = images.select {|image| image.server_id == server.id}
|
36
|
+
end
|
37
|
+
images
|
38
|
+
end
|
39
|
+
|
40
|
+
def get(image_id)
|
41
|
+
connection.get_image_details(image_id)
|
42
|
+
rescue Excon::Errors::NotFound
|
43
|
+
nil
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -18,14 +18,30 @@ module Fog
|
|
18
18
|
attribute :metadata
|
19
19
|
|
20
20
|
def destroy
|
21
|
+
requires :id
|
22
|
+
|
21
23
|
connection.delete_server(@id)
|
22
24
|
true
|
23
25
|
end
|
24
26
|
|
27
|
+
def images
|
28
|
+
requires :id
|
29
|
+
|
30
|
+
connection.images(:server => self)
|
31
|
+
end
|
32
|
+
|
33
|
+
def reboot(type = 'SOFT')
|
34
|
+
requires :id
|
35
|
+
|
36
|
+
connection.reboot_server(@id, type)
|
37
|
+
true
|
38
|
+
end
|
39
|
+
|
25
40
|
def save
|
26
|
-
|
41
|
+
requires :flavor_id, :image_id, :name
|
42
|
+
options = { 'metadata' => @metadata, 'personality' => @personality }
|
27
43
|
options = options.reject {|key, value| value.nil?}
|
28
|
-
data = connection.create_server(@flavor_id, @image_id, options)
|
44
|
+
data = connection.create_server(@flavor_id, @image_id, @name, options)
|
29
45
|
merge_attributes(data.body['server'])
|
30
46
|
true
|
31
47
|
end
|
@@ -43,7 +43,24 @@ else
|
|
43
43
|
module Rackspace
|
44
44
|
class Servers
|
45
45
|
|
46
|
-
def create_image
|
46
|
+
def create_image(server_id, options = {})
|
47
|
+
response = Excon::Response.new
|
48
|
+
response.status = 202
|
49
|
+
|
50
|
+
now = Time.now
|
51
|
+
data = {
|
52
|
+
'created' => now,
|
53
|
+
'id' => 123456,
|
54
|
+
'name' => options['name'] || '',
|
55
|
+
'serverId' => server_id,
|
56
|
+
'status' => 'SAVING',
|
57
|
+
'updated' => now,
|
58
|
+
}
|
59
|
+
|
60
|
+
Fog::Rackspace::Servers.data[:last_modified][:images][data['id']] = now
|
61
|
+
Fog::Rackspace::Servers.data[:images][data['id']] = data
|
62
|
+
response.body = { 'image' => data.reject {|key, value| !['id', 'name', 'serverId'].include?(key)} }
|
63
|
+
response
|
47
64
|
end
|
48
65
|
|
49
66
|
end
|
@@ -34,7 +34,7 @@ unless Fog.mocking?
|
|
34
34
|
# * 'name<~String> - Name of server
|
35
35
|
# * 'progress'<~Integer> - Progress through current status
|
36
36
|
# * 'status'<~String> - Current server status
|
37
|
-
def create_server(flavor_id, image_id, options = {})
|
37
|
+
def create_server(flavor_id, image_id, name, options = {})
|
38
38
|
data = {
|
39
39
|
'server' => {
|
40
40
|
'flavorId' => flavor_id,
|
@@ -74,8 +74,8 @@ else
|
|
74
74
|
module Rackspace
|
75
75
|
class Servers
|
76
76
|
|
77
|
-
def create_server(flavor_id, image_id, options = {})
|
78
|
-
response =
|
77
|
+
def create_server(flavor_id, image_id, name, options = {})
|
78
|
+
response = Excon::Response.new
|
79
79
|
response.status = 202
|
80
80
|
|
81
81
|
data = {
|
@@ -85,12 +85,12 @@ else
|
|
85
85
|
'imageId' => image_id,
|
86
86
|
'hostId' => "123456789ABCDEF01234567890ABCDEF",
|
87
87
|
'metadata' => options[:metadata] || {},
|
88
|
+
'name' => name,
|
88
89
|
'progress' => 0,
|
89
90
|
'status' => 'BUILD'
|
90
91
|
}
|
91
|
-
data['name'] = "slice#{data[:id]}"
|
92
92
|
data['adminPass'] = "#{data['name']}password"
|
93
|
-
Fog::Rackspace::Servers.data[:last_modified][data['id']] = Time.now
|
93
|
+
Fog::Rackspace::Servers.data[:last_modified][:servers][data['id']] = Time.now
|
94
94
|
Fog::Rackspace::Servers.data[:servers][data['id']] = data
|
95
95
|
response.body = { 'server' => data }
|
96
96
|
response
|
@@ -27,7 +27,22 @@ else
|
|
27
27
|
module Rackspace
|
28
28
|
class Servers
|
29
29
|
|
30
|
-
def delete_image
|
30
|
+
def delete_image(image_id)
|
31
|
+
response = Excon::Response.new
|
32
|
+
if image = list_images_detail.body['images'].detect {|image| image['id'] == image_id}
|
33
|
+
if image['status'] == 'SAVING'
|
34
|
+
response.status = 409
|
35
|
+
raise(Excon::Errors.status_error({:expects => 202}, response))
|
36
|
+
else
|
37
|
+
Fog::Rackspace::Servers.data[:last_modified][:images].delete(image_id)
|
38
|
+
Fog::Rackspace::Servers.data[:images].delete(image_id)
|
39
|
+
response.status = 202
|
40
|
+
end
|
41
|
+
else
|
42
|
+
response.status = 400
|
43
|
+
raise(Excon::Errors.status_error({:expects => 202}, response))
|
44
|
+
end
|
45
|
+
response
|
31
46
|
end
|
32
47
|
|
33
48
|
end
|
@@ -28,19 +28,19 @@ else
|
|
28
28
|
class Servers
|
29
29
|
|
30
30
|
def delete_server(server_id)
|
31
|
-
response =
|
31
|
+
response = Excon::Response.new
|
32
32
|
if server = list_servers_detail.body['servers'].detect { |server| server['id'] == server_id }
|
33
33
|
if server['status'] == 'BUILD'
|
34
34
|
response.status = 409
|
35
|
-
raise(Excon::Errors.status_error(202,
|
35
|
+
raise(Excon::Errors.status_error({:expects => 202}, response))
|
36
36
|
else
|
37
|
-
Fog::Rackspace::Servers.data[:last_modified].delete(server_id)
|
37
|
+
Fog::Rackspace::Servers.data[:last_modified][:servers].delete(server_id)
|
38
38
|
Fog::Rackspace::Servers.data[:servers].delete(server_id)
|
39
39
|
response.status = 202
|
40
40
|
end
|
41
41
|
else
|
42
42
|
response.status = 404
|
43
|
-
raise(Excon::Errors.status_error(202,
|
43
|
+
raise(Excon::Errors.status_error({:expects => 202}, response))
|
44
44
|
end
|
45
45
|
response
|
46
46
|
end
|
@@ -43,13 +43,13 @@ else
|
|
43
43
|
class Servers
|
44
44
|
|
45
45
|
def get_server_details(server_id)
|
46
|
-
response =
|
46
|
+
response = Excon::Response.new
|
47
47
|
if server = list_servers_detail.body['servers'].detect { |server| server['id'] == server_id }
|
48
48
|
response.status = [200, 203][rand(1)]
|
49
49
|
response.body = { 'server' => server }
|
50
50
|
else
|
51
51
|
response.status = 404
|
52
|
-
raise(Excon::Errors.status_error(202,
|
52
|
+
raise(Excon::Errors.status_error({:expects => 202}, response))
|
53
53
|
end
|
54
54
|
response
|
55
55
|
end
|
@@ -34,13 +34,13 @@ else
|
|
34
34
|
class Servers
|
35
35
|
|
36
36
|
def list_addresses(server_id)
|
37
|
-
response =
|
37
|
+
response = Excon::Response.new
|
38
38
|
if server = list_servers_detail.body['servers'].detect { |server| server['id'] == server_id }
|
39
39
|
response.status = [200, 203][rand(1)]
|
40
40
|
response.body = { 'addresses' => server['addresses'] }
|
41
41
|
else
|
42
42
|
response.status = 404
|
43
|
-
raise(Excon::Errors.status_error(202,
|
43
|
+
raise(Excon::Errors.status_error({:expects => 202}, response))
|
44
44
|
end
|
45
45
|
response
|
46
46
|
end
|
@@ -30,6 +30,16 @@ else
|
|
30
30
|
class Servers
|
31
31
|
|
32
32
|
def list_images
|
33
|
+
response = Excon::Response.new
|
34
|
+
data = list_images_detail.body['images']
|
35
|
+
images = []
|
36
|
+
for image in data
|
37
|
+
images << image.reject { |key, value| !['id', 'name'].include?(key) }
|
38
|
+
end
|
39
|
+
response.status = [200, 203][rand(1)]
|
40
|
+
response.body = { 'images' => images }
|
41
|
+
response
|
42
|
+
|
33
43
|
end
|
34
44
|
|
35
45
|
end
|
@@ -32,7 +32,22 @@ else
|
|
32
32
|
module Rackspace
|
33
33
|
class Servers
|
34
34
|
|
35
|
-
def
|
35
|
+
def list_images_detail
|
36
|
+
response = Excon::Response.new
|
37
|
+
|
38
|
+
images = Fog::Rackspace::Servers.data[:images].values
|
39
|
+
for image in images
|
40
|
+
case image['status']
|
41
|
+
when 'SAVING'
|
42
|
+
if Time.now - Fog::Rackspace::Servers.data[:last_modified][:images][image['id']] > 2
|
43
|
+
image['status'] = 'ACTIVE'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
response.status = [200, 203][rand(1)]
|
49
|
+
response.body = { 'images' => images }
|
50
|
+
response
|
36
51
|
end
|
37
52
|
|
38
53
|
end
|