fog 0.3.22 → 0.3.23
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/fog.gemspec +2 -2
- data/lib/fog.rb +1 -1
- data/lib/fog/aws/models/compute/address.rb +6 -5
- data/lib/fog/aws/models/compute/addresses.rb +3 -3
- data/lib/fog/aws/models/compute/image.rb +7 -11
- data/lib/fog/aws/models/compute/images.rb +3 -3
- data/lib/fog/aws/models/compute/key_pair.rb +1 -1
- data/lib/fog/aws/models/compute/key_pairs.rb +4 -3
- data/lib/fog/aws/models/compute/security_group.rb +6 -6
- data/lib/fog/aws/models/compute/security_groups.rb +3 -3
- data/lib/fog/aws/models/compute/server.rb +15 -44
- data/lib/fog/aws/models/compute/servers.rb +3 -5
- data/lib/fog/aws/models/compute/snapshot.rb +4 -4
- data/lib/fog/aws/models/compute/snapshots.rb +3 -3
- data/lib/fog/aws/models/compute/tags.rb +4 -4
- data/lib/fog/aws/models/compute/volume.rb +7 -7
- data/lib/fog/aws/models/compute/volumes.rb +4 -4
- data/lib/fog/aws/models/storage/directories.rb +1 -1
- data/lib/fog/aws/models/storage/file.rb +9 -5
- data/lib/fog/aws/models/storage/files.rb +10 -9
- data/lib/fog/aws/parsers/storage/get_bucket.rb +19 -3
- data/lib/fog/aws/requests/storage/get_bucket.rb +1 -0
- data/lib/fog/bluebox/models/compute/server.rb +7 -13
- data/lib/fog/brightbox/models/compute/image.rb +4 -4
- data/lib/fog/brightbox/models/compute/server.rb +7 -7
- data/lib/fog/brightbox/models/compute/user.rb +3 -3
- data/lib/fog/core/attributes.rb +18 -26
- data/lib/fog/go_grid/models/compute/image.rb +2 -2
- data/lib/fog/go_grid/models/compute/server.rb +2 -2
- data/lib/fog/google/models/storage/directories.rb +1 -1
- data/lib/fog/google/models/storage/file.rb +9 -6
- data/lib/fog/google/models/storage/files.rb +10 -9
- data/lib/fog/google/parsers/storage/get_bucket.rb +19 -3
- data/lib/fog/google/requests/storage/get_bucket.rb +1 -0
- data/lib/fog/local/models/storage/file.rb +5 -2
- data/lib/fog/rackspace/models/compute/image.rb +3 -3
- data/lib/fog/rackspace/models/compute/server.rb +10 -10
- data/lib/fog/rackspace/models/storage/file.rb +8 -5
- data/lib/fog/rackspace/models/storage/files.rb +4 -4
- data/lib/fog/slicehost/models/compute/server.rb +7 -7
- data/lib/fog/terremark/models/shared/address.rb +2 -2
- data/lib/fog/terremark/models/shared/network.rb +2 -2
- data/lib/fog/terremark/models/shared/server.rb +13 -13
- data/lib/fog/terremark/models/shared/task.rb +3 -3
- data/lib/fog/terremark/models/shared/vdc.rb +4 -4
- metadata +3 -3
@@ -13,16 +13,16 @@ module Fog
|
|
13
13
|
model Fog::AWS::Compute::Snapshot
|
14
14
|
|
15
15
|
def initialize(attributes)
|
16
|
-
|
16
|
+
self.filters ||= { 'RestorableBy' => 'self' }
|
17
17
|
super
|
18
18
|
end
|
19
19
|
|
20
|
-
def all(filters =
|
20
|
+
def all(filters = filters, options = {})
|
21
21
|
unless filters.is_a?(Hash)
|
22
22
|
Formatador.display_line("[yellow][WARN] all with #{filters.class} param is deprecated, use all('snapshot-id' => []) instead[/] [light_black](#{caller.first})[/]")
|
23
23
|
filters = {'snapshot-id' => [*filters]}
|
24
24
|
end
|
25
|
-
|
25
|
+
self.filters = filters
|
26
26
|
data = connection.describe_snapshots(filters.merge!(options)).body
|
27
27
|
load(data['snapshotSet'])
|
28
28
|
if volume
|
@@ -12,13 +12,13 @@ module Fog
|
|
12
12
|
model Fog::AWS::Compute::Tag
|
13
13
|
|
14
14
|
def initialize(attributes)
|
15
|
-
|
15
|
+
self.filters ||= {}
|
16
16
|
super
|
17
17
|
end
|
18
18
|
|
19
|
-
def all(filters =
|
20
|
-
|
21
|
-
data = connection.describe_tags(
|
19
|
+
def all(filters = filters)
|
20
|
+
self.filters = filters
|
21
|
+
data = connection.describe_tags(filters).body
|
22
22
|
load(data['tagSet'])
|
23
23
|
end
|
24
24
|
|
@@ -30,7 +30,7 @@ module Fog
|
|
30
30
|
def destroy
|
31
31
|
requires :id
|
32
32
|
|
33
|
-
connection.delete_volume(
|
33
|
+
connection.delete_volume(id)
|
34
34
|
true
|
35
35
|
end
|
36
36
|
|
@@ -42,7 +42,7 @@ module Fog
|
|
42
42
|
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
43
43
|
requires :availability_zone, :size
|
44
44
|
|
45
|
-
data = connection.create_volume(
|
45
|
+
data = connection.create_volume(availability_zone, size, snapshot_id).body
|
46
46
|
new_attributes = data.reject {|key,value| key == 'requestId'}
|
47
47
|
merge_attributes(new_attributes)
|
48
48
|
if @server
|
@@ -73,19 +73,19 @@ module Fog
|
|
73
73
|
def attach(new_server)
|
74
74
|
if new_record?
|
75
75
|
@server = new_server
|
76
|
-
|
76
|
+
self.availability_zone = new_server.availability_zone
|
77
77
|
elsif new_server
|
78
78
|
requires :device
|
79
79
|
@server = nil
|
80
|
-
|
81
|
-
connection.attach_volume(
|
80
|
+
self.server_id = new_server.id
|
81
|
+
connection.attach_volume(server_id, id, device)
|
82
82
|
reload
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
86
|
def detach
|
87
87
|
@server = nil
|
88
|
-
|
88
|
+
self.server_id = nil
|
89
89
|
unless new_record?
|
90
90
|
connection.detach_volume(@id)
|
91
91
|
reload
|
@@ -94,7 +94,7 @@ module Fog
|
|
94
94
|
|
95
95
|
def force_detach
|
96
96
|
@server = nil
|
97
|
-
|
97
|
+
self.server_id = nil
|
98
98
|
unless new_record?
|
99
99
|
connection.detach_volume(@id, 'Force' => true)
|
100
100
|
reload
|
@@ -13,17 +13,17 @@ module Fog
|
|
13
13
|
model Fog::AWS::Compute::Volume
|
14
14
|
|
15
15
|
def initialize(attributes)
|
16
|
-
|
16
|
+
self.filters ||= {}
|
17
17
|
super
|
18
18
|
end
|
19
19
|
|
20
|
-
def all(filters =
|
20
|
+
def all(filters = filters)
|
21
21
|
unless filters.is_a?(Hash)
|
22
22
|
Formatador.display_line("[yellow][WARN] all with #{filters.class} param is deprecated, use all('volume-id' => []) instead[/] [light_black](#{caller.first})[/]")
|
23
23
|
filters = {'volume-id' => [*filters]}
|
24
24
|
end
|
25
|
-
|
26
|
-
data = connection.describe_volumes(
|
25
|
+
self.filters = filters
|
26
|
+
data = connection.describe_volumes(filters).body
|
27
27
|
load(data['volumeSet'])
|
28
28
|
if server
|
29
29
|
self.replace(self.select {|volume| volume.server_id == server.id})
|
@@ -25,7 +25,7 @@ module Fog
|
|
25
25
|
directory = new(:key => data['Name'])
|
26
26
|
options = {}
|
27
27
|
for k, v in data
|
28
|
-
if ['Delimiter', 'IsTruncated', 'Marker', 'MaxKeys', 'Prefix'].include?(k)
|
28
|
+
if ['CommonPrefixes', 'Delimiter', 'IsTruncated', 'Marker', 'MaxKeys', 'Prefix'].include?(k)
|
29
29
|
options[k] = v
|
30
30
|
end
|
31
31
|
end
|
@@ -33,34 +33,38 @@ module Fog
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def body
|
36
|
-
|
36
|
+
attributes[:body] ||= if last_modified && (file = collection.get(identity))
|
37
37
|
file.body
|
38
38
|
else
|
39
39
|
''
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
def body=(new_body)
|
44
|
+
attributes[:body] = new_body
|
45
|
+
end
|
46
|
+
|
43
47
|
def directory
|
44
48
|
@directory
|
45
49
|
end
|
46
50
|
|
47
51
|
def copy(target_directory_key, target_file_key)
|
48
52
|
requires :directory, :key
|
49
|
-
connection.copy_object(directory.key,
|
53
|
+
connection.copy_object(directory.key, key, target_directory_key, target_file_key)
|
50
54
|
target_directory = connection.directories.new(:key => target_directory_key)
|
51
55
|
target_directory.files.get(target_file_key)
|
52
56
|
end
|
53
57
|
|
54
58
|
def destroy
|
55
59
|
requires :directory, :key
|
56
|
-
connection.delete_object(directory.key,
|
60
|
+
connection.delete_object(directory.key, key)
|
57
61
|
true
|
58
62
|
end
|
59
63
|
|
60
64
|
remove_method :owner=
|
61
65
|
def owner=(new_owner)
|
62
66
|
if new_owner
|
63
|
-
|
67
|
+
attributes[:owner] = {
|
64
68
|
:display_name => new_owner['DisplayName'],
|
65
69
|
:id => new_owner['ID']
|
66
70
|
}
|
@@ -103,7 +107,7 @@ module Fog
|
|
103
107
|
options['Expires'] = expires if expires
|
104
108
|
options['x-amz-storage-class'] = storage_class if storage_class
|
105
109
|
|
106
|
-
data = connection.put_object(directory.key,
|
110
|
+
data = connection.put_object(directory.key, key, body, options)
|
107
111
|
merge_attributes(data.headers)
|
108
112
|
if body.is_a?(String)
|
109
113
|
self.content_length = body.size
|
@@ -7,22 +7,23 @@ module Fog
|
|
7
7
|
|
8
8
|
class Files < Fog::Collection
|
9
9
|
|
10
|
-
attribute :
|
10
|
+
attribute :common_prefixes, :aliases => 'CommonPrefixes'
|
11
|
+
attribute :delimiter, :aliases => 'Delimiter'
|
11
12
|
attribute :directory
|
12
|
-
attribute :is_truncated,
|
13
|
-
attribute :marker,
|
14
|
-
attribute :max_keys,
|
15
|
-
attribute :prefix,
|
13
|
+
attribute :is_truncated, :aliases => 'IsTruncated'
|
14
|
+
attribute :marker, :aliases => 'Marker'
|
15
|
+
attribute :max_keys, :aliases => ['MaxKeys', 'max-keys']
|
16
|
+
attribute :prefix, :aliases => 'Prefix'
|
16
17
|
|
17
18
|
model Fog::AWS::Storage::File
|
18
19
|
|
19
20
|
def all(options = {})
|
20
21
|
requires :directory
|
21
22
|
options = {
|
22
|
-
'delimiter' =>
|
23
|
-
'marker' =>
|
24
|
-
'max-keys' =>
|
25
|
-
'prefix' =>
|
23
|
+
'delimiter' => delimiter,
|
24
|
+
'marker' => marker,
|
25
|
+
'max-keys' => max_keys,
|
26
|
+
'prefix' => prefix
|
26
27
|
}.merge!(options)
|
27
28
|
options = options.reject {|key,value| value.nil? || value.to_s.empty?}
|
28
29
|
merge_attributes(options)
|
@@ -7,11 +7,21 @@ module Fog
|
|
7
7
|
|
8
8
|
def reset
|
9
9
|
@object = { 'Owner' => {} }
|
10
|
-
@response = { 'Contents' => [] }
|
10
|
+
@response = { 'Contents' => [], 'CommonPrefixes' => [] }
|
11
|
+
end
|
12
|
+
|
13
|
+
def start_element(name, attrs = [])
|
14
|
+
super
|
15
|
+
case name
|
16
|
+
when 'CommonPrefixes'
|
17
|
+
@in_common_prefixes = true
|
18
|
+
end
|
11
19
|
end
|
12
20
|
|
13
21
|
def end_element(name)
|
14
22
|
case name
|
23
|
+
when 'CommonPrefixes'
|
24
|
+
@in_common_prefixes = false
|
15
25
|
when 'Contents'
|
16
26
|
@response['Contents'] << @object
|
17
27
|
@object = { 'Owner' => {} }
|
@@ -27,13 +37,19 @@ module Fog
|
|
27
37
|
end
|
28
38
|
when 'LastModified'
|
29
39
|
@object['LastModified'] = Time.parse(@value)
|
30
|
-
when 'Marker', 'Name'
|
40
|
+
when 'Marker', 'Name'
|
31
41
|
@response[name] = @value
|
32
42
|
when 'MaxKeys'
|
33
43
|
@response['MaxKeys'] = @value.to_i
|
44
|
+
when 'Prefix'
|
45
|
+
if @in_common_prefixes
|
46
|
+
@response['CommonPrefixes'] << @value
|
47
|
+
else
|
48
|
+
@response[name] = @value
|
49
|
+
end
|
34
50
|
when 'Size'
|
35
51
|
@object['Size'] = @value.to_i
|
36
|
-
when '
|
52
|
+
when 'Delimiter', 'Key', 'StorageClass'
|
37
53
|
@object[name] = @value
|
38
54
|
end
|
39
55
|
end
|
@@ -26,6 +26,7 @@ module Fog
|
|
26
26
|
# * 'MaxKeys'<~Integer> - Maximum number of keys specified for query
|
27
27
|
# * 'Name'<~String> - Name of the bucket
|
28
28
|
# * 'Prefix'<~String> - Prefix specified for query
|
29
|
+
# * 'CommonPrefixes'<~Array> - Array of strings for common prefixes
|
29
30
|
# * 'Contents'<~Array>:
|
30
31
|
# * 'ETag'<~String>: Etag of object
|
31
32
|
# * 'Key'<~String>: Name of object
|
@@ -17,7 +17,7 @@ module Fog
|
|
17
17
|
|
18
18
|
attribute :cpu
|
19
19
|
attribute :description
|
20
|
-
attribute :flavor_id
|
20
|
+
attribute :flavor_id, :aliases => :product, :squash => 'id'
|
21
21
|
attribute :hostname
|
22
22
|
attribute :image_id
|
23
23
|
attribute :ips
|
@@ -30,24 +30,24 @@ module Fog
|
|
30
30
|
attr_writer :private_key, :private_key_path, :public_key, :public_key_path, :username
|
31
31
|
|
32
32
|
def initialize(attributes={})
|
33
|
-
|
33
|
+
self.flavor_id ||= '94fd37a7-2606-47f7-84d5-9000deda52ae'
|
34
34
|
super
|
35
35
|
end
|
36
36
|
|
37
37
|
def destroy
|
38
38
|
requires :id
|
39
|
-
connection.destroy_block(
|
39
|
+
connection.destroy_block(id)
|
40
40
|
true
|
41
41
|
end
|
42
42
|
|
43
43
|
def flavor
|
44
44
|
requires :flavor_id
|
45
|
-
connection.flavors.get(
|
45
|
+
connection.flavors.get(flavor_id)
|
46
46
|
end
|
47
47
|
|
48
48
|
def image
|
49
49
|
requires :image_id
|
50
|
-
connection.images.get(
|
50
|
+
connection.images.get(image_id)
|
51
51
|
end
|
52
52
|
|
53
53
|
def private_key_path
|
@@ -69,12 +69,12 @@ module Fog
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def ready?
|
72
|
-
|
72
|
+
status == 'running'
|
73
73
|
end
|
74
74
|
|
75
75
|
def reboot(type = 'SOFT')
|
76
76
|
requires :id
|
77
|
-
connection.reboot_block(
|
77
|
+
connection.reboot_block(id, type)
|
78
78
|
true
|
79
79
|
end
|
80
80
|
|
@@ -116,12 +116,6 @@ module Fog
|
|
116
116
|
@username ||= 'deploy'
|
117
117
|
end
|
118
118
|
|
119
|
-
private
|
120
|
-
|
121
|
-
def product=(new_product)
|
122
|
-
@flavor_id = new_product['id']
|
123
|
-
end
|
124
|
-
|
125
119
|
end
|
126
120
|
|
127
121
|
end
|
@@ -29,10 +29,10 @@ module Fog
|
|
29
29
|
def save
|
30
30
|
requires :source, :arch
|
31
31
|
options = {
|
32
|
-
:source =>
|
33
|
-
:arch =>
|
34
|
-
:name =>
|
35
|
-
:description =>
|
32
|
+
:source => source,
|
33
|
+
:arch => arch,
|
34
|
+
:name => name,
|
35
|
+
:description => description
|
36
36
|
}.delete_if {|k,v| v.nil? || v == "" }
|
37
37
|
data = connection.create_image(options)
|
38
38
|
merge_attributes(data)
|
@@ -63,12 +63,12 @@ module Fog
|
|
63
63
|
|
64
64
|
def flavor
|
65
65
|
requires :flavor_id
|
66
|
-
connection.flavors.get(
|
66
|
+
connection.flavors.get(flavor_id)
|
67
67
|
end
|
68
68
|
|
69
69
|
def image
|
70
70
|
requires :image_id
|
71
|
-
connection.images.get(
|
71
|
+
connection.images.get(image_id)
|
72
72
|
end
|
73
73
|
|
74
74
|
def ready?
|
@@ -78,11 +78,11 @@ module Fog
|
|
78
78
|
def save
|
79
79
|
requires :image_id
|
80
80
|
options = {
|
81
|
-
:image =>
|
82
|
-
:server_type =>
|
83
|
-
:name =>
|
84
|
-
:zone =>
|
85
|
-
:user_data =>
|
81
|
+
:image => image_id,
|
82
|
+
:server_type => flavor_id,
|
83
|
+
:name => name,
|
84
|
+
:zone => zone_id,
|
85
|
+
:user_data => user_data
|
86
86
|
}.delete_if {|k,v| v.nil? || v == "" }
|
87
87
|
data = connection.create_server(options)
|
88
88
|
merge_attributes(data)
|
@@ -22,9 +22,9 @@ module Fog
|
|
22
22
|
requires :identity
|
23
23
|
|
24
24
|
options = {
|
25
|
-
:email_address =>
|
26
|
-
:ssh_key =>
|
27
|
-
:name =>
|
25
|
+
:email_address => email_address,
|
26
|
+
:ssh_key => ssh_key,
|
27
|
+
:name => name
|
28
28
|
}
|
29
29
|
|
30
30
|
data = connection.update_user(identity, options)
|
data/lib/fog/core/attributes.rb
CHANGED
@@ -16,13 +16,15 @@ module Fog
|
|
16
16
|
|
17
17
|
def attribute(name, options = {})
|
18
18
|
class_eval <<-EOS, __FILE__, __LINE__
|
19
|
-
|
19
|
+
def #{name}
|
20
|
+
attributes[:#{name}]
|
21
|
+
end
|
20
22
|
EOS
|
21
23
|
case options[:type]
|
22
24
|
when :boolean
|
23
25
|
class_eval <<-EOS, __FILE__, __LINE__
|
24
26
|
def #{name}=(new_#{name})
|
25
|
-
|
27
|
+
attributes[:#{name}] = case new_#{name}
|
26
28
|
when 'true'
|
27
29
|
true
|
28
30
|
when 'false'
|
@@ -33,39 +35,35 @@ module Fog
|
|
33
35
|
when :float
|
34
36
|
class_eval <<-EOS, __FILE__, __LINE__
|
35
37
|
def #{name}=(new_#{name})
|
36
|
-
|
38
|
+
attributes[:#{name}] = new_#{name}.to_f
|
37
39
|
end
|
38
40
|
EOS
|
39
41
|
when :integer
|
40
42
|
class_eval <<-EOS, __FILE__, __LINE__
|
41
43
|
def #{name}=(new_#{name})
|
42
|
-
|
44
|
+
attributes[:#{name}] = new_#{name}.to_i
|
43
45
|
end
|
44
46
|
EOS
|
45
47
|
when :string
|
46
48
|
class_eval <<-EOS, __FILE__, __LINE__
|
47
49
|
def #{name}=(new_#{name})
|
48
|
-
|
50
|
+
attributes[:#{name}] = new_#{name}.to_s
|
49
51
|
end
|
50
52
|
EOS
|
51
53
|
when :time
|
52
54
|
class_eval <<-EOS, __FILE__, __LINE__
|
53
55
|
def #{name}=(new_#{name})
|
54
|
-
if new_#{name}.nil? || new_#{name} == "" || new_#{name}.is_a?(Time)
|
55
|
-
|
56
|
+
attributes[:#{name}] = if new_#{name}.nil? || new_#{name} == "" || new_#{name}.is_a?(Time)
|
57
|
+
new_#{name}
|
56
58
|
else
|
57
|
-
|
59
|
+
Time.parse(new_#{name})
|
58
60
|
end
|
59
61
|
end
|
60
62
|
EOS
|
61
63
|
when :array
|
62
64
|
class_eval <<-EOS, __FILE__, __LINE__
|
63
65
|
def #{name}=(new_#{name})
|
64
|
-
|
65
|
-
new_#{name}
|
66
|
-
else
|
67
|
-
@#{name} = [ new_#{name} ]
|
68
|
-
end
|
66
|
+
attributes[:#{name}] = [*new_#{name}]
|
69
67
|
end
|
70
68
|
EOS
|
71
69
|
else
|
@@ -74,18 +72,20 @@ module Fog
|
|
74
72
|
def #{name}=(new_data)
|
75
73
|
if new_data.is_a?(Hash)
|
76
74
|
if new_data[:#{squash}] || new_data["#{squash}"]
|
77
|
-
|
75
|
+
attributes[:#{name}] = new_data[:#{squash}] || new_data["#{squash}"]
|
78
76
|
else
|
79
|
-
|
77
|
+
attributes[:#{name}] = [ new_data ]
|
80
78
|
end
|
81
79
|
else
|
82
|
-
|
80
|
+
attributes[:#{name}] = new_data
|
83
81
|
end
|
84
82
|
end
|
85
83
|
EOS
|
86
84
|
else
|
87
85
|
class_eval <<-EOS, __FILE__, __LINE__
|
88
|
-
|
86
|
+
def #{name}=(new_#{name})
|
87
|
+
attributes[:#{name}] = new_#{name}
|
88
|
+
end
|
89
89
|
EOS
|
90
90
|
end
|
91
91
|
end
|
@@ -118,13 +118,7 @@ module Fog
|
|
118
118
|
end
|
119
119
|
|
120
120
|
def attributes
|
121
|
-
@attributes ||=
|
122
|
-
attributes = {}
|
123
|
-
for attribute in self.class.attributes
|
124
|
-
attributes[attribute] = send("#{attribute}")
|
125
|
-
end
|
126
|
-
attributes
|
127
|
-
end
|
121
|
+
@attributes ||= {}
|
128
122
|
end
|
129
123
|
|
130
124
|
def identity
|
@@ -139,10 +133,8 @@ module Fog
|
|
139
133
|
for key, value in new_attributes
|
140
134
|
unless self.class.ignored_attributes.include?(key)
|
141
135
|
if aliased_key = self.class.aliases[key]
|
142
|
-
attributes[aliased_key] = value
|
143
136
|
send("#{aliased_key}=", value)
|
144
137
|
elsif (public_methods | private_methods).detect {|method| ["#{key}=", :"#{key}="].include?(method)}
|
145
|
-
attributes[key.to_sym] = value
|
146
138
|
send("#{key}=", value)
|
147
139
|
else
|
148
140
|
attributes[key] = value
|