fog 0.3.16 → 0.3.17
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.rdoc +17 -12
- data/fog.gemspec +10 -5
- data/lib/fog.rb +1 -1
- data/lib/fog/aws/models/storage/directory.rb +22 -0
- data/lib/fog/aws/models/storage/file.rb +15 -0
- data/lib/fog/aws/storage.rb +8 -0
- data/lib/fog/core/collection.rb +9 -8
- data/lib/fog/core/compute.rb +1 -1
- data/lib/fog/google/models/storage/directory.rb +23 -1
- data/lib/fog/google/models/storage/file.rb +16 -1
- data/lib/fog/google/parsers/storage/access_control_list.rb +16 -14
- data/lib/fog/local/models/storage/directory.rb +8 -0
- data/lib/fog/local/models/storage/file.rb +4 -0
- data/lib/fog/rackspace/cdn.rb +3 -3
- data/lib/fog/rackspace/models/storage/directory.rb +18 -0
- data/lib/fog/rackspace/models/storage/file.rb +7 -0
- data/lib/fog/rackspace/requests/cdn/{get_cdn_containers.rb → get_containers.rb} +3 -3
- data/lib/fog/rackspace/requests/cdn/{head_cdn_container.rb → head_container.rb} +3 -3
- data/lib/fog/rackspace/requests/cdn/{put_cdn_container.rb → put_container.rb} +3 -3
- data/lib/fog/rackspace/storage.rb +10 -0
- data/lib/fog/vcloud.rb +32 -153
- data/lib/fog/vcloud/collection.rb +18 -0
- data/lib/fog/vcloud/mock_data_classes.rb +701 -0
- data/lib/fog/vcloud/requests/get_network.rb +8 -8
- data/lib/fog/vcloud/requests/get_organization.rb +10 -10
- data/lib/fog/vcloud/requests/get_vdc.rb +18 -18
- data/lib/fog/vcloud/requests/get_versions.rb +3 -3
- data/lib/fog/vcloud/requests/login.rb +2 -2
- data/lib/fog/vcloud/terremark/ecloud.rb +65 -109
- data/lib/fog/vcloud/terremark/ecloud/models/catalog.rb +1 -0
- data/lib/fog/vcloud/terremark/ecloud/models/firewall_acls.rb +1 -0
- data/lib/fog/vcloud/terremark/ecloud/models/internet_services.rb +1 -0
- data/lib/fog/vcloud/terremark/ecloud/models/ip.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/ips.rb +1 -0
- data/lib/fog/vcloud/terremark/ecloud/models/network.rb +3 -2
- data/lib/fog/vcloud/terremark/ecloud/models/networks.rb +1 -0
- data/lib/fog/vcloud/terremark/ecloud/models/nodes.rb +1 -0
- data/lib/fog/vcloud/terremark/ecloud/models/public_ips.rb +1 -0
- data/lib/fog/vcloud/terremark/ecloud/models/server.rb +20 -8
- data/lib/fog/vcloud/terremark/ecloud/models/servers.rb +1 -0
- data/lib/fog/vcloud/terremark/ecloud/models/tasks.rb +1 -0
- data/lib/fog/vcloud/terremark/ecloud/models/vdcs.rb +2 -0
- data/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +4 -8
- data/lib/fog/vcloud/terremark/ecloud/requests/add_node.rb +4 -7
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +18 -20
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_node.rb +6 -7
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_vapp.rb +40 -9
- data/lib/fog/vcloud/terremark/ecloud/requests/delete_internet_service.rb +2 -10
- data/lib/fog/vcloud/terremark/ecloud/requests/delete_node.rb +2 -6
- data/lib/fog/vcloud/terremark/ecloud/requests/delete_vapp.rb +13 -1
- data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb +6 -6
- data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog_item.rb +6 -7
- data/lib/fog/vcloud/terremark/ecloud/requests/get_internet_services.rb +34 -33
- data/lib/fog/vcloud/terremark/ecloud/requests/get_network.rb +23 -24
- data/lib/fog/vcloud/terremark/ecloud/requests/get_network_extensions.rb +10 -13
- data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ip.rb +15 -19
- data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ips.rb +20 -22
- data/lib/fog/vcloud/terremark/ecloud/requests/get_node.rb +12 -15
- data/lib/fog/vcloud/terremark/ecloud/requests/get_nodes.rb +11 -12
- data/lib/fog/vcloud/terremark/ecloud/requests/get_public_ip.rb +5 -4
- data/lib/fog/vcloud/terremark/ecloud/requests/get_public_ips.rb +9 -8
- data/lib/fog/vcloud/terremark/ecloud/requests/get_vapp.rb +33 -17
- data/lib/fog/vcloud/terremark/ecloud/requests/get_vdc.rb +54 -53
- data/lib/fog/vcloud/terremark/ecloud/requests/instantiate_vapp_template.rb +13 -19
- data/lib/fog/vcloud/terremark/ecloud/requests/power_off.rb +9 -2
- data/lib/fog/vcloud/terremark/ecloud/requests/power_on.rb +2 -4
- data/spec/vcloud/bin_spec.rb +3 -6
- data/spec/vcloud/models/vdc_spec.rb +8 -8
- data/spec/vcloud/requests/get_network_spec.rb +8 -8
- data/spec/vcloud/requests/get_organization_spec.rb +9 -9
- data/spec/vcloud/requests/get_vdc_spec.rb +7 -7
- data/spec/vcloud/requests/get_versions_spec.rb +1 -1
- data/spec/vcloud/requests/login_spec.rb +2 -2
- data/spec/vcloud/spec_helper.rb +45 -30
- data/spec/vcloud/terremark/ecloud/models/internet_service_spec.rb +10 -14
- data/spec/vcloud/terremark/ecloud/models/ip_spec.rb +5 -8
- data/spec/vcloud/terremark/ecloud/models/ips_spec.rb +2 -2
- data/spec/vcloud/terremark/ecloud/models/network_spec.rb +15 -16
- data/spec/vcloud/terremark/ecloud/models/node_spec.rb +7 -7
- data/spec/vcloud/terremark/ecloud/models/nodes_spec.rb +1 -1
- data/spec/vcloud/terremark/ecloud/models/public_ip_spec.rb +4 -8
- data/spec/vcloud/terremark/ecloud/models/server_spec.rb +42 -0
- data/spec/vcloud/terremark/ecloud/models/vdc_spec.rb +7 -7
- data/spec/vcloud/terremark/ecloud/models/vdcs_spec.rb +1 -1
- data/spec/vcloud/terremark/ecloud/requests/add_internet_service_spec.rb +13 -18
- data/spec/vcloud/terremark/ecloud/requests/add_node_spec.rb +9 -5
- data/spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb +5 -7
- data/spec/vcloud/terremark/ecloud/requests/configure_node_spec.rb +22 -28
- data/spec/vcloud/terremark/ecloud/requests/configure_vapp_spec.rb +71 -0
- data/spec/vcloud/terremark/ecloud/requests/delete_internet_service_spec.rb +7 -9
- data/spec/vcloud/terremark/ecloud/requests/delete_node_spec.rb +3 -7
- data/spec/vcloud/terremark/ecloud/requests/delete_vapp_spec.rb +83 -0
- data/spec/vcloud/terremark/ecloud/requests/get_catalog_item_spec.rb +6 -5
- data/spec/vcloud/terremark/ecloud/requests/get_catalog_spec.rb +2 -2
- data/spec/vcloud/terremark/ecloud/requests/get_internet_services_spec.rb +31 -42
- data/spec/vcloud/terremark/ecloud/requests/get_network_ip_spec.rb +4 -7
- data/spec/vcloud/terremark/ecloud/requests/get_network_ips_spec.rb +1 -1
- data/spec/vcloud/terremark/ecloud/requests/get_network_spec.rb +19 -11
- data/spec/vcloud/terremark/ecloud/requests/get_node_spec.rb +8 -8
- data/spec/vcloud/terremark/ecloud/requests/get_nodes_spec.rb +11 -11
- data/spec/vcloud/terremark/ecloud/requests/get_public_ip_spec.rb +4 -5
- data/spec/vcloud/terremark/ecloud/requests/get_public_ips_spec.rb +6 -6
- data/spec/vcloud/terremark/ecloud/requests/get_vapp_spec.rb +36 -19
- data/spec/vcloud/terremark/ecloud/requests/get_vdc_spec.rb +21 -18
- data/spec/vcloud/terremark/ecloud/requests/instantiate_vapp_template_spec.rb +27 -17
- data/spec/vcloud/terremark/ecloud/requests/power_off_spec.rb +34 -0
- data/spec/vcloud/terremark/ecloud/requests/power_on_spec.rb +3 -4
- data/spec/vcloud/vcloud_spec.rb +2 -2
- data/tests/helpers/storage/directory_tests.rb +8 -0
- data/tests/helpers/storage/file_tests.rb +4 -0
- metadata +11 -6
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
@@ -3,6 +3,7 @@ http://geemus.s3.amazonaws.com/fog.png
|
|
3
3
|
fog is the Ruby cloud computing library.
|
4
4
|
|
5
5
|
The quick and dirty, top to bottom:
|
6
|
+
|
6
7
|
* Collections provide a simplified interface, making clouds easier to work with and switch between.
|
7
8
|
* Requests allow power users to get the most out of the features of each individual cloud.
|
8
9
|
* Mocks make testing and integrating a breeze.
|
@@ -25,16 +26,18 @@ Now just type 'fog' to trying stuff out, confident that fog should let you know
|
|
25
26
|
== Collections
|
26
27
|
|
27
28
|
A high level interface to each cloud is provided through collections, such as images and servers.
|
28
|
-
You can see a list of available collections by calling #collections on the connection object.
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
You can see a list of available collections by calling #collections on the connection object. You can try it out using the `fog` command:
|
30
|
+
|
31
|
+
>> server = AWS.collections
|
32
|
+
[:addresses, :directories, :files, :flavors, :images, :key_pairs, :security_groups, :servers, :snapshots, :volumes]
|
32
33
|
|
33
|
-
Some
|
34
|
-
|
35
|
-
|
36
|
-
*
|
37
|
-
*
|
34
|
+
Some of these collections are available across multiple providers. For example, all compute providers have +flavors+, +images+ and +servers+, and storage providers have +directory+ and +file+.
|
35
|
+
|
36
|
+
Collections share most of the basic CRUD type operations, such as:
|
37
|
+
* +#all+ - fetch every object of that type from the provider.
|
38
|
+
* +#create+ initialize a new record locally and then persists it with the provider.
|
39
|
+
* +#get+ - fetch a single object by its identity from the provider.
|
40
|
+
* +#new+ - initialize a new record locally, but do not persist it to the provider.
|
38
41
|
|
39
42
|
As an example, we'll try initializing and persisting a Rackspace Cloud server:
|
40
43
|
|
@@ -60,12 +63,14 @@ As an example, we'll try initializing and persisting a Rackspace Cloud server:
|
|
60
63
|
== Models
|
61
64
|
|
62
65
|
Many of the collection methods return individual objects, which also provide some common methods:
|
63
|
-
*
|
64
|
-
*
|
65
|
-
*
|
66
|
+
* +#destroy+ - will destroy the persisted object from the provider
|
67
|
+
* +#save+ - persist the object to the provider
|
68
|
+
* +#wait_for+ - takes a block and waits for either the block to return true for the object or for a timeout (defaults to 10 minutes)
|
66
69
|
|
67
70
|
== Mocks
|
68
71
|
|
72
|
+
As you might imagine, testing code using Fog could be feasibly slow and expensive to constantly be turning and and shutting down instances. Fortunately, fog includes support for mocking itself out.
|
73
|
+
|
69
74
|
Mocking provides an in memory representation of the state of cloud resources as you make requests.
|
70
75
|
Mocked calls to mimic the behavior of each provider while eliminating the cost and time needed to actually use cloud resources.
|
71
76
|
Enabling mocking easy to use, before you run any other commands run:
|
data/fog.gemspec
CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |s|
|
|
7
7
|
## If your rubyforge_project name is different, then edit it and comment out
|
8
8
|
## the sub! line in the Rakefile
|
9
9
|
s.name = 'fog'
|
10
|
-
s.version = '0.3.
|
11
|
-
s.date = '2010-11-
|
10
|
+
s.version = '0.3.17'
|
11
|
+
s.date = '2010-11-05'
|
12
12
|
s.rubyforge_project = 'fog'
|
13
13
|
|
14
14
|
## Make sure your summary is short. The description may be as long
|
@@ -374,9 +374,9 @@ Gem::Specification.new do |s|
|
|
374
374
|
lib/fog/rackspace/models/storage/directory.rb
|
375
375
|
lib/fog/rackspace/models/storage/file.rb
|
376
376
|
lib/fog/rackspace/models/storage/files.rb
|
377
|
-
lib/fog/rackspace/requests/cdn/
|
378
|
-
lib/fog/rackspace/requests/cdn/
|
379
|
-
lib/fog/rackspace/requests/cdn/
|
377
|
+
lib/fog/rackspace/requests/cdn/get_containers.rb
|
378
|
+
lib/fog/rackspace/requests/cdn/head_container.rb
|
379
|
+
lib/fog/rackspace/requests/cdn/put_container.rb
|
380
380
|
lib/fog/rackspace/requests/compute/create_image.rb
|
381
381
|
lib/fog/rackspace/requests/compute/create_server.rb
|
382
382
|
lib/fog/rackspace/requests/compute/delete_image.rb
|
@@ -500,6 +500,7 @@ Gem::Specification.new do |s|
|
|
500
500
|
lib/fog/vcloud/bin.rb
|
501
501
|
lib/fog/vcloud/collection.rb
|
502
502
|
lib/fog/vcloud/generators.rb
|
503
|
+
lib/fog/vcloud/mock_data_classes.rb
|
503
504
|
lib/fog/vcloud/model.rb
|
504
505
|
lib/fog/vcloud/models/vdc.rb
|
505
506
|
lib/fog/vcloud/models/vdcs.rb
|
@@ -631,14 +632,17 @@ Gem::Specification.new do |s|
|
|
631
632
|
spec/vcloud/terremark/ecloud/models/nodes_spec.rb
|
632
633
|
spec/vcloud/terremark/ecloud/models/public_ip_spec.rb
|
633
634
|
spec/vcloud/terremark/ecloud/models/public_ips_spec.rb
|
635
|
+
spec/vcloud/terremark/ecloud/models/server_spec.rb
|
634
636
|
spec/vcloud/terremark/ecloud/models/vdc_spec.rb
|
635
637
|
spec/vcloud/terremark/ecloud/models/vdcs_spec.rb
|
636
638
|
spec/vcloud/terremark/ecloud/requests/add_internet_service_spec.rb
|
637
639
|
spec/vcloud/terremark/ecloud/requests/add_node_spec.rb
|
638
640
|
spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb
|
639
641
|
spec/vcloud/terremark/ecloud/requests/configure_node_spec.rb
|
642
|
+
spec/vcloud/terremark/ecloud/requests/configure_vapp_spec.rb
|
640
643
|
spec/vcloud/terremark/ecloud/requests/delete_internet_service_spec.rb
|
641
644
|
spec/vcloud/terremark/ecloud/requests/delete_node_spec.rb
|
645
|
+
spec/vcloud/terremark/ecloud/requests/delete_vapp_spec.rb
|
642
646
|
spec/vcloud/terremark/ecloud/requests/get_catalog_item_spec.rb
|
643
647
|
spec/vcloud/terremark/ecloud/requests/get_catalog_spec.rb
|
644
648
|
spec/vcloud/terremark/ecloud/requests/get_customization_options_spec.rb
|
@@ -654,6 +658,7 @@ Gem::Specification.new do |s|
|
|
654
658
|
spec/vcloud/terremark/ecloud/requests/get_vdc_spec.rb
|
655
659
|
spec/vcloud/terremark/ecloud/requests/instantiate_vapp_template_spec.rb
|
656
660
|
spec/vcloud/terremark/ecloud/requests/login_spec.rb
|
661
|
+
spec/vcloud/terremark/ecloud/requests/power_off_spec.rb
|
657
662
|
spec/vcloud/terremark/ecloud/requests/power_on_spec.rb
|
658
663
|
spec/vcloud/vcloud_spec.rb
|
659
664
|
tests/aws/helper.rb
|
data/lib/fog.rb
CHANGED
@@ -61,6 +61,28 @@ module Fog
|
|
61
61
|
@payer = new_payer
|
62
62
|
end
|
63
63
|
|
64
|
+
def public=(new_public)
|
65
|
+
if new_public
|
66
|
+
@acl = 'public-read'
|
67
|
+
else
|
68
|
+
@acl = 'private'
|
69
|
+
end
|
70
|
+
new_public
|
71
|
+
end
|
72
|
+
|
73
|
+
def public_url
|
74
|
+
requires :key
|
75
|
+
if connection.get_bucket_acl(key).body['AccessControlList'].detect {|grant| grant['Grantee']['URI'] == 'http://acs.amazonaws.com/groups/global/AllUsers' && grant['Permission'] == 'READ'}
|
76
|
+
if key.to_s =~ /^(?:[a-z]|\d(?!\d{0,2}(?:\.\d{1,3}){3}$))(?:[a-z0-9]|\.(?![\.\-])|\-(?![\.])){1,61}[a-z0-9]$/
|
77
|
+
"https://#{key}.s3.amazonaws.com"
|
78
|
+
else
|
79
|
+
"https://s3.amazonaws.com/#{key}"
|
80
|
+
end
|
81
|
+
else
|
82
|
+
nil
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
64
86
|
def save
|
65
87
|
requires :key
|
66
88
|
options = {}
|
@@ -60,6 +60,21 @@ module Fog
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
+
def public_url
|
64
|
+
requires :directory, :key
|
65
|
+
if directory.public_url
|
66
|
+
"#{directory.public_url}/#{key}"
|
67
|
+
elsif connection.get_object_acl(directory.key, key).body['AccessControlList'].detect {|grant| grant['Grantee']['URI'] == 'http://acs.amazonaws.com/groups/global/AllUsers' && grant['Permission'] == 'READ'}
|
68
|
+
if directory.key.to_s =~ /^(?:[a-z]|\d(?!\d{0,2}(?:\.\d{1,3}){3}$))(?:[a-z0-9]|\.(?![\.\-])|\-(?![\.])){1,61}[a-z0-9]$/
|
69
|
+
"https://#{directory.key}.s3.amazonaws.com/#{key}"
|
70
|
+
else
|
71
|
+
"https://s3.amazonaws.com/#{directory.key}/#{key}"
|
72
|
+
end
|
73
|
+
else
|
74
|
+
nil
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
63
78
|
def save(options = {})
|
64
79
|
requires :body, :directory, :key
|
65
80
|
if options != {}
|
data/lib/fog/aws/storage.rb
CHANGED
@@ -38,6 +38,13 @@ module Fog
|
|
38
38
|
|
39
39
|
module Utils
|
40
40
|
|
41
|
+
def cdn
|
42
|
+
@cdn ||= Fog::AWS::CDN.new(
|
43
|
+
:aws_access_key_id => @aws_access_key_id,
|
44
|
+
:aws_secret_access_key => @aws_secret_access_key
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
41
48
|
def parse_data(data)
|
42
49
|
metadata = {
|
43
50
|
:body => nil,
|
@@ -93,6 +100,7 @@ module Fog
|
|
93
100
|
def initialize(options={})
|
94
101
|
require 'mime/types'
|
95
102
|
@aws_access_key_id = options[:aws_access_key_id]
|
103
|
+
@aws_secret_access_key = options[:aws_secret_access_key]
|
96
104
|
options[:region] ||= 'us-east-1'
|
97
105
|
@host = options[:host] || case options[:region]
|
98
106
|
when 'eu-west-1'
|
data/lib/fog/core/collection.rb
CHANGED
@@ -5,19 +5,20 @@ module Fog
|
|
5
5
|
include Fog::Attributes::InstanceMethods
|
6
6
|
|
7
7
|
Array.public_instance_methods(false).each do |method|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
unless [:reject, :select].include?(method.to_sym)
|
9
|
+
class_eval <<-RUBY
|
10
|
+
def #{method}(*args)
|
11
|
+
unless @loaded
|
12
|
+
lazy_load
|
13
|
+
end
|
14
|
+
super
|
12
15
|
end
|
13
|
-
|
14
|
-
|
15
|
-
RUBY
|
16
|
+
RUBY
|
17
|
+
end
|
16
18
|
end
|
17
19
|
|
18
20
|
%w[reject select].each do |method|
|
19
21
|
class_eval <<-RUBY
|
20
|
-
# remove_method :#{method}
|
21
22
|
def #{method}(*args)
|
22
23
|
unless @loaded
|
23
24
|
lazy_load
|
data/lib/fog/core/compute.rb
CHANGED
@@ -39,11 +39,33 @@ module Fog
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
def public=(new_public)
|
43
|
+
if new_public
|
44
|
+
@acl = 'public-read'
|
45
|
+
else
|
46
|
+
@acl = 'private'
|
47
|
+
end
|
48
|
+
new_public
|
49
|
+
end
|
50
|
+
|
51
|
+
def public_url
|
52
|
+
requires :key
|
53
|
+
if connection.get_bucket_acl(key).body['AccessControlList'].detect {|entry| entry['Scope']['type'] == 'AllUsers' && entry['Permission'] == 'READ'}
|
54
|
+
if key.to_s =~ /^(?:[a-z]|\d(?!\d{0,2}(?:\.\d{1,3}){3}$))(?:[a-z0-9]|\.(?![\.\-])|\-(?![\.])){1,61}[a-z0-9]$/
|
55
|
+
"https://#{key}.commondatastorage.googleapis.com"
|
56
|
+
else
|
57
|
+
"https://commondatastorage.googleapis.com/#{key}"
|
58
|
+
end
|
59
|
+
else
|
60
|
+
nil
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
42
64
|
def save
|
43
65
|
requires :key
|
44
66
|
options = {}
|
45
67
|
if @acl
|
46
|
-
options['x-
|
68
|
+
options['x-goog-acl'] = @acl
|
47
69
|
end
|
48
70
|
if @location
|
49
71
|
options['LocationConstraint'] = @location
|
@@ -63,13 +63,28 @@ module Fog
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
+
def public_url
|
67
|
+
requires :directory, :key
|
68
|
+
if directory.public_url
|
69
|
+
"#{directory.public_url}/#{key}"
|
70
|
+
elsif connection.get_object_acl(directory.key, key).body['AccessControlList'].detect {|entry| entry['Scope']['type'] == 'AllUsers' && entry['Permission'] == 'READ'}
|
71
|
+
if directory.key.to_s =~ /^(?:[a-z]|\d(?!\d{0,2}(?:\.\d{1,3}){3}$))(?:[a-z0-9]|\.(?![\.\-])|\-(?![\.])){1,61}[a-z0-9]$/
|
72
|
+
"https://#{directory.key}.commondatastorage.googleapis/#{key}"
|
73
|
+
else
|
74
|
+
"https://commondatastorage.googleapis.com/#{directory.key}/#{key}"
|
75
|
+
end
|
76
|
+
else
|
77
|
+
nil
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
66
81
|
def save(options = {})
|
67
82
|
requires :body, :directory, :key
|
68
83
|
if options != {}
|
69
84
|
Formatador.display_line("[yellow][WARN] options param is deprecated, use acl= instead[/] [light_black](#{caller.first})[/]")
|
70
85
|
end
|
71
86
|
if @acl
|
72
|
-
options['x-
|
87
|
+
options['x-goog-acl'] ||= @acl
|
73
88
|
end
|
74
89
|
if content_type
|
75
90
|
options['Content-Type'] = content_type
|
@@ -6,35 +6,37 @@ module Fog
|
|
6
6
|
class AccessControlList < Fog::Parsers::Base
|
7
7
|
|
8
8
|
def reset
|
9
|
-
@
|
10
|
-
@
|
9
|
+
@in_entries = false
|
10
|
+
@entry = { 'Scope' => {} }
|
11
11
|
@response = { 'Owner' => {}, 'AccessControlList' => [] }
|
12
12
|
end
|
13
13
|
|
14
14
|
def start_element(name, attrs = [])
|
15
15
|
super
|
16
|
-
|
17
|
-
|
16
|
+
case name
|
17
|
+
when 'Entries'
|
18
|
+
@in_entries = true
|
19
|
+
when 'Scope'
|
20
|
+
key, value = attrs
|
21
|
+
@entry['Scope'][key] = value
|
18
22
|
end
|
19
23
|
end
|
20
24
|
|
21
25
|
def end_element(name)
|
22
26
|
case name
|
23
|
-
when '
|
24
|
-
@
|
25
|
-
when '
|
26
|
-
@response['AccessControlList'] << @
|
27
|
-
@
|
27
|
+
when 'Entries'
|
28
|
+
@in_entries = false
|
29
|
+
when 'Entry'
|
30
|
+
@response['AccessControlList'] << @entry
|
31
|
+
@entry = { 'Scope' => {} }
|
28
32
|
when 'DisplayName', 'ID'
|
29
|
-
if @
|
30
|
-
@
|
33
|
+
if @in_entries
|
34
|
+
@entry['Scope'][name] = @value
|
31
35
|
else
|
32
36
|
@response['Owner'][name] = @value
|
33
37
|
end
|
34
38
|
when 'Permission'
|
35
|
-
@
|
36
|
-
when 'URI'
|
37
|
-
@grant['Grantee'][name] = @value
|
39
|
+
@entry[name] = @value
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
data/lib/fog/rackspace/cdn.rb
CHANGED
@@ -7,9 +7,9 @@ module Fog
|
|
7
7
|
model_path 'fog/rackspace/models/cdn'
|
8
8
|
|
9
9
|
request_path 'fog/rackspace/requests/cdn'
|
10
|
-
request :
|
11
|
-
request :
|
12
|
-
request :
|
10
|
+
request :get_containers
|
11
|
+
request :head_container
|
12
|
+
request :put_container
|
13
13
|
|
14
14
|
class Mock
|
15
15
|
|
@@ -32,9 +32,27 @@ module Fog
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
def public=(new_public)
|
36
|
+
@public = new_public
|
37
|
+
end
|
38
|
+
|
39
|
+
def public_url
|
40
|
+
requires :key
|
41
|
+
@public_url ||= begin
|
42
|
+
begin response = connection.cdn.head_container(key)
|
43
|
+
response.headers['X-CDN-URI']
|
44
|
+
rescue Fog::Service::NotFound
|
45
|
+
nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
35
50
|
def save
|
36
51
|
requires :key
|
37
52
|
connection.put_container(key)
|
53
|
+
if @public
|
54
|
+
@public_url = connection.cdn.put_container(key).headers['X-CDN-URI']
|
55
|
+
end
|
38
56
|
true
|
39
57
|
end
|
40
58
|
|
@@ -41,6 +41,13 @@ module Fog
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
def public_url
|
45
|
+
requires :directory, :key
|
46
|
+
if @directory.public_url
|
47
|
+
"#{@directory.public_url}/#{key}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
44
51
|
def save(options = {})
|
45
52
|
requires :body, :directory, :key
|
46
53
|
data = connection.put_object(directory.key, @key, @body, options)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Fog
|
2
2
|
module Rackspace
|
3
|
-
class
|
3
|
+
class CDN
|
4
4
|
class Real
|
5
5
|
|
6
6
|
# List existing cdn-enabled storage containers
|
@@ -15,7 +15,7 @@ module Fog
|
|
15
15
|
# * response<~Excon::Response>:
|
16
16
|
# * body<~Array>:
|
17
17
|
# * container<~String>: Name of container
|
18
|
-
def
|
18
|
+
def get_containers(options = {})
|
19
19
|
response = request(
|
20
20
|
:expects => [200, 204],
|
21
21
|
:method => 'GET',
|
@@ -29,7 +29,7 @@ module Fog
|
|
29
29
|
|
30
30
|
class Mock
|
31
31
|
|
32
|
-
def
|
32
|
+
def get_containers(options = {})
|
33
33
|
Fog::Mock.not_implemented
|
34
34
|
end
|
35
35
|
|