fog 0.3.7 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +6 -6
- data/README.rdoc +7 -1
- data/bin/fog +4 -3
- data/fog.gemspec +39 -24
- data/lib/fog.rb +4 -12
- data/lib/fog/aws.rb +14 -5
- data/lib/fog/aws/compute.rb +26 -9
- data/lib/fog/aws/elb.rb +3 -2
- data/lib/fog/aws/models/compute/address.rb +2 -1
- data/lib/fog/aws/models/compute/addresses.rb +11 -9
- data/lib/fog/aws/models/compute/flavor.rb +1 -1
- data/lib/fog/aws/models/compute/flavors.rb +13 -11
- data/lib/fog/aws/models/compute/image.rb +2 -1
- data/lib/fog/aws/models/compute/images.rb +7 -9
- data/lib/fog/aws/models/compute/key_pair.rb +1 -1
- data/lib/fog/aws/models/compute/key_pairs.rb +10 -8
- data/lib/fog/aws/models/compute/security_group.rb +1 -1
- data/lib/fog/aws/models/compute/security_groups.rb +11 -9
- data/lib/fog/aws/models/compute/server.rb +10 -3
- data/lib/fog/aws/models/compute/servers.rb +14 -8
- data/lib/fog/aws/models/compute/snapshot.rb +3 -2
- data/lib/fog/aws/models/compute/snapshots.rb +11 -16
- data/lib/fog/aws/models/compute/tag.rb +36 -0
- data/lib/fog/aws/models/compute/tags.rb +34 -0
- data/lib/fog/aws/models/compute/volume.rb +11 -10
- data/lib/fog/aws/models/compute/volumes.rb +11 -9
- data/lib/fog/aws/models/storage/directories.rb +1 -1
- data/lib/fog/aws/models/storage/directory.rb +1 -1
- data/lib/fog/aws/models/storage/file.rb +3 -2
- data/lib/fog/aws/models/storage/files.rb +1 -7
- data/lib/fog/aws/parsers/compute/describe_availability_zones.rb +4 -2
- data/lib/fog/aws/parsers/compute/describe_images.rb +23 -13
- data/lib/fog/aws/parsers/compute/describe_instances.rb +34 -8
- data/lib/fog/aws/parsers/compute/describe_security_groups.rb +4 -3
- data/lib/fog/aws/parsers/compute/describe_snapshots.rb +33 -13
- data/lib/fog/aws/parsers/compute/describe_tags.rb +30 -0
- data/lib/fog/aws/parsers/compute/describe_volumes.rb +17 -3
- data/lib/fog/aws/parsers/compute/run_instances.rb +4 -4
- data/lib/fog/aws/parsers/storage/get_bucket.rb +1 -1
- data/lib/fog/aws/parsers/storage/get_bucket_logging.rb +1 -1
- data/lib/fog/aws/parsers/storage/get_bucket_object_versions.rb +3 -3
- data/lib/fog/aws/requests/compute/create_snapshot.rb +1 -0
- data/lib/fog/aws/requests/compute/create_tags.rb +78 -0
- data/lib/fog/aws/requests/compute/delete_tags.rb +45 -0
- data/lib/fog/aws/requests/compute/describe_addresses.rb +27 -19
- data/lib/fog/aws/requests/compute/describe_availability_zones.rb +31 -25
- data/lib/fog/aws/requests/compute/describe_images.rb +11 -18
- data/lib/fog/aws/requests/compute/describe_instances.rb +125 -53
- data/lib/fog/aws/requests/compute/describe_key_pairs.rb +29 -21
- data/lib/fog/aws/requests/compute/describe_regions.rb +28 -23
- data/lib/fog/aws/requests/compute/describe_reserved_instances.rb +8 -4
- data/lib/fog/aws/requests/compute/describe_security_groups.rb +48 -19
- data/lib/fog/aws/requests/compute/describe_snapshots.rb +72 -35
- data/lib/fog/aws/requests/compute/describe_tags.rb +42 -0
- data/lib/fog/aws/requests/compute/describe_volumes.rb +67 -36
- data/lib/fog/aws/requests/compute/run_instances.rb +10 -3
- data/lib/fog/aws/simpledb.rb +3 -1
- data/lib/fog/aws/storage.rb +17 -8
- data/lib/fog/bluebox/models/compute/flavor.rb +1 -1
- data/lib/fog/bluebox/models/compute/flavors.rb +1 -1
- data/lib/fog/bluebox/models/compute/image.rb +1 -1
- data/lib/fog/bluebox/models/compute/images.rb +1 -1
- data/lib/fog/bluebox/models/compute/server.rb +8 -6
- data/lib/fog/bluebox/models/compute/servers.rb +1 -1
- data/lib/fog/bluebox/requests/compute/get_blocks.rb +1 -1
- data/lib/fog/core.rb +11 -0
- data/lib/fog/{attributes.rb → core/attributes.rb} +0 -0
- data/lib/fog/{bin.rb → core/bin.rb} +1 -1
- data/lib/fog/{collection.rb → core/collection.rb} +4 -0
- data/lib/fog/{connection.rb → core/connection.rb} +0 -0
- data/lib/fog/{credentials.rb → core/credentials.rb} +2 -0
- data/lib/fog/{deprecation.rb → core/deprecation.rb} +0 -0
- data/lib/fog/{errors.rb → core/errors.rb} +0 -0
- data/lib/fog/{hmac.rb → core/hmac.rb} +0 -0
- data/lib/fog/{model.rb → core/model.rb} +0 -0
- data/lib/fog/{parser.rb → core/parser.rb} +0 -0
- data/lib/fog/{provider.rb → core/provider.rb} +0 -0
- data/lib/fog/{service.rb → core/service.rb} +1 -0
- data/lib/fog/{ssh.rb → core/ssh.rb} +7 -7
- data/lib/fog/go_grid.rb +1 -1
- data/lib/fog/go_grid/compute.rb +6 -1
- data/lib/fog/go_grid/models/compute/image.rb +60 -0
- data/lib/fog/go_grid/models/compute/images.rb +33 -0
- data/lib/fog/go_grid/models/compute/server.rb +56 -0
- data/lib/fog/go_grid/models/compute/servers.rb +35 -0
- data/lib/fog/go_grid/requests/compute/grid_image_get.rb +41 -0
- data/lib/fog/go_grid/requests/compute/grid_image_list.rb +6 -1
- data/lib/fog/go_grid/requests/compute/grid_server_power.rb +2 -2
- data/lib/fog/google/models/storage/directories.rb +1 -1
- data/lib/fog/google/models/storage/directory.rb +1 -1
- data/lib/fog/google/models/storage/file.rb +3 -2
- data/lib/fog/google/models/storage/files.rb +1 -7
- data/lib/fog/google/parsers/storage/get_bucket.rb +1 -1
- data/lib/fog/linode/requests/compute/avail_linodeplans.rb +2 -2
- data/lib/fog/local/models/storage/directories.rb +1 -1
- data/lib/fog/local/models/storage/directory.rb +1 -1
- data/lib/fog/local/models/storage/file.rb +2 -2
- data/lib/fog/local/models/storage/files.rb +2 -5
- data/lib/fog/local/storage.rb +1 -1
- data/lib/fog/new_servers/compute.rb +1 -1
- data/lib/fog/rackspace/models/compute/flavor.rb +1 -3
- data/lib/fog/rackspace/models/compute/flavors.rb +1 -1
- data/lib/fog/rackspace/models/compute/image.rb +2 -1
- data/lib/fog/rackspace/models/compute/images.rb +1 -1
- data/lib/fog/rackspace/models/compute/server.rb +12 -11
- data/lib/fog/rackspace/models/compute/servers.rb +1 -1
- data/lib/fog/rackspace/models/storage/directories.rb +1 -1
- data/lib/fog/rackspace/models/storage/directory.rb +1 -1
- data/lib/fog/rackspace/models/storage/file.rb +4 -4
- data/lib/fog/rackspace/models/storage/files.rb +1 -1
- data/lib/fog/rackspace/requests/compute/create_image.rb +2 -2
- data/lib/fog/rackspace/requests/compute/delete_image.rb +1 -1
- data/lib/fog/rackspace/requests/compute/delete_server.rb +1 -1
- data/lib/fog/rackspace/requests/compute/get_server_details.rb +1 -1
- data/lib/fog/rackspace/requests/compute/list_addresses.rb +1 -1
- data/lib/fog/rackspace/requests/compute/list_images_detail.rb +2 -2
- data/lib/fog/rackspace/requests/compute/list_private_addresses.rb +1 -1
- data/lib/fog/rackspace/requests/compute/list_public_addresses.rb +1 -1
- data/lib/fog/rackspace/requests/compute/update_server.rb +1 -1
- data/lib/fog/rackspace/requests/storage/put_object.rb +4 -3
- data/lib/fog/slicehost/models/compute/flavor.rb +1 -1
- data/lib/fog/slicehost/models/compute/flavors.rb +1 -1
- data/lib/fog/slicehost/models/compute/image.rb +1 -1
- data/lib/fog/slicehost/models/compute/images.rb +1 -1
- data/lib/fog/slicehost/models/compute/server.rb +3 -1
- data/lib/fog/slicehost/models/compute/servers.rb +1 -1
- data/lib/fog/terremark/ecloud.rb +34 -33
- data/lib/fog/terremark/models/shared/address.rb +1 -1
- data/lib/fog/terremark/models/shared/network.rb +1 -1
- data/lib/fog/terremark/models/shared/server.rb +1 -1
- data/lib/fog/terremark/models/shared/servers.rb +1 -1
- data/lib/fog/terremark/models/shared/task.rb +1 -1
- data/lib/fog/terremark/models/shared/tasks.rb +1 -1
- data/lib/fog/terremark/models/shared/vdc.rb +1 -1
- data/lib/fog/terremark/parser.rb +1 -0
- data/lib/fog/terremark/vcloud.rb +4 -4
- data/lib/fog/vcloud.rb +15 -7
- data/lib/fog/vcloud/terremark/ecloud.rb +15 -3
- data/lib/fog/vcloud/terremark/ecloud/models/firewall_acls.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/internet_services.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/ips.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/networks.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/nodes.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/public_ips.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/servers.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/tasks.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/vdcs.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +55 -49
- data/lib/fog/vcloud/terremark/ecloud/requests/add_node.rb +19 -15
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +8 -1
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_node.rb +17 -12
- data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb +29 -1
- data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog_item.rb +38 -2
- data/lib/fog/vcloud/terremark/ecloud/requests/get_customization_options.rb +8 -2
- data/lib/fog/vcloud/terremark/ecloud/requests/instantiate_vapp_template.rb +46 -4
- data/spec/aws/models/compute/server_spec.rb +2 -0
- data/spec/aws/requests/simpledb/select_spec.rb +1 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/vcloud/spec_helper.rb +1 -1
- data/spec/vcloud/terremark/ecloud/requests/get_catalog_item_spec.rb +62 -0
- data/spec/vcloud/terremark/ecloud/requests/get_catalog_spec.rb +44 -0
- data/spec/vcloud/terremark/ecloud/requests/get_customization_options_spec.rb +39 -0
- data/spec/vcloud/terremark/ecloud/requests/instantiate_vapp_template_spec.rb +73 -0
- data/tests/aws/requests/compute/address_tests.rb +2 -6
- data/tests/aws/requests/compute/availability_zone_tests.rb +3 -10
- data/tests/aws/requests/compute/image_tests.rb +4 -9
- data/tests/aws/requests/compute/instance_tests.rb +7 -8
- data/tests/aws/requests/compute/key_pair_tests.rb +2 -6
- data/tests/aws/requests/compute/region_tests.rb +2 -9
- data/tests/aws/requests/compute/security_group_tests.rb +3 -7
- data/tests/aws/requests/compute/snapshot_tests.rb +4 -7
- data/tests/aws/requests/compute/tag_tests.rb +49 -0
- data/tests/aws/requests/compute/volume_tests.rb +2 -6
- data/tests/aws/requests/storage/bucket_tests.rb +48 -0
- data/tests/aws/requests/storage/object_tests.rb +63 -0
- data/tests/bluebox/requests/compute/block_tests.rb +24 -11
- data/tests/bluebox/requests/compute/product_tests.rb +3 -0
- data/tests/bluebox/requests/compute/template_tests.rb +3 -0
- data/tests/go_grid/helper.rb +0 -0
- data/tests/go_grid/requests/compute/image_tests.rb +0 -0
- data/tests/helper.rb +5 -1
- data/tests/linode/requests/compute/datacenter_tests.rb +1 -0
- data/tests/linode/requests/compute/distribution_tests.rb +2 -0
- data/tests/linode/requests/compute/linode_tests.rb +6 -0
- data/tests/linode/requests/compute/linodeplans_tests.rb +2 -0
- data/tests/lorem.txt +1 -0
- data/tests/rackspace/requests/compute/flavor_tests.rb +4 -0
- data/tests/rackspace/requests/compute/image_tests.rb +12 -4
- data/tests/rackspace/requests/compute/server_tests.rb +9 -0
- data/tests/slicehost/requests/compute/backup_tests.rb +1 -0
- data/tests/slicehost/requests/compute/flavor_tests.rb +3 -0
- data/tests/slicehost/requests/compute/image_tests.rb +3 -0
- data/tests/slicehost/requests/compute/slice_tests.rb +14 -2
- metadata +42 -27
- data/spec/aws/requests/storage/delete_bucket_spec.rb +0 -35
- data/spec/aws/requests/storage/delete_object_spec.rb +0 -36
- data/spec/aws/requests/storage/get_object_spec.rb +0 -58
- data/spec/aws/requests/storage/get_service_spec.rb +0 -32
- data/spec/aws/requests/storage/head_object_spec.rb +0 -26
- data/spec/aws/requests/storage/put_bucket_spec.rb +0 -19
- data/spec/aws/requests/storage/put_object_spec.rb +0 -43
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'fog/model'
|
1
|
+
require 'fog/core/model'
|
2
2
|
|
3
3
|
module Fog
|
4
4
|
module Slicehost
|
@@ -70,7 +70,9 @@ module Fog
|
|
70
70
|
end
|
71
71
|
|
72
72
|
def save
|
73
|
+
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
73
74
|
requires :flavor_id, :image_id, :name
|
75
|
+
|
74
76
|
data = connection.create_slice(@flavor_id, @image_id, @name)
|
75
77
|
merge_attributes(data.body)
|
76
78
|
true
|
data/lib/fog/terremark/ecloud.rb
CHANGED
@@ -1,39 +1,40 @@
|
|
1
1
|
module Fog
|
2
2
|
module Terremark
|
3
|
-
|
3
|
+
module Ecloud
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
module Bin
|
6
|
+
end
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
module Defaults
|
9
|
+
HOST = 'services.enterprisecloud.terremark.com'
|
10
|
+
PATH = '/api/v0.8a-ext2.0'
|
11
|
+
PORT = 443
|
12
|
+
SCHEME = 'https'
|
13
|
+
end
|
14
14
|
|
15
|
-
|
15
|
+
extend Fog::Terremark::Shared
|
16
16
|
|
17
|
-
|
17
|
+
def self.new(options={})
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
unless @required
|
20
|
+
shared_requires
|
21
|
+
@required = true
|
22
|
+
end
|
23
23
|
|
24
|
-
|
24
|
+
check_shared_options(options)
|
25
25
|
|
26
|
-
|
26
|
+
if Fog.mocking?
|
27
27
|
Fog::Terremark::Ecloud::Mock.new(options)
|
28
28
|
else
|
29
29
|
Fog::Terremark::Ecloud::Real.new(options)
|
30
30
|
end
|
31
|
-
end
|
32
31
|
|
33
|
-
|
32
|
+
end
|
33
|
+
|
34
|
+
class Real
|
34
35
|
|
35
|
-
|
36
|
-
|
36
|
+
include Fog::Terremark::Shared::Real
|
37
|
+
include Fog::Terremark::Shared::Parser
|
37
38
|
|
38
39
|
def initialize(options={})
|
39
40
|
@terremark_password = options[:terremark_ecloud_password]
|
@@ -47,18 +48,18 @@ module Fog
|
|
47
48
|
|
48
49
|
end
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
51
|
+
class Mock
|
52
|
+
include Fog::Terremark::Shared::Mock
|
53
|
+
include Fog::Terremark::Shared::Parser
|
54
|
+
|
55
|
+
def initialize(option = {})
|
56
|
+
super
|
57
|
+
@base_url = Fog::Terremark::Ecloud::Defaults::SCHEME + "://" +
|
58
|
+
Fog::Terremark::Ecloud::Defaults::HOST +
|
59
|
+
Fog::Terremark::Ecloud::Defaults::PATH
|
60
|
+
@data = self.class.data[:terremark_ecloud_username]
|
61
|
+
end
|
62
|
+
end
|
62
63
|
|
63
64
|
end
|
64
65
|
end
|
data/lib/fog/terremark/parser.rb
CHANGED
data/lib/fog/terremark/vcloud.rb
CHANGED
@@ -25,9 +25,9 @@ module Fog
|
|
25
25
|
|
26
26
|
if Fog.mocking?
|
27
27
|
Fog::Terremark::Vcloud::Mock.new(options)
|
28
|
-
|
28
|
+
else
|
29
29
|
Fog::Terremark::Vcloud::Real.new(options)
|
30
|
-
|
30
|
+
end
|
31
31
|
end
|
32
32
|
|
33
33
|
class Real
|
@@ -91,7 +91,7 @@ module Fog
|
|
91
91
|
nil
|
92
92
|
end
|
93
93
|
end
|
94
|
-
|
94
|
+
end
|
95
95
|
|
96
96
|
class Mock
|
97
97
|
include Fog::Terremark::Shared::Mock
|
@@ -106,7 +106,7 @@ module Fog
|
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
|
-
|
109
|
+
end
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
data/lib/fog/vcloud.rb
CHANGED
@@ -31,6 +31,7 @@ module Fog
|
|
31
31
|
class UnsupportedVersion < Exception ; end
|
32
32
|
|
33
33
|
module Shared
|
34
|
+
attr_reader :versions_uri
|
34
35
|
|
35
36
|
def default_organization_uri
|
36
37
|
@default_organization_uri ||= begin
|
@@ -81,9 +82,6 @@ module Fog
|
|
81
82
|
include Shared
|
82
83
|
extend Fog::Vcloud::Generators
|
83
84
|
|
84
|
-
attr_accessor :login_uri
|
85
|
-
attr_reader :versions_uri
|
86
|
-
|
87
85
|
def supporting_versions
|
88
86
|
["0.8"]
|
89
87
|
end
|
@@ -295,6 +293,14 @@ module Fog
|
|
295
293
|
:storage => { :used => "105", :allocated => "200" },
|
296
294
|
:cpu => { :allocated => "10000" },
|
297
295
|
:memory => { :allocated => "20480" },
|
296
|
+
:catalog => {
|
297
|
+
:name => "The catalog",
|
298
|
+
:items => [
|
299
|
+
{ :id => "0", :name => "Item 0" },
|
300
|
+
{ :id => "1", :name => "Item 1" },
|
301
|
+
{ :id => "2", :name => "Item 2" },
|
302
|
+
]
|
303
|
+
},
|
298
304
|
:networks => [
|
299
305
|
{ :id => "31",
|
300
306
|
:href => "#{base_url}/network/31",
|
@@ -367,9 +373,11 @@ module Fog
|
|
367
373
|
|
368
374
|
def vdc_from_uri(uri)
|
369
375
|
match = Regexp.new(%r:.*/vdc/(\d+):).match(uri.to_s)
|
370
|
-
|
371
|
-
|
372
|
-
|
376
|
+
match && vdc_from_id(match[1])
|
377
|
+
end
|
378
|
+
|
379
|
+
def vdc_from_id(id)
|
380
|
+
mock_data[:organizations].map { |org| org[:vdcs] }.flatten.detect { |vdc| vdc[:id] == id }
|
373
381
|
end
|
374
382
|
|
375
383
|
def ip_from_uri(uri)
|
@@ -415,4 +423,4 @@ module Fog
|
|
415
423
|
end
|
416
424
|
|
417
425
|
require 'fog/vcloud/terremark/ecloud'
|
418
|
-
require 'fog/vcloud/terremark/vcloud'
|
426
|
+
require 'fog/vcloud/terremark/vcloud'
|
@@ -102,7 +102,7 @@ module Fog
|
|
102
102
|
{ :id => "72", :href => extension_url + "/internetService/72", :port => "7000", :protocol => 'HTTP', :enabled => "true",
|
103
103
|
:timeout => "2", :name => 'An SSH Map', :description => 'SSH 1', :redirect_url => '',
|
104
104
|
:nodes => [ {:id => "83", :href => extension_url + "/nodeService/83", :ip_address => "1.2.3.5",
|
105
|
-
:name => "SSH", :port => "22", :enabled => "true", :description => "web ssh" }
|
105
|
+
:name => "SSH", :port => "22", :enabled => "true", :description => "web ssh" }
|
106
106
|
] }
|
107
107
|
]
|
108
108
|
},
|
@@ -157,6 +157,18 @@ module Fog
|
|
157
157
|
"#{base_url}/extensions/internetService/#{internet_service[:id]}"
|
158
158
|
end
|
159
159
|
|
160
|
+
def self.vapp_href(options)
|
161
|
+
"#{base_url}/vapp/#{options[:id]}"
|
162
|
+
end
|
163
|
+
|
164
|
+
def self.vapp_template_href(options)
|
165
|
+
"#{base_url}/vappTemplate/#{options[:id]}"
|
166
|
+
end
|
167
|
+
|
168
|
+
def self.catalog_item_customization_href(options)
|
169
|
+
"#{base_url}/extensions/template/#{options[:id]}/options/customization"
|
170
|
+
end
|
171
|
+
|
160
172
|
def ecloud_xmlns
|
161
173
|
{ :xmlns => "urn:tmrk:eCloudExtensions-2.3", :"xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance" }
|
162
174
|
end
|
@@ -167,8 +179,8 @@ module Fog
|
|
167
179
|
|
168
180
|
def mock_ip_and_service_from_service_url(uri)
|
169
181
|
if ip = mock_data[:organizations].map { |org| org[:vdcs] }.flatten.map { |vdc| vdc[:public_ips] }.flatten.compact.detect { |pip| pip[:services].detect { |service| service[:href] == uri } }
|
170
|
-
if
|
171
|
-
[ip,
|
182
|
+
if desired_service = ip[:services].detect { |service| service[:href] == uri }
|
183
|
+
[ip, desired_service]
|
172
184
|
else
|
173
185
|
[ip, nil]
|
174
186
|
end
|
@@ -2,7 +2,60 @@ module Fog
|
|
2
2
|
class Vcloud
|
3
3
|
module Terremark
|
4
4
|
class Ecloud
|
5
|
+
module Shared
|
6
|
+
def validate_internet_service_monitor(monitor)
|
7
|
+
#FIXME: Refactor this type of function into something generic
|
8
|
+
required_opts = [:type, :url_send_string, :http_headers, :receive_string, :is_enabled]
|
9
|
+
|
10
|
+
unless required_opts.all? { |opt| monitor.keys.include?(opt) && monitor[opt] }
|
11
|
+
raise ArgumentError.new("Required Monitor data missing: #{(required_opts - monitor.keys).map(&:inspect).join(", ")}")
|
12
|
+
end
|
13
|
+
|
14
|
+
unless ['HTTP','ECV'].include?(monitor[:type])
|
15
|
+
raise ArgumentError.new("Supported monitor types are: ECV & HTTP")
|
16
|
+
end
|
17
|
+
|
18
|
+
unless monitor[:http_headers].is_a?(Array) || monitor[:http_headers].is_a?(String)
|
19
|
+
raise ArgumentError.new("Monitor :http_headers must be a String or Array")
|
20
|
+
end
|
21
|
+
|
22
|
+
unless [true, false, "true", "false"].include?(monitor[:is_enabled])
|
23
|
+
raise ArgumentError.new("Monitor :is_enabled must be true or false")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def validate_internet_service_data(service_data, configure=false)
|
28
|
+
required_opts = [:name, :protocol, :port, :description, :enabled]
|
29
|
+
if configure
|
30
|
+
required_opts + [ :id, :href, :timeout ]
|
31
|
+
end
|
32
|
+
unless required_opts.all? { |opt| service_data.keys.include?(opt) }
|
33
|
+
raise ArgumentError.new("Required Internet Service data missing: #{(required_opts - service_data.keys).map(&:inspect).join(", ")}")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
5
38
|
class Real
|
39
|
+
include Shared
|
40
|
+
|
41
|
+
def add_internet_service(internet_services_uri, service_data)
|
42
|
+
validate_internet_service_data(service_data)
|
43
|
+
if monitor = service_data[:monitor]
|
44
|
+
validate_internet_service_monitor(monitor)
|
45
|
+
ensure_monitor_defaults!(monitor)
|
46
|
+
end
|
47
|
+
|
48
|
+
request(
|
49
|
+
:body => generate_internet_service_request(service_data),
|
50
|
+
:expects => 200,
|
51
|
+
:headers => {'Content-Type' => 'application/vnd.tmrk.ecloud.internetService+xml'},
|
52
|
+
:method => 'POST',
|
53
|
+
:uri => internet_services_uri,
|
54
|
+
:parse => true
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
6
59
|
|
7
60
|
def generate_internet_service_request(service_data)
|
8
61
|
builder = Builder::XmlMarkup.new
|
@@ -35,37 +88,6 @@ module Fog
|
|
35
88
|
}
|
36
89
|
end
|
37
90
|
|
38
|
-
def validate_internet_service_data(service_data, configure=false)
|
39
|
-
required_opts = [:name, :protocol, :port, :description, :enabled]
|
40
|
-
if configure
|
41
|
-
required_opts + [ :id, :href, :timeout ]
|
42
|
-
end
|
43
|
-
unless required_opts.all? { |opt| service_data.keys.include?(opt) }
|
44
|
-
raise ArgumentError.new("Required Internet Service data missing: #{(required_opts - service_data.keys).map(&:inspect).join(", ")}")
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def validate_internet_service_monitor(monitor)
|
49
|
-
#FIXME: Refactor this type of function into something generic
|
50
|
-
required_opts = [:type, :url_send_string, :http_headers, :receive_string, :is_enabled]
|
51
|
-
|
52
|
-
unless required_opts.all? { |opt| monitor.keys.include?(opt) && monitor[opt] }
|
53
|
-
raise ArgumentError.new("Required Monitor data missing: #{(required_opts - monitor.keys).map(&:inspect).join(", ")}")
|
54
|
-
end
|
55
|
-
|
56
|
-
unless ['HTTP','ECV'].include?(monitor[:type])
|
57
|
-
raise ArgumentError.new("Supported monitor types are: ECV & HTTP")
|
58
|
-
end
|
59
|
-
|
60
|
-
unless monitor[:http_headers].is_a?(Array) || monitor[:http_headers].is_a?(String)
|
61
|
-
raise ArgumentError.new("Monitor :http_headers must be a String or Array")
|
62
|
-
end
|
63
|
-
|
64
|
-
unless [true, false, "true", "false"].include?(monitor[:is_enabled])
|
65
|
-
raise ArgumentError.new("Monitor :is_enabled must be true or false")
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
91
|
def ensure_monitor_defaults!(monitor)
|
70
92
|
if monitor[:http_headers].is_a?(String)
|
71
93
|
monitor[:http_headers] = [ monitor[:http_headers] ]
|
@@ -87,27 +109,11 @@ module Fog
|
|
87
109
|
monitor[:interval] = 5
|
88
110
|
end
|
89
111
|
end
|
90
|
-
|
91
|
-
def add_internet_service(internet_services_uri, service_data)
|
92
|
-
validate_internet_service_data(service_data)
|
93
|
-
if monitor = service_data[:monitor]
|
94
|
-
validate_internet_service_monitor(monitor)
|
95
|
-
ensure_monitor_defaults!(monitor)
|
96
|
-
end
|
97
|
-
|
98
|
-
request(
|
99
|
-
:body => generate_internet_service_request(service_data),
|
100
|
-
:expects => 200,
|
101
|
-
:headers => {'Content-Type' => 'application/vnd.tmrk.ecloud.internetService+xml'},
|
102
|
-
:method => 'POST',
|
103
|
-
:uri => internet_services_uri,
|
104
|
-
:parse => true
|
105
|
-
)
|
106
|
-
end
|
107
|
-
|
108
112
|
end
|
109
113
|
|
110
114
|
class Mock
|
115
|
+
include Shared
|
116
|
+
|
111
117
|
#
|
112
118
|
# Based on
|
113
119
|
# http://support.theenterprisecloud.com/kb/default.asp?id=561&Lang=1&SID=
|