fog 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -2
- data/Gemfile.lock +5 -5
- data/README.rdoc +29 -29
- data/fog.gemspec +24 -2
- data/lib/fog.rb +4 -15
- data/lib/fog/aws.rb +2 -2
- data/lib/fog/aws/ec2.rb +64 -101
- data/lib/fog/aws/elb.rb +19 -27
- data/lib/fog/aws/models/ec2/addresses.rb +1 -9
- data/lib/fog/aws/models/ec2/flavors.rb +1 -7
- data/lib/fog/aws/models/ec2/images.rb +1 -7
- data/lib/fog/aws/models/ec2/key_pairs.rb +1 -7
- data/lib/fog/aws/models/ec2/security_groups.rb +1 -7
- data/lib/fog/aws/models/ec2/servers.rb +1 -7
- data/lib/fog/aws/models/ec2/snapshots.rb +1 -9
- data/lib/fog/aws/models/ec2/volumes.rb +1 -9
- data/lib/fog/aws/models/s3/directories.rb +1 -7
- data/lib/fog/aws/models/s3/file.rb +5 -0
- data/lib/fog/aws/requests/ec2/allocate_address.rb +2 -0
- data/lib/fog/aws/requests/ec2/attach_volume.rb +2 -0
- data/lib/fog/aws/requests/ec2/create_key_pair.rb +2 -0
- data/lib/fog/aws/requests/ec2/create_snapshot.rb +2 -0
- data/lib/fog/aws/requests/ec2/create_volume.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_addresses.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_availability_zones.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_images.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_instances.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_key_pairs.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_regions.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_reserved_instances.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_security_groups.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_snapshots.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_volumes.rb +2 -0
- data/lib/fog/aws/requests/ec2/detach_volume.rb +2 -0
- data/lib/fog/aws/requests/ec2/get_console_output.rb +2 -0
- data/lib/fog/aws/requests/ec2/run_instances.rb +2 -0
- data/lib/fog/aws/requests/ec2/terminate_instances.rb +2 -0
- data/lib/fog/aws/requests/elb/create_load_balancer.rb +2 -0
- data/lib/fog/aws/requests/elb/delete_load_balancer.rb +2 -0
- data/lib/fog/aws/requests/elb/deregister_instances_from_load_balancer.rb +2 -0
- data/lib/fog/aws/requests/elb/describe_instance_health.rb +2 -0
- data/lib/fog/aws/requests/elb/describe_load_balancers.rb +2 -0
- data/lib/fog/aws/requests/elb/disable_availability_zones_for_load_balancer.rb +2 -0
- data/lib/fog/aws/requests/elb/enable_availability_zones_for_load_balancer.rb +2 -0
- data/lib/fog/aws/requests/elb/register_instances_with_load_balancer.rb +2 -0
- data/lib/fog/aws/requests/s3/copy_object.rb +2 -0
- data/lib/fog/aws/requests/s3/get_bucket.rb +2 -0
- data/lib/fog/aws/requests/s3/get_bucket_acl.rb +2 -0
- data/lib/fog/aws/requests/s3/get_bucket_location.rb +2 -0
- data/lib/fog/aws/requests/s3/get_bucket_logging.rb +2 -0
- data/lib/fog/aws/requests/s3/get_bucket_object_versions.rb +2 -0
- data/lib/fog/aws/requests/s3/get_bucket_versioning.rb +2 -0
- data/lib/fog/aws/requests/s3/get_object_acl.rb +2 -0
- data/lib/fog/aws/requests/s3/get_request_payment.rb +2 -0
- data/lib/fog/aws/requests/s3/get_service.rb +2 -0
- data/lib/fog/aws/requests/s3/put_object.rb +2 -2
- data/lib/fog/aws/requests/simpledb/domain_metadata.rb +2 -0
- data/lib/fog/aws/requests/simpledb/get_attributes.rb +2 -0
- data/lib/fog/aws/requests/simpledb/list_domains.rb +2 -0
- data/lib/fog/aws/requests/simpledb/select.rb +2 -0
- data/lib/fog/aws/s3.rb +68 -85
- data/lib/fog/aws/simpledb.rb +15 -29
- data/lib/fog/bluebox.rb +23 -40
- data/lib/fog/bluebox/models/flavors.rb +1 -7
- data/lib/fog/bluebox/models/images.rb +1 -9
- data/lib/fog/bluebox/models/servers.rb +1 -7
- data/lib/fog/credentials.rb +2 -0
- data/lib/fog/errors.rb +20 -0
- data/lib/fog/hmac.rb +48 -0
- data/lib/fog/local.rb +9 -22
- data/lib/fog/local/models/directories.rb +1 -7
- data/lib/fog/rackspace.rb +2 -6
- data/lib/fog/rackspace/files.rb +46 -48
- data/lib/fog/rackspace/models/files/directories.rb +1 -7
- data/lib/fog/rackspace/models/servers/flavors.rb +1 -7
- data/lib/fog/rackspace/models/servers/images.rb +1 -9
- data/lib/fog/rackspace/models/servers/server.rb +37 -1
- data/lib/fog/rackspace/models/servers/servers.rb +8 -7
- data/lib/fog/rackspace/requests/files/put_object.rb +1 -1
- data/lib/fog/rackspace/servers.rb +33 -45
- data/lib/fog/service.rb +82 -0
- data/lib/fog/slicehost.rb +28 -42
- data/lib/fog/slicehost/models/flavors.rb +1 -7
- data/lib/fog/slicehost/models/images.rb +1 -9
- data/lib/fog/slicehost/models/servers.rb +1 -7
- data/lib/fog/ssh.rb +1 -1
- data/lib/fog/vcloud.rb +20 -3
- data/lib/fog/vcloud/collection.rb +25 -5
- data/lib/fog/vcloud/model.rb +4 -0
- data/lib/fog/vcloud/parsers/get_organization.rb +2 -2
- data/lib/fog/vcloud/parsers/get_vdc.rb +2 -2
- data/lib/fog/vcloud/parsers/get_versions.rb +1 -1
- data/lib/fog/vcloud/parsers/login.rb +2 -2
- data/lib/fog/vcloud/parsers/network.rb +53 -0
- data/lib/fog/vcloud/requests/get_network.rb +54 -0
- data/lib/fog/vcloud/requests/get_organization.rb +1 -2
- data/lib/fog/vcloud/terremark/ecloud.rb +17 -4
- data/lib/fog/vcloud/terremark/ecloud/models/internet_service.rb +35 -0
- data/lib/fog/vcloud/terremark/ecloud/models/internet_services.rb +9 -9
- data/lib/fog/vcloud/terremark/ecloud/models/ip.rb +18 -0
- data/lib/fog/vcloud/terremark/ecloud/models/ips.rb +36 -0
- data/lib/fog/vcloud/terremark/ecloud/models/network.rb +32 -0
- data/lib/fog/vcloud/terremark/ecloud/models/networks.rb +38 -0
- data/lib/fog/vcloud/terremark/ecloud/models/public_ip.rb +3 -1
- data/lib/fog/vcloud/terremark/ecloud/models/public_ips.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/vdc.rb +9 -0
- data/lib/fog/vcloud/terremark/ecloud/models/vdcs.rb +2 -0
- data/lib/fog/vcloud/terremark/ecloud/parsers/network.rb +28 -0
- data/lib/fog/vcloud/terremark/ecloud/parsers/network_ips.rb +31 -0
- data/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +10 -7
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +99 -0
- data/lib/fog/vcloud/terremark/ecloud/requests/get_network.rb +54 -0
- data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ips.rb +51 -0
- data/spec/aws/models/s3/file_spec.rb +15 -0
- data/spec/vcloud/requests/get_network_spec.rb +55 -0
- data/spec/vcloud/spec_helper.rb +1 -0
- data/spec/vcloud/terremark/ecloud/models/internet_service_spec.rb +15 -0
- data/spec/vcloud/terremark/ecloud/models/ip_spec.rb +35 -0
- data/spec/vcloud/terremark/ecloud/models/ips_spec.rb +28 -0
- data/spec/vcloud/terremark/ecloud/models/network_spec.rb +65 -0
- data/spec/vcloud/terremark/ecloud/models/networks_spec.rb +26 -0
- data/spec/vcloud/terremark/ecloud/models/public_ip_spec.rb +0 -2
- data/spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb +44 -0
- data/spec/vcloud/terremark/ecloud/requests/get_network_ips_spec.rb +54 -0
- data/spec/vcloud/terremark/ecloud/requests/get_network_spec.rb +63 -0
- data/tests/aws/requests/ec2/volume_tests.rb +2 -2
- data/tests/helper.rb +2 -0
- metadata +25 -3
data/lib/fog/vcloud.rb
CHANGED
@@ -178,14 +178,22 @@ module Fog
|
|
178
178
|
:subnet => "1.2.3.0/24",
|
179
179
|
:gateway => "1.2.3.1",
|
180
180
|
:netmask => "255.255.255.0",
|
181
|
-
:
|
181
|
+
:dns => "8.8.8.8",
|
182
|
+
:features => [
|
183
|
+
{ :type => :fencemode, :value => "isolated" }
|
184
|
+
],
|
185
|
+
:ips => { "1.2.3.3" => "Broom 1", "1.2.3.4" => "Broom 2", "1.2.3.10" => "Email" }
|
182
186
|
},
|
183
187
|
{ :href => "#{base_url}/network/32",
|
184
188
|
:name => "4.5.6.0/24",
|
185
189
|
:subnet => "4.5.6.0/24",
|
186
190
|
:gateway => "4.5.6.1",
|
187
191
|
:netmask => "255.255.255.0",
|
188
|
-
:
|
192
|
+
:dns => "8.8.8.8",
|
193
|
+
:features => [
|
194
|
+
{ :type => :fencemode, :value => "isolated" }
|
195
|
+
],
|
196
|
+
:ips => { }
|
189
197
|
},
|
190
198
|
],
|
191
199
|
:vms => [
|
@@ -231,8 +239,12 @@ module Fog
|
|
231
239
|
:name => "7.8.9.0/24",
|
232
240
|
:subnet => "7.8.9.0/24",
|
233
241
|
:gateway => "7.8.9.1",
|
242
|
+
:dns => "8.8.8.8",
|
234
243
|
:netmask => "255.255.255.0",
|
235
|
-
:
|
244
|
+
:features => [
|
245
|
+
{ :type => :fencemode, :value => "isolated" }
|
246
|
+
],
|
247
|
+
:ips => { "7.8.9.10" => "Master Blaster" }
|
236
248
|
}
|
237
249
|
],
|
238
250
|
:vms => [
|
@@ -313,6 +325,7 @@ module Fog
|
|
313
325
|
require 'fog/vcloud/models/vdcs'
|
314
326
|
require 'fog/vcloud/terremark/vcloud'
|
315
327
|
require 'fog/vcloud/terremark/ecloud'
|
328
|
+
require 'fog/vcloud/requests/get_network'
|
316
329
|
require 'fog/vcloud/requests/get_organization'
|
317
330
|
require 'fog/vcloud/requests/get_vdc'
|
318
331
|
require 'fog/vcloud/requests/get_versions'
|
@@ -321,6 +334,7 @@ module Fog
|
|
321
334
|
require 'fog/vcloud/parsers/get_vdc'
|
322
335
|
require 'fog/vcloud/parsers/get_versions'
|
323
336
|
require 'fog/vcloud/parsers/login'
|
337
|
+
require 'fog/vcloud/parsers/network'
|
324
338
|
|
325
339
|
require 'builder'
|
326
340
|
|
@@ -331,6 +345,9 @@ module Fog
|
|
331
345
|
Struct.new("VcloudVersion", :version, :login_url, :supported)
|
332
346
|
Struct.new("VcloudOrgList", :organizations, :xmlns)
|
333
347
|
Struct.new("VcloudXCapacity", :units, :allocated, :used, :limit)
|
348
|
+
Struct.new("VcloudNetwork", :features, :configuration, :href, :type, :name, :xmlns, :description)
|
349
|
+
Struct.new("VcloudNetworkConfiguration", :gateway, :netmask, :dns)
|
350
|
+
Struct.new("VcloudNetworkFenceMode", :mode)
|
334
351
|
@required = true
|
335
352
|
end
|
336
353
|
|
@@ -18,7 +18,8 @@ module Fog
|
|
18
18
|
@all_request = all_request
|
19
19
|
class_eval <<-EOS, __FILE__, __LINE__
|
20
20
|
def all
|
21
|
-
|
21
|
+
raw_all = self.class.all_request.call(self)
|
22
|
+
data = (raw_all.is_a?(Array) ? raw_all : raw_all.body.links).select do |link|
|
22
23
|
link.type == self.class.vcloud_type
|
23
24
|
end.map { |link| {:href => link.href, :name => link.name } }
|
24
25
|
load(data)
|
@@ -53,14 +54,33 @@ module Fog
|
|
53
54
|
end
|
54
55
|
end
|
55
56
|
|
56
|
-
|
57
|
-
|
57
|
+
attr_accessor :href
|
58
|
+
|
59
|
+
def create(attributes = {})
|
60
|
+
attributes.merge!(:new => true)
|
61
|
+
obj = super(attributes)
|
62
|
+
self << obj
|
63
|
+
obj
|
64
|
+
end
|
65
|
+
|
66
|
+
def each
|
67
|
+
super do |item|
|
68
|
+
item.reload
|
69
|
+
yield(item)
|
70
|
+
end
|
58
71
|
end
|
59
72
|
|
60
|
-
def
|
61
|
-
|
73
|
+
def [](index)
|
74
|
+
if obj = super
|
75
|
+
obj.reload unless obj.loaded?
|
76
|
+
end
|
77
|
+
obj
|
62
78
|
end
|
63
79
|
|
80
|
+
#def reload
|
81
|
+
# self.all
|
82
|
+
#end
|
83
|
+
|
64
84
|
end
|
65
85
|
end
|
66
86
|
end
|
data/lib/fog/vcloud/model.rb
CHANGED
@@ -12,8 +12,8 @@ module Fog
|
|
12
12
|
@response = Struct::VcloudVdc.new([],[],[],Struct::VcloudXCapacity.new,Struct::VcloudXCapacity.new,Struct::VcloudXCapacity.new)
|
13
13
|
end
|
14
14
|
|
15
|
-
def start_element(name, attributes)
|
16
|
-
|
15
|
+
def start_element(name, attributes=[])
|
16
|
+
super
|
17
17
|
case name
|
18
18
|
when 'Cpu'
|
19
19
|
@target = :cpu_capacity
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module Vcloud
|
4
|
+
|
5
|
+
class Network < Fog::Parsers::Vcloud::Base
|
6
|
+
|
7
|
+
def reset
|
8
|
+
@response = Struct::VcloudNetwork.new([])
|
9
|
+
end
|
10
|
+
|
11
|
+
def start_element(name,attributes=[])
|
12
|
+
super
|
13
|
+
case name
|
14
|
+
when "Network"
|
15
|
+
handle_root(attributes)
|
16
|
+
when "Features"
|
17
|
+
@in = :features
|
18
|
+
when "Configuration"
|
19
|
+
@in = :configuration
|
20
|
+
@response.configuration = Struct::VcloudNetworkConfiguration.new
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def end_element(name)
|
25
|
+
case @in
|
26
|
+
when :features
|
27
|
+
case name
|
28
|
+
when "FenceMode"
|
29
|
+
@response.features << Struct::VcloudNetworkFenceMode.new(@value)
|
30
|
+
when "Features"
|
31
|
+
@in = nil
|
32
|
+
end
|
33
|
+
when :configuration
|
34
|
+
case name
|
35
|
+
when "Gateway","Netmask","Dns"
|
36
|
+
@response.configuration[name.downcase] = @value
|
37
|
+
when "Configuration"
|
38
|
+
@in = nil
|
39
|
+
end
|
40
|
+
else
|
41
|
+
case name
|
42
|
+
when "Description"
|
43
|
+
@response.description = @value
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Fog
|
2
|
+
module Vcloud
|
3
|
+
class Real
|
4
|
+
|
5
|
+
def get_network(network_uri)
|
6
|
+
request(
|
7
|
+
:expects => 200,
|
8
|
+
:method => 'GET',
|
9
|
+
:parser => Fog::Parsers::Vcloud::Network.new,
|
10
|
+
:uri => uri
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
class Mock
|
17
|
+
|
18
|
+
def get_network(network_uri)
|
19
|
+
#
|
20
|
+
# Based off of:
|
21
|
+
# vCloud API Guide v0.8 - Page 50
|
22
|
+
#
|
23
|
+
# Did not implement AssociatedNetwork, seems redundant, haven't seen it in use yet
|
24
|
+
# Did not implement the following features: Dhcp, Nat & Firewall
|
25
|
+
#
|
26
|
+
type = "application/vnd.vmware.vcloud.network+xml"
|
27
|
+
response = Excon::Response.new
|
28
|
+
if network = mock_data[:organizations].map { |org| org[:vdcs].map { |vdc| vdc[:networks] } }.flatten.detect { |network| network[:href] == network_uri.to_s }
|
29
|
+
xml = Builder::XmlMarkup.new
|
30
|
+
mock_it Fog::Parsers::Vcloud::Network.new, 200,
|
31
|
+
xml.Network(xmlns.merge(:href => network[:href], :name => network[:name], :type => type)) {
|
32
|
+
xml.Description(network[:name])
|
33
|
+
xml.Configuration {
|
34
|
+
xml.Gateway(network[:gateway])
|
35
|
+
xml.Netmask(network[:netmask])
|
36
|
+
xml.Dns(network[:dns])
|
37
|
+
}
|
38
|
+
if network[:features]
|
39
|
+
xml.Features {
|
40
|
+
if feature = network[:features].detect { |feature| feature[:type] == :fencemode }
|
41
|
+
xml.FenceMode(feature[:value])
|
42
|
+
end
|
43
|
+
}
|
44
|
+
end
|
45
|
+
},
|
46
|
+
{ 'Content-Type' => type }
|
47
|
+
else
|
48
|
+
mock_error 200, "401 Unauthorized"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -3,13 +3,12 @@ module Fog
|
|
3
3
|
|
4
4
|
class Real
|
5
5
|
def get_organization(organization_uri)
|
6
|
-
|
6
|
+
request(
|
7
7
|
:expects => 200,
|
8
8
|
:method => 'GET',
|
9
9
|
:parser => Fog::Parsers::Vcloud::GetOrganization.new,
|
10
10
|
:uri => organization_uri
|
11
11
|
)
|
12
|
-
response
|
13
12
|
end
|
14
13
|
|
15
14
|
end
|
@@ -31,6 +31,10 @@ module Fog
|
|
31
31
|
require 'fog/vcloud/terremark/all'
|
32
32
|
require 'fog/vcloud/terremark/ecloud/models/internet_service'
|
33
33
|
require 'fog/vcloud/terremark/ecloud/models/internet_services'
|
34
|
+
require 'fog/vcloud/terremark/ecloud/models/ip'
|
35
|
+
require 'fog/vcloud/terremark/ecloud/models/ips'
|
36
|
+
require 'fog/vcloud/terremark/ecloud/models/network'
|
37
|
+
require 'fog/vcloud/terremark/ecloud/models/networks'
|
34
38
|
require 'fog/vcloud/terremark/ecloud/models/public_ip'
|
35
39
|
require 'fog/vcloud/terremark/ecloud/models/public_ips'
|
36
40
|
require 'fog/vcloud/terremark/ecloud/models/vdc'
|
@@ -40,19 +44,28 @@ module Fog
|
|
40
44
|
require 'fog/vcloud/terremark/ecloud/parsers/get_public_ips'
|
41
45
|
require 'fog/vcloud/terremark/ecloud/parsers/get_vdc'
|
42
46
|
require 'fog/vcloud/terremark/ecloud/parsers/internet_service'
|
47
|
+
require 'fog/vcloud/terremark/ecloud/parsers/network'
|
48
|
+
require 'fog/vcloud/terremark/ecloud/parsers/network_ips'
|
43
49
|
require 'fog/vcloud/terremark/ecloud/requests/add_internet_service'
|
50
|
+
require 'fog/vcloud/terremark/ecloud/requests/configure_internet_service'
|
44
51
|
require 'fog/vcloud/terremark/ecloud/requests/delete_internet_service'
|
45
52
|
require 'fog/vcloud/terremark/ecloud/requests/get_internet_services'
|
53
|
+
require 'fog/vcloud/terremark/ecloud/requests/get_network'
|
54
|
+
require 'fog/vcloud/terremark/ecloud/requests/get_network_ips'
|
46
55
|
require 'fog/vcloud/terremark/ecloud/requests/get_public_ip'
|
47
56
|
require 'fog/vcloud/terremark/ecloud/requests/get_public_ips'
|
48
57
|
require 'fog/vcloud/terremark/ecloud/requests/login'
|
49
58
|
require 'fog/vcloud/terremark/ecloud/requests/get_vdc'
|
50
|
-
Struct.new("TmrkEcloudVdc", :links, :resource_entities, :networks,
|
51
|
-
|
52
|
-
|
59
|
+
Struct.new("TmrkEcloudVdc", :links, :resource_entities, :networks, :cpu_capacity, :storage_capacity,
|
60
|
+
:memory_capacity, :deployed_vm_quota, :instantiated_vm_quota, :href, :type,
|
61
|
+
:name, :xmlns, :description)
|
53
62
|
Struct.new("TmrkEcloudList", :links)
|
54
63
|
Struct.new("TmrkEcloudPublicIp", :type, :href, :name, :id)
|
55
|
-
Struct.new("TmrkEcloudInternetService", :type, :href, :id, :name, :public_ip, :port, :protocol,
|
64
|
+
Struct.new("TmrkEcloudInternetService", :type, :href, :id, :name, :public_ip, :port, :protocol,
|
65
|
+
:enabled, :timeout, :description, :url_send_string, :http_header)
|
66
|
+
Struct.new("TmrkEcloudNetwork", :features, :configuration, :ips_link, :name, :type, :href, :xmlns)
|
67
|
+
Struct.new("TmrkEcloudNetworkIps", :addresses)
|
68
|
+
Struct.new("TmrkEcloudNetworkIp", :name, :status, :server)
|
56
69
|
@required = true
|
57
70
|
end
|
58
71
|
if Fog.mocking?
|
@@ -20,6 +20,41 @@ module Fog
|
|
20
20
|
attribute :url_send_string
|
21
21
|
attribute :http_header
|
22
22
|
|
23
|
+
attr_accessor :new
|
24
|
+
|
25
|
+
def delete
|
26
|
+
requires :href
|
27
|
+
|
28
|
+
connection.delete_internet_service( self.href )
|
29
|
+
collection.reload
|
30
|
+
end
|
31
|
+
|
32
|
+
def save
|
33
|
+
if new_record?
|
34
|
+
result = connection.add_internet_service( collection.href, _compose_service_data )
|
35
|
+
self.href = result.body.href
|
36
|
+
self.reload
|
37
|
+
else
|
38
|
+
connection.configure_internet_service( self.href, _compose_service_data, _compose_ip_data )
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def _compose_service_data
|
45
|
+
service_data = {}
|
46
|
+
self.class.attributes.select{ |attribute| !attribute.nil? }.each { |attribute| service_data[attribute] = send(attribute).to_s }
|
47
|
+
service_data
|
48
|
+
end
|
49
|
+
|
50
|
+
def _compose_ip_data
|
51
|
+
if public_ip.nil?
|
52
|
+
{}
|
53
|
+
else
|
54
|
+
{ :id => self.public_ip.id, :href => self.public_ip.href.to_s, :name => self.public_ip.name }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
23
58
|
end
|
24
59
|
end
|
25
60
|
end
|
@@ -17,12 +17,10 @@ module Fog
|
|
17
17
|
|
18
18
|
class InternetServices < Fog::Vcloud::Collection
|
19
19
|
|
20
|
-
attr_accessor :href
|
21
|
-
|
22
20
|
model Fog::Vcloud::Terremark::Ecloud::InternetService
|
23
21
|
|
24
22
|
vcloud_type "application/vnd.tmrk.ecloud.internetService+xml"
|
25
|
-
all_request lambda { |internet_services| internet_services.raw_results }
|
23
|
+
all_request lambda { |internet_services| internet_services.send(:raw_results) }
|
26
24
|
|
27
25
|
def get(uri)
|
28
26
|
if internet_service = get_raw(uri)
|
@@ -32,18 +30,20 @@ module Fog
|
|
32
30
|
end
|
33
31
|
|
34
32
|
def get_raw(uri)
|
35
|
-
raw_results.body.links.detect { |link| link.href == uri }
|
33
|
+
raw_results.body.links.detect { |link| link.href.to_s == uri.to_s }
|
34
|
+
end
|
35
|
+
|
36
|
+
def reload
|
37
|
+
super
|
38
|
+
@raw_results = nil
|
36
39
|
end
|
37
40
|
|
41
|
+
private
|
42
|
+
|
38
43
|
def raw_results
|
39
44
|
@raw_results ||= connection.get_internet_services(self.href)
|
40
45
|
end
|
41
46
|
|
42
|
-
#def reload
|
43
|
-
# super
|
44
|
-
# @raw_results = nil
|
45
|
-
#end
|
46
|
-
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Fog
|
2
|
+
module Vcloud
|
3
|
+
module Terremark
|
4
|
+
module Ecloud
|
5
|
+
|
6
|
+
class Ips < Fog::Vcloud::Collection
|
7
|
+
|
8
|
+
model Fog::Vcloud::Terremark::Ecloud::Ip
|
9
|
+
|
10
|
+
undef_method :create
|
11
|
+
|
12
|
+
def all
|
13
|
+
load(connection.get_network_ips(href).body.addresses.
|
14
|
+
map { |address| { :name => address.name, :status => address.status, :server => address.server } })
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_raw(name)
|
18
|
+
raw_results.detect { |address| address.name == name }
|
19
|
+
end
|
20
|
+
|
21
|
+
def reload
|
22
|
+
super
|
23
|
+
@raw_results = nil
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def raw_results
|
29
|
+
@raw_results ||= connection.get_network_ips(href).body.addresses
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|