fog 0.0.39 → 0.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +88 -31
- data/Rakefile +25 -2
- data/VERSION +1 -1
- data/bin/fog +57 -43
- data/fog.gemspec +52 -23
- data/lib/fog.rb +7 -4
- data/lib/fog/aws/ec2.rb +6 -2
- data/lib/fog/aws/models/ec2/address.rb +13 -13
- data/lib/fog/aws/models/ec2/addresses.rb +5 -5
- data/lib/fog/aws/models/ec2/flavor.rb +19 -0
- data/lib/fog/aws/models/ec2/flavors.rb +43 -0
- data/lib/fog/aws/models/ec2/image.rb +24 -0
- data/lib/fog/aws/models/ec2/images.rb +44 -0
- data/lib/fog/aws/models/ec2/{instance.rb → server.rb} +22 -10
- data/lib/fog/aws/models/ec2/{instances.rb → servers.rb} +12 -12
- data/lib/fog/aws/models/ec2/snapshot.rb +2 -2
- data/lib/fog/aws/models/ec2/volume.rb +17 -17
- data/lib/fog/aws/models/ec2/volumes.rb +5 -5
- data/lib/fog/aws/models/s3/{buckets.rb → directories.rb} +16 -13
- data/lib/fog/aws/models/s3/{bucket.rb → directory.rb} +5 -10
- data/lib/fog/aws/models/s3/{object.rb → file.rb} +16 -18
- data/lib/fog/aws/models/s3/{objects.rb → files.rb} +19 -19
- data/lib/fog/aws/requests/ec2/run_instances.rb +1 -1
- data/lib/fog/aws/s3.rb +6 -6
- data/lib/fog/rackspace/files.rb +6 -3
- data/lib/fog/rackspace/models/servers/flavor.rb +26 -1
- data/lib/fog/rackspace/models/servers/image.rb +3 -3
- data/lib/fog/rackspace/models/servers/server.rb +20 -9
- data/lib/fog/rackspace/models/servers/servers.rb +3 -1
- data/lib/fog/rackspace/servers.rb +2 -1
- data/spec/aws/models/ec2/address_spec.rb +8 -8
- data/spec/aws/models/ec2/server_spec.rb +109 -0
- data/spec/aws/models/ec2/servers_spec.rb +52 -0
- data/spec/aws/models/ec2/snapshot_spec.rb +2 -1
- data/spec/aws/models/ec2/volume_spec.rb +22 -22
- data/spec/aws/models/s3/directories_spec.rb +49 -0
- data/spec/aws/models/s3/directory_spec.rb +112 -0
- data/spec/aws/models/s3/file_spec.rb +106 -0
- data/spec/aws/models/s3/files_spec.rb +116 -0
- data/spec/rackspace/models/servers/server_spec.rb +51 -0
- data/spec/shared_examples/server_examples.rb +42 -0
- data/spec/spec_helper.rb +1 -1
- metadata +51 -22
- data/spec/aws/models/ec2/instance_spec.rb +0 -161
- data/spec/aws/models/ec2/instances_spec.rb +0 -70
- data/spec/aws/models/s3/bucket_spec.rb +0 -129
- data/spec/aws/models/s3/buckets_spec.rb +0 -70
- data/spec/aws/models/s3/object_spec.rb +0 -121
- data/spec/aws/models/s3/objects_spec.rb +0 -141
@@ -11,7 +11,7 @@ module Fog
|
|
11
11
|
class Volumes < Fog::Collection
|
12
12
|
|
13
13
|
attribute :volume_id
|
14
|
-
attribute :
|
14
|
+
attribute :server
|
15
15
|
|
16
16
|
model Fog::AWS::EC2::Volume
|
17
17
|
|
@@ -31,8 +31,8 @@ module Fog
|
|
31
31
|
data['volumeSet'].each do |volume|
|
32
32
|
volumes << new(volume)
|
33
33
|
end
|
34
|
-
if
|
35
|
-
volumes = volumes.select {|volume| volume.instance_id ==
|
34
|
+
if server
|
35
|
+
volumes = volumes.select {|volume| volume.instance_id == server.id}
|
36
36
|
end
|
37
37
|
self.replace(volumes)
|
38
38
|
end
|
@@ -46,8 +46,8 @@ module Fog
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def new(attributes = {})
|
49
|
-
if
|
50
|
-
super({ :
|
49
|
+
if server
|
50
|
+
super({ :server => server }.merge!(attributes))
|
51
51
|
else
|
52
52
|
super
|
53
53
|
end
|
@@ -2,13 +2,13 @@ module Fog
|
|
2
2
|
module AWS
|
3
3
|
class S3
|
4
4
|
|
5
|
-
def
|
6
|
-
Fog::AWS::S3::
|
5
|
+
def directories
|
6
|
+
Fog::AWS::S3::Directories.new(:connection => self)
|
7
7
|
end
|
8
8
|
|
9
|
-
class
|
9
|
+
class Directories < Fog::Collection
|
10
10
|
|
11
|
-
model Fog::AWS::S3::
|
11
|
+
model Fog::AWS::S3::Directory
|
12
12
|
|
13
13
|
def all
|
14
14
|
if @loaded
|
@@ -16,30 +16,33 @@ module Fog
|
|
16
16
|
end
|
17
17
|
@loaded = true
|
18
18
|
data = connection.get_service.body
|
19
|
-
data['Buckets'].each do |
|
20
|
-
self << new(
|
19
|
+
data['Buckets'].each do |directory|
|
20
|
+
self << new(directory)
|
21
21
|
end
|
22
22
|
self
|
23
23
|
end
|
24
24
|
|
25
25
|
def get(name, options = {})
|
26
26
|
remap_attributes(options, {
|
27
|
-
:
|
27
|
+
:delimiter => 'delimiter',
|
28
|
+
:marker => 'marker',
|
29
|
+
:max_keys => 'max-keys',
|
30
|
+
:prefix => 'prefix'
|
28
31
|
})
|
29
32
|
data = connection.get_bucket(name, options).body
|
30
|
-
|
33
|
+
directory = new(:name => data['Name'])
|
31
34
|
options = {}
|
32
35
|
for key, value in data
|
33
36
|
if ['Delimiter', 'IsTruncated', 'Marker', 'MaxKeys', 'Prefix'].include?(key)
|
34
37
|
options[key] = value
|
35
38
|
end
|
36
39
|
end
|
37
|
-
|
38
|
-
|
39
|
-
data['Contents'].each do |
|
40
|
-
|
40
|
+
directory.files.merge_attributes(options)
|
41
|
+
directory.files.instance_variable_set(:@loaded, true)
|
42
|
+
data['Contents'].each do |file|
|
43
|
+
directory.files << directory.files.new(file)
|
41
44
|
end
|
42
|
-
|
45
|
+
directory
|
43
46
|
rescue Excon::Errors::NotFound
|
44
47
|
nil
|
45
48
|
end
|
@@ -2,7 +2,7 @@ module Fog
|
|
2
2
|
module AWS
|
3
3
|
class S3
|
4
4
|
|
5
|
-
class
|
5
|
+
class Directory < Fog::Model
|
6
6
|
|
7
7
|
identity :name, 'Name'
|
8
8
|
|
@@ -10,7 +10,6 @@ module Fog
|
|
10
10
|
|
11
11
|
def destroy
|
12
12
|
requires :name
|
13
|
-
|
14
13
|
connection.delete_bucket(@name)
|
15
14
|
true
|
16
15
|
rescue Excon::Errors::NotFound
|
@@ -19,7 +18,6 @@ module Fog
|
|
19
18
|
|
20
19
|
def location
|
21
20
|
requires :name
|
22
|
-
|
23
21
|
data = connection.get_bucket_location(@name)
|
24
22
|
data.body['LocationConstraint']
|
25
23
|
end
|
@@ -28,10 +26,10 @@ module Fog
|
|
28
26
|
@location = new_location
|
29
27
|
end
|
30
28
|
|
31
|
-
def
|
32
|
-
@
|
33
|
-
Fog::AWS::S3::
|
34
|
-
:
|
29
|
+
def files
|
30
|
+
@files ||= begin
|
31
|
+
Fog::AWS::S3::Files.new(
|
32
|
+
:directory => self,
|
35
33
|
:connection => connection
|
36
34
|
)
|
37
35
|
end
|
@@ -39,21 +37,18 @@ module Fog
|
|
39
37
|
|
40
38
|
def payer
|
41
39
|
requires :name
|
42
|
-
|
43
40
|
data = connection.get_request_payment(@name)
|
44
41
|
data.body['Payer']
|
45
42
|
end
|
46
43
|
|
47
44
|
def payer=(new_payer)
|
48
45
|
requires :name
|
49
|
-
|
50
46
|
connection.put_request_payment(@name, new_payer)
|
51
47
|
@payer = new_payer
|
52
48
|
end
|
53
49
|
|
54
50
|
def save
|
55
51
|
requires :name
|
56
|
-
|
57
52
|
options = {}
|
58
53
|
if @location
|
59
54
|
options['LocationConstraint'] = @location
|
@@ -2,7 +2,7 @@ module Fog
|
|
2
2
|
module AWS
|
3
3
|
class S3
|
4
4
|
|
5
|
-
class
|
5
|
+
class File < Fog::Model
|
6
6
|
|
7
7
|
identity :key, 'Key'
|
8
8
|
|
@@ -15,30 +15,28 @@ module Fog
|
|
15
15
|
attribute :size, 'Size'
|
16
16
|
attribute :storage_class, 'StorageClass'
|
17
17
|
|
18
|
-
def
|
19
|
-
@
|
18
|
+
def directory
|
19
|
+
@directory
|
20
20
|
end
|
21
21
|
|
22
|
-
def copy(
|
23
|
-
requires :
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
target_object = target_bucket.objects.new(attributes.merge!(:key => target_object_key))
|
22
|
+
def copy(target_directory_name, target_file_key)
|
23
|
+
requires :directory, :key
|
24
|
+
data = connection.copy_object(directory.name, @key, target_directory_name, target_file_key).body
|
25
|
+
target_directory = connection.directories.new(:name => target_directory_name)
|
26
|
+
target_file = target_directory.files.new(attributes.merge!(:key => target_file_key))
|
28
27
|
copy_data = {}
|
29
28
|
for key, value in data
|
30
29
|
if ['ETag', 'LastModified'].include?(key)
|
31
30
|
copy_data[key] = value
|
32
31
|
end
|
33
32
|
end
|
34
|
-
|
35
|
-
|
33
|
+
target_file.merge_attributes(copy_data)
|
34
|
+
target_file
|
36
35
|
end
|
37
36
|
|
38
37
|
def destroy
|
39
|
-
requires :
|
40
|
-
|
41
|
-
connection.delete_object(bucket.name, @key)
|
38
|
+
requires :directory, :key
|
39
|
+
connection.delete_object(directory.name, @key)
|
42
40
|
true
|
43
41
|
end
|
44
42
|
|
@@ -52,16 +50,16 @@ module Fog
|
|
52
50
|
end
|
53
51
|
|
54
52
|
def save(options = {})
|
55
|
-
requires :body, :
|
56
|
-
data = connection.put_object(
|
53
|
+
requires :body, :directory, :key
|
54
|
+
data = connection.put_object(directory.name, @key, @body, options)
|
57
55
|
@etag = data.headers['ETag']
|
58
56
|
true
|
59
57
|
end
|
60
58
|
|
61
59
|
private
|
62
60
|
|
63
|
-
def
|
64
|
-
@
|
61
|
+
def directory=(new_directory)
|
62
|
+
@directory = new_directory
|
65
63
|
end
|
66
64
|
|
67
65
|
end
|
@@ -2,7 +2,7 @@ module Fog
|
|
2
2
|
module AWS
|
3
3
|
class S3
|
4
4
|
|
5
|
-
class
|
5
|
+
class Files < Fog::Collection
|
6
6
|
|
7
7
|
attribute :delimiter, 'Delimiter'
|
8
8
|
attribute :is_truncated, 'IsTruncated'
|
@@ -10,7 +10,7 @@ module Fog
|
|
10
10
|
attribute :max_keys, 'MaxKeys'
|
11
11
|
attribute :prefix, 'Prefix'
|
12
12
|
|
13
|
-
model Fog::AWS::S3::
|
13
|
+
model Fog::AWS::S3::File
|
14
14
|
|
15
15
|
def all(options = {})
|
16
16
|
merge_attributes(options)
|
@@ -18,19 +18,19 @@ module Fog
|
|
18
18
|
clear
|
19
19
|
end
|
20
20
|
@loaded = true
|
21
|
-
collection =
|
22
|
-
|
21
|
+
collection = directory.collection.get(
|
22
|
+
directory.name,
|
23
23
|
options
|
24
24
|
)
|
25
25
|
if collection
|
26
|
-
self.replace(collection.
|
26
|
+
self.replace(collection.files)
|
27
27
|
else
|
28
28
|
nil
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
33
|
-
@
|
32
|
+
def directory
|
33
|
+
@directory
|
34
34
|
end
|
35
35
|
|
36
36
|
def get(key, options = {}, &block)
|
@@ -40,48 +40,48 @@ module Fog
|
|
40
40
|
'max-keys' => @max_keys,
|
41
41
|
'prefix' => @prefix
|
42
42
|
}.merge!(options)
|
43
|
-
data = connection.get_object(
|
44
|
-
|
43
|
+
data = connection.get_object(directory.name, key, options, &block)
|
44
|
+
file_data = {
|
45
45
|
:body => data.body,
|
46
46
|
:key => key
|
47
47
|
}
|
48
48
|
for key, value in data.headers
|
49
49
|
if ['Content-Length', 'Content-Type', 'ETag', 'Last-Modified'].include?(key)
|
50
|
-
|
50
|
+
file_data[key] = value
|
51
51
|
end
|
52
52
|
end
|
53
|
-
new(
|
53
|
+
new(file_data)
|
54
54
|
rescue Excon::Errors::NotFound
|
55
55
|
nil
|
56
56
|
end
|
57
57
|
|
58
58
|
def get_url(key, expires)
|
59
|
-
connection.get_object_url(
|
59
|
+
connection.get_object_url(directory.name, key, expires)
|
60
60
|
end
|
61
61
|
|
62
62
|
def head(key, options = {})
|
63
|
-
data = connection.head_object(
|
64
|
-
|
63
|
+
data = connection.head_object(directory.name, key, options)
|
64
|
+
file_data = {
|
65
65
|
:key => key
|
66
66
|
}
|
67
67
|
for key, value in data.headers
|
68
68
|
if ['Content-Length', 'Content-Type', 'ETag', 'Last-Modified'].include?(key)
|
69
|
-
|
69
|
+
file_data[key] = value
|
70
70
|
end
|
71
71
|
end
|
72
|
-
new(
|
72
|
+
new(file_data)
|
73
73
|
rescue Excon::Errors::NotFound
|
74
74
|
nil
|
75
75
|
end
|
76
76
|
|
77
77
|
def new(attributes = {})
|
78
|
-
super({ :
|
78
|
+
super({ :directory => directory }.merge!(attributes))
|
79
79
|
end
|
80
80
|
|
81
81
|
private
|
82
82
|
|
83
|
-
def
|
84
|
-
@
|
83
|
+
def directory=(new_directory)
|
84
|
+
@directory = new_directory
|
85
85
|
end
|
86
86
|
|
87
87
|
end
|
@@ -23,7 +23,7 @@ unless Fog.mocking?
|
|
23
23
|
# * 'Encoding'<~String> - ?
|
24
24
|
# * 'groupId'<~String> - Name of security group for instances
|
25
25
|
# * 'InstanceType'<~String> - Type of instance to boot. Valid options
|
26
|
-
# in ['m1.small', 'm1.large', 'm1.xlarge', 'c1.medium', 'c1.xlarge']
|
26
|
+
# in ['m1.small', 'm1.large', 'm1.xlarge', 'c1.medium', 'c1.xlarge', 'm2.2xlarge', 'm2.4xlarge']
|
27
27
|
# default is 'm1.small'
|
28
28
|
# * 'KernelId'<~String> - Id of kernel with which to launch
|
29
29
|
# * 'KeyName'<~String> - Name of a keypair to add to booting instances
|
data/lib/fog/aws/s3.rb
CHANGED
@@ -12,10 +12,10 @@ module Fog
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.reload
|
15
|
-
load "fog/aws/models/s3/
|
16
|
-
load "fog/aws/models/s3/
|
17
|
-
load "fog/aws/models/s3/
|
18
|
-
load "fog/aws/models/s3/
|
15
|
+
load "fog/aws/models/s3/directory.rb"
|
16
|
+
load "fog/aws/models/s3/directories.rb"
|
17
|
+
load "fog/aws/models/s3/file.rb"
|
18
|
+
load "fog/aws/models/s3/files.rb"
|
19
19
|
|
20
20
|
load "fog/aws/parsers/s3/copy_object.rb"
|
21
21
|
load "fog/aws/parsers/s3/get_bucket.rb"
|
@@ -80,12 +80,12 @@ module Fog
|
|
80
80
|
metadata[:body] = data
|
81
81
|
metadata[:headers]['Content-Length'] = metadata[:body].size.to_s
|
82
82
|
else
|
83
|
-
filename = File.basename(data.path)
|
83
|
+
filename = ::File.basename(data.path)
|
84
84
|
unless (mime_types = MIME::Types.of(filename)).empty?
|
85
85
|
metadata[:headers]['Content-Type'] = mime_types.first.content_type
|
86
86
|
end
|
87
87
|
metadata[:body] = data.read
|
88
|
-
metadata[:headers]['Content-Length'] = File.size(data.path).to_s
|
88
|
+
metadata[:headers]['Content-Length'] = ::File.size(data.path).to_s
|
89
89
|
end
|
90
90
|
# metadata[:headers]['Content-MD5'] = Base64.encode64(Digest::MD5.digest(metadata[:body])).strip
|
91
91
|
metadata
|
data/lib/fog/rackspace/files.rb
CHANGED
@@ -26,7 +26,6 @@ module Fog
|
|
26
26
|
@storage_path = storage_uri.path
|
27
27
|
@storage_port = storage_uri.port
|
28
28
|
@storage_scheme = storage_uri.scheme
|
29
|
-
@connection = Fog::Connection.new("#{@storage_scheme}://#{@storage_host}:#{@storage_port}")
|
30
29
|
end
|
31
30
|
|
32
31
|
def parse_data(data)
|
@@ -51,10 +50,12 @@ module Fog
|
|
51
50
|
end
|
52
51
|
|
53
52
|
def cdn_request(params)
|
54
|
-
|
53
|
+
@cdn_connection = Fog::Connection.new("#{@cdn_scheme}://#{@cdn_host}:#{@cdn_port}")
|
54
|
+
response = @cdn_connection.request({
|
55
55
|
:body => params[:body],
|
56
56
|
:expects => params[:expects],
|
57
57
|
:headers => {
|
58
|
+
'Content-Type' => 'application/json',
|
58
59
|
'X-Auth-Token' => @auth_token
|
59
60
|
}.merge!(params[:headers] || {}),
|
60
61
|
:host => @cdn_host,
|
@@ -69,10 +70,12 @@ module Fog
|
|
69
70
|
end
|
70
71
|
|
71
72
|
def storage_request(params)
|
72
|
-
|
73
|
+
@storage_connection = Fog::Connection.new("#{@storage_scheme}://#{@storage_host}:#{@storage_port}")
|
74
|
+
response = @storage_connection.request({
|
73
75
|
:body => params[:body],
|
74
76
|
:expects => params[:expects],
|
75
77
|
:headers => {
|
78
|
+
'Content-Type' => 'application/json',
|
76
79
|
'X-Auth-Token' => @auth_token
|
77
80
|
}.merge!(params[:headers] || {}),
|
78
81
|
:host => @storage_host,
|
@@ -6,11 +6,36 @@ module Fog
|
|
6
6
|
|
7
7
|
identity :id
|
8
8
|
|
9
|
+
attribute :bits
|
10
|
+
attribute :cores
|
9
11
|
attribute :disk
|
10
|
-
attribute :id
|
11
12
|
attribute :name
|
12
13
|
attribute :ram
|
13
14
|
|
15
|
+
def bits
|
16
|
+
64
|
17
|
+
end
|
18
|
+
|
19
|
+
def cores
|
20
|
+
# 2 quad-cores >= 2Ghz = 8 cores
|
21
|
+
8 * case ram
|
22
|
+
when 256
|
23
|
+
1/64.0
|
24
|
+
when 512
|
25
|
+
1/32.0
|
26
|
+
when 1024
|
27
|
+
1/16.0
|
28
|
+
when 2048
|
29
|
+
1/8.0
|
30
|
+
when 4096
|
31
|
+
1/4.0
|
32
|
+
when 8192
|
33
|
+
1/2.0
|
34
|
+
when 15872
|
35
|
+
1
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
14
39
|
end
|
15
40
|
|
16
41
|
end
|
@@ -7,8 +7,8 @@ module Fog
|
|
7
7
|
identity :id
|
8
8
|
|
9
9
|
attribute :name
|
10
|
-
attribute :created
|
11
|
-
attribute :updated
|
10
|
+
attribute :created_at, 'created'
|
11
|
+
attribute :updated_at, 'updated'
|
12
12
|
attribute :status
|
13
13
|
attribute :server_id, 'serverId'
|
14
14
|
|
@@ -28,7 +28,7 @@ module Fog
|
|
28
28
|
def save
|
29
29
|
requires :server_id
|
30
30
|
|
31
|
-
data = connection.
|
31
|
+
data = connection.create_image(@server_id, 'name' => name)
|
32
32
|
merge_attributes(data.body['image'])
|
33
33
|
true
|
34
34
|
end
|