fog 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. data/Gemfile +8 -8
  2. data/Gemfile.lock +3 -3
  3. data/bin/fog +2 -10
  4. data/fog.gemspec +45 -20
  5. data/lib/fog.rb +2 -1
  6. data/lib/fog/attributes.rb +48 -8
  7. data/lib/fog/aws/ec2.rb +5 -2
  8. data/lib/fog/aws/elb.rb +5 -2
  9. data/lib/fog/aws/models/ec2/server.rb +1 -1
  10. data/lib/fog/aws/requests/simpledb/put_attributes.rb +43 -12
  11. data/lib/fog/aws/s3.rb +2 -2
  12. data/lib/fog/aws/simpledb.rb +15 -3
  13. data/lib/fog/bin.rb +11 -2
  14. data/lib/fog/bluebox.rb +5 -1
  15. data/lib/fog/connection.rb +9 -1
  16. data/lib/fog/credentials.rb +3 -0
  17. data/lib/fog/new_servers.rb +89 -0
  18. data/lib/fog/new_servers/bin.rb +30 -0
  19. data/lib/fog/new_servers/requests/add_server.rb +39 -0
  20. data/lib/fog/new_servers/requests/cancel_server.rb +36 -0
  21. data/lib/fog/new_servers/requests/get_server.rb +42 -0
  22. data/lib/fog/new_servers/requests/list_images.rb +33 -0
  23. data/lib/fog/new_servers/requests/list_plans.rb +36 -0
  24. data/lib/fog/new_servers/requests/list_servers.rb +43 -0
  25. data/lib/fog/new_servers/requests/reboot_server.rb +30 -0
  26. data/lib/fog/parser.rb +6 -0
  27. data/lib/fog/rackspace/files.rb +8 -2
  28. data/lib/fog/rackspace/models/servers/server.rb +5 -0
  29. data/lib/fog/rackspace/servers.rb +5 -1
  30. data/lib/fog/service.rb +6 -1
  31. data/lib/fog/slicehost.rb +5 -1
  32. data/lib/fog/terremark/ecloud.rb +1 -0
  33. data/lib/fog/terremark/shared.rb +4 -1
  34. data/lib/fog/terremark/vcloud.rb +1 -0
  35. data/lib/fog/vcloud.rb +150 -141
  36. data/lib/fog/vcloud/bin.rb +2 -2
  37. data/lib/fog/vcloud/collection.rb +3 -84
  38. data/lib/fog/vcloud/extension.rb +44 -0
  39. data/lib/fog/vcloud/generators.rb +33 -0
  40. data/lib/fog/vcloud/model.rb +5 -38
  41. data/lib/fog/vcloud/models/vdc.rb +14 -24
  42. data/lib/fog/vcloud/models/vdcs.rb +13 -8
  43. data/lib/fog/vcloud/requests/get_network.rb +4 -11
  44. data/lib/fog/vcloud/requests/get_organization.rb +4 -11
  45. data/lib/fog/vcloud/requests/get_vdc.rb +4 -12
  46. data/lib/fog/vcloud/requests/get_versions.rb +4 -13
  47. data/lib/fog/vcloud/requests/login.rb +4 -4
  48. data/lib/fog/vcloud/terremark/ecloud.rb +125 -54
  49. data/lib/fog/vcloud/terremark/ecloud/models/catalog.rb +30 -0
  50. data/lib/fog/vcloud/terremark/ecloud/models/catalog_item.rb +31 -0
  51. data/lib/fog/vcloud/terremark/ecloud/models/internet_service.rb +21 -22
  52. data/lib/fog/vcloud/terremark/ecloud/models/internet_services.rb +11 -25
  53. data/lib/fog/vcloud/terremark/ecloud/models/ip.rb +38 -5
  54. data/lib/fog/vcloud/terremark/ecloud/models/ips.rb +11 -15
  55. data/lib/fog/vcloud/terremark/ecloud/models/network.rb +52 -11
  56. data/lib/fog/vcloud/terremark/ecloud/models/networks.rb +14 -13
  57. data/lib/fog/vcloud/terremark/ecloud/models/node.rb +47 -0
  58. data/lib/fog/vcloud/terremark/ecloud/models/nodes.rb +30 -0
  59. data/lib/fog/vcloud/terremark/ecloud/models/public_ip.rb +6 -9
  60. data/lib/fog/vcloud/terremark/ecloud/models/public_ips.rb +19 -3
  61. data/lib/fog/vcloud/terremark/ecloud/models/server.rb +203 -0
  62. data/lib/fog/vcloud/terremark/ecloud/models/servers.rb +43 -0
  63. data/lib/fog/vcloud/terremark/ecloud/models/task.rb +22 -0
  64. data/lib/fog/vcloud/terremark/ecloud/models/tasks.rb +30 -0
  65. data/lib/fog/vcloud/terremark/ecloud/models/vdc.rb +32 -10
  66. data/lib/fog/vcloud/terremark/ecloud/models/vdcs.rb +5 -6
  67. data/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +23 -10
  68. data/lib/fog/vcloud/terremark/ecloud/requests/add_node.rb +54 -0
  69. data/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +14 -12
  70. data/lib/fog/vcloud/terremark/ecloud/requests/configure_network.rb +53 -0
  71. data/lib/fog/vcloud/terremark/ecloud/requests/configure_network_ip.rb +52 -0
  72. data/lib/fog/vcloud/terremark/ecloud/requests/configure_node.rb +42 -0
  73. data/lib/fog/vcloud/terremark/ecloud/requests/configure_vapp.rb +115 -0
  74. data/lib/fog/vcloud/terremark/ecloud/requests/delete_internet_service.rb +4 -23
  75. data/lib/fog/vcloud/terremark/ecloud/requests/delete_node.rb +0 -0
  76. data/lib/fog/vcloud/terremark/ecloud/requests/delete_vapp.rb +19 -0
  77. data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb +18 -0
  78. data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog_item.rb +18 -0
  79. data/lib/fog/vcloud/terremark/ecloud/requests/get_customization_options.rb +18 -0
  80. data/lib/fog/vcloud/terremark/ecloud/requests/get_internet_services.rb +9 -16
  81. data/lib/fog/vcloud/terremark/ecloud/requests/get_network.rb +8 -14
  82. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_extensions.rb +36 -0
  83. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ip.rb +44 -0
  84. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ips.rb +11 -12
  85. data/lib/fog/vcloud/terremark/ecloud/requests/get_node.rb +18 -0
  86. data/lib/fog/vcloud/terremark/ecloud/requests/get_nodes.rb +18 -0
  87. data/lib/fog/vcloud/terremark/ecloud/requests/get_public_ip.rb +5 -19
  88. data/lib/fog/vcloud/terremark/ecloud/requests/get_public_ips.rb +5 -12
  89. data/lib/fog/vcloud/terremark/ecloud/requests/get_task.rb +18 -0
  90. data/lib/fog/vcloud/terremark/ecloud/requests/get_task_list.rb +19 -0
  91. data/lib/fog/vcloud/terremark/ecloud/requests/get_vapp.rb +18 -0
  92. data/lib/fog/vcloud/terremark/ecloud/requests/get_vdc.rb +7 -15
  93. data/lib/fog/vcloud/terremark/ecloud/requests/power_off.rb +18 -0
  94. data/lib/fog/vcloud/terremark/ecloud/requests/power_on.rb +18 -0
  95. data/lib/fog/vcloud/terremark/ecloud/requests/power_reset.rb +18 -0
  96. data/lib/fog/vcloud/terremark/ecloud/requests/power_shutdown.rb +18 -0
  97. data/lib/fog/vcloud/terremark/vcloud.rb +4 -18
  98. data/lib/fog/vcloud/terremark/vcloud/requests/get_vdc.rb +4 -12
  99. data/spec/aws/requests/simpledb/put_attributes_spec.rb +18 -0
  100. data/spec/vcloud/bin_spec.rb +2 -2
  101. data/spec/vcloud/models/vdc_spec.rb +35 -29
  102. data/spec/vcloud/requests/get_network_spec.rb +32 -43
  103. data/spec/vcloud/requests/get_organization_spec.rb +45 -38
  104. data/spec/vcloud/requests/get_vdc_spec.rb +42 -32
  105. data/spec/vcloud/requests/get_versions_spec.rb +17 -17
  106. data/spec/vcloud/requests/login_spec.rb +7 -4
  107. data/spec/vcloud/spec_helper.rb +137 -46
  108. data/spec/vcloud/terremark/ecloud/models/internet_service_spec.rb +53 -58
  109. data/spec/vcloud/terremark/ecloud/models/internet_services_spec.rb +20 -20
  110. data/spec/vcloud/terremark/ecloud/models/ip_spec.rb +22 -21
  111. data/spec/vcloud/terremark/ecloud/models/ips_spec.rb +18 -18
  112. data/spec/vcloud/terremark/ecloud/models/network_spec.rb +55 -51
  113. data/spec/vcloud/terremark/ecloud/models/networks_spec.rb +16 -15
  114. data/spec/vcloud/terremark/ecloud/models/public_ip_spec.rb +26 -27
  115. data/spec/vcloud/terremark/ecloud/models/public_ips_spec.rb +16 -15
  116. data/spec/vcloud/terremark/ecloud/models/vdc_spec.rb +52 -36
  117. data/spec/vcloud/terremark/ecloud/models/vdcs_spec.rb +18 -15
  118. data/spec/vcloud/terremark/ecloud/requests/add_internet_service_spec.rb +46 -43
  119. data/spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb +37 -32
  120. data/spec/vcloud/terremark/ecloud/requests/delete_internet_service_spec.rb +26 -23
  121. data/spec/vcloud/terremark/ecloud/requests/get_internet_services_spec.rb +57 -49
  122. data/spec/vcloud/terremark/ecloud/requests/get_network_ip_spec.rb +41 -0
  123. data/spec/vcloud/terremark/ecloud/requests/get_network_ips_spec.rb +39 -34
  124. data/spec/vcloud/terremark/ecloud/requests/get_network_spec.rb +26 -48
  125. data/spec/vcloud/terremark/ecloud/requests/get_public_ip_spec.rb +25 -26
  126. data/spec/vcloud/terremark/ecloud/requests/get_public_ips_spec.rb +35 -27
  127. data/spec/vcloud/terremark/ecloud/requests/get_vdc_spec.rb +85 -110
  128. data/spec/vcloud/terremark/ecloud/requests/login_spec.rb +7 -4
  129. data/spec/vcloud/vcloud_spec.rb +9 -8
  130. metadata +62 -26
  131. data/lib/fog/vcloud/parser.rb +0 -42
  132. data/lib/fog/vcloud/parsers/get_organization.rb +0 -37
  133. data/lib/fog/vcloud/parsers/get_vdc.rb +0 -62
  134. data/lib/fog/vcloud/parsers/get_versions.rb +0 -46
  135. data/lib/fog/vcloud/parsers/login.rb +0 -36
  136. data/lib/fog/vcloud/parsers/network.rb +0 -53
  137. data/lib/fog/vcloud/terremark/all.rb +0 -9
  138. data/lib/fog/vcloud/terremark/ecloud/parsers/get_internet_services.rb +0 -59
  139. data/lib/fog/vcloud/terremark/ecloud/parsers/get_public_ip.rb +0 -30
  140. data/lib/fog/vcloud/terremark/ecloud/parsers/get_public_ips.rb +0 -40
  141. data/lib/fog/vcloud/terremark/ecloud/parsers/get_vdc.rb +0 -59
  142. data/lib/fog/vcloud/terremark/ecloud/parsers/internet_service.rb +0 -58
  143. data/lib/fog/vcloud/terremark/ecloud/parsers/network.rb +0 -28
  144. data/lib/fog/vcloud/terremark/ecloud/parsers/network_ips.rb +0 -31
  145. data/lib/fog/vcloud/terremark/ecloud/requests/login.rb +0 -27
  146. data/lib/fog/vcloud/terremark/vcloud/parsers/get_vdc.rb +0 -34
  147. data/spec/vcloud/terremark/vcloud/requests/get_vdc_spec.rb +0 -74
@@ -11,7 +11,7 @@ module Fog
11
11
  'Authorization' => authorization_header
12
12
  },
13
13
  :method => 'POST',
14
- :parser => Fog::Parsers::Vcloud::Login.new,
14
+ :parse => true,
15
15
  :uri => @login_uri
16
16
  })
17
17
  end
@@ -29,10 +29,10 @@ module Fog
29
29
  #
30
30
  xml = Builder::XmlMarkup.new
31
31
 
32
- mock_it Fog::Parsers::Vcloud::Login.new, 200,
32
+ mock_it 200,
33
33
  xml.OrgList(xmlns) {
34
- Fog::Vcloud::Mock.data[:organizations].each do |org|
35
- xml.Org( org[:info].merge( "type" => "application/vnd.vmware.vcloud.org+xml" ) ) {}
34
+ mock_data[:organizations].each do |org|
35
+ xml.Org( :type => "application/vnd.vmware.vcloud.org+xml", :href => org[:info][:href], :name => org[:info][:name] )
36
36
  end
37
37
  },
38
38
  { 'Set-Cookie' => 'vcloud-token=fc020a05-21d7-4f33-9b2a-25d8cd05a44e; path=/',
@@ -2,14 +2,130 @@ module Fog
2
2
  module Vcloud
3
3
  module Terremark
4
4
  module Ecloud
5
+ extend Fog::Vcloud::Extension
6
+
7
+ model_path 'fog/vcloud/terremark/ecloud/models'
8
+ model :catalog_item
9
+ model :catalog
10
+ model :internet_service
11
+ model :internet_services
12
+ model :ip
13
+ model :ips
14
+ model :network
15
+ model :networks
16
+ model :node
17
+ model :nodes
18
+ model :public_ip
19
+ model :public_ips
20
+ model :server
21
+ model :servers
22
+ model :task
23
+ model :tasks
24
+ model :vdc
25
+ model :vdcs
26
+
27
+ request_path 'fog/vcloud/terremark/ecloud/requests'
28
+ request :add_internet_service
29
+ request :add_node
30
+ request :configure_internet_service
31
+ request :configure_network
32
+ request :configure_network_ip
33
+ request :configure_node
34
+ request :configure_vapp
35
+ request :delete_internet_service
36
+ request :delete_node
37
+ request :delete_vapp
38
+ request :get_catalog
39
+ request :get_catalog_item
40
+ request :get_customization_options
41
+ request :get_internet_services
42
+ request :get_network
43
+ request :get_network_ip
44
+ request :get_network_ips
45
+ request :get_network_extensions
46
+ request :get_node
47
+ request :get_nodes
48
+ request :get_public_ip
49
+ request :get_public_ips
50
+ request :get_task
51
+ request :get_task_list
52
+ request :get_vapp
53
+ request :get_vdc
54
+ request :power_off
55
+ request :power_on
56
+ request :power_reset
57
+ request :power_shutdown
58
+
59
+ versions "v0.8b-ext2.3"
5
60
 
6
61
  module Mock
7
62
  def self.base_url
8
- "https://fakey.com/api/v0.8a-ext2.0"
63
+ "https://fakey.com/api/v0.8b-ext2.3"
64
+ end
65
+
66
+ def self.data_reset
67
+ @mock_data = nil
68
+ Fog::Vcloud::Mock.data_reset
69
+ end
70
+
71
+ def self.extension_url
72
+ self.base_url + "/extensions"
9
73
  end
10
74
 
11
- def self.data
12
- @mock_data ||= Fog::Vcloud::Mock.data
75
+ def self.data( base_url = self.base_url )
76
+ @mock_data ||= begin
77
+ extension_href =
78
+ vcloud_data = Fog::Vcloud::Mock.data(base_url)
79
+ vcloud_data.delete( :versions )
80
+ vcloud_data.merge!( :versions => [ { :version => "v0.8b-ext2.3", :login_url => "#{base_url}/login", :supported => true } ] )
81
+
82
+ vcloud_data[:organizations][0][:vdcs][0][:public_ips] =
83
+ [
84
+ { :id => "51",
85
+ :href => extension_url + "/publicIp/51",
86
+ :name => "99.1.2.3",
87
+ :services => [
88
+ { :id => "71", :port => "80", :protocol => 'HTTP', :enabled => "true", :timeout => "2", :name => 'Web Site', :description => 'Web Servers' },
89
+ { :id => "72", :port => "7000", :protocol => 'HTTP', :enabled => "true", :timeout => "2", :name => 'An SSH Map', :description => 'SSH 1' }
90
+ ]
91
+ },
92
+ { :id => "52",
93
+ :href => extension_url + "/publicIp/52",
94
+ :name => "99.1.2.4",
95
+ :services => [
96
+ { :id => "73", :port => "80", :protocol => 'HTTP', :enabled => "true", :timeout => "2", :name => 'Web Site', :description => 'Web Servers' },
97
+ { :id => "74", :port => "7000", :protocol => 'HTTP', :enabled => "true", :timeout => "2", :name => 'An SSH Map', :description => 'SSH 2' }
98
+ ]
99
+ },
100
+ { :id => "53",
101
+ :href => extension_url + "/publicIp/53",
102
+ :name => "99.1.9.7",
103
+ :services => []
104
+ }
105
+ ]
106
+
107
+ vcloud_data[:organizations][0][:vdcs][1][:public_ips] =
108
+ [
109
+ { :id => "54",
110
+ :href => extension_url + "/publicIp/54",
111
+ :name => "99.99.99.99",
112
+ :services => []
113
+ }
114
+ ]
115
+
116
+ vcloud_data[:organizations].each do |organization|
117
+ organization[:info][:extension_href] = extension_url
118
+ organization[:vdcs].each do | vdc|
119
+ vdc[:extension_href] = "#{base_url}/extensions/vdc/#{vdc[:id]}"
120
+ vdc[:networks].each do |network|
121
+ network[:extension_href] = "#{extension_url}/network/#{network[:id]}"
122
+ network[:rnat] = vdc[:public_ips].first[:name]
123
+ end
124
+ end
125
+ end
126
+
127
+ vcloud_data
128
+ end
13
129
  end
14
130
 
15
131
  def self.public_ip_href(ip)
@@ -19,62 +135,17 @@ module Fog
19
135
  def self.internet_service_href(internet_service)
20
136
  "#{base_url}/extensions/internetService/#{internet_service[:id]}"
21
137
  end
22
- end
23
138
 
24
- module Versions
25
- SUPPORTED = ["v0.8", "v0.8a-ext2.0"]
26
- end
27
-
28
- def self.extended(klass)
29
- #Do anything we need to do here that's specific to ecloud
30
- unless @required
31
- require 'fog/vcloud/terremark/all'
32
- require 'fog/vcloud/terremark/ecloud/models/internet_service'
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'
38
- require 'fog/vcloud/terremark/ecloud/models/public_ip'
39
- require 'fog/vcloud/terremark/ecloud/models/public_ips'
40
- require 'fog/vcloud/terremark/ecloud/models/vdc'
41
- require 'fog/vcloud/terremark/ecloud/models/vdcs'
42
- require 'fog/vcloud/terremark/ecloud/parsers/get_internet_services'
43
- require 'fog/vcloud/terremark/ecloud/parsers/get_public_ip'
44
- require 'fog/vcloud/terremark/ecloud/parsers/get_public_ips'
45
- require 'fog/vcloud/terremark/ecloud/parsers/get_vdc'
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'
49
- require 'fog/vcloud/terremark/ecloud/requests/add_internet_service'
50
- require 'fog/vcloud/terremark/ecloud/requests/configure_internet_service'
51
- require 'fog/vcloud/terremark/ecloud/requests/delete_internet_service'
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'
55
- require 'fog/vcloud/terremark/ecloud/requests/get_public_ip'
56
- require 'fog/vcloud/terremark/ecloud/requests/get_public_ips'
57
- require 'fog/vcloud/terremark/ecloud/requests/login'
58
- require 'fog/vcloud/terremark/ecloud/requests/get_vdc'
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)
62
- Struct.new("TmrkEcloudList", :links)
63
- Struct.new("TmrkEcloudPublicIp", :type, :href, :name, :id)
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)
69
- @required = true
139
+ def ecloud_xmlns
140
+ { :xmlns => "urn:tmrk:eCloudExtensions-2.3", :"xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance" }
70
141
  end
71
- if Fog.mocking?
72
- klass.extend Fog::Vcloud::Terremark::Ecloud::Mock
73
- else
74
- klass.extend Fog::Vcloud::Terremark::Ecloud::Real
142
+
143
+ def mock_data
144
+ Fog::Vcloud::Terremark::Ecloud::Mock.data
75
145
  end
76
146
  end
77
147
 
148
+
78
149
  private
79
150
 
80
151
  # If we don't support any versions the service does, then raise an error.
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module Vcloud
3
+ module Terremark
4
+ module Ecloud
5
+
6
+ class Catalog < Fog::Vcloud::Collection
7
+
8
+ model Fog::Vcloud::Terremark::Ecloud::CatalogItem
9
+
10
+ attribute :href, :aliases => :Href
11
+
12
+ def all
13
+ if data = connection.get_catalog(href).body[:CatalogItems][:CatalogItem]
14
+ load(data)
15
+ end
16
+ end
17
+
18
+ def get(uri)
19
+ if data = connection.get_catalog_item(uri)
20
+ new(data.body)
21
+ end
22
+ rescue Fog::Errors::NotFound
23
+ nil
24
+ end
25
+
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,31 @@
1
+ module Fog
2
+ module Vcloud
3
+ module Terremark
4
+ module Ecloud
5
+ class CatalogItem < Fog::Vcloud::Model
6
+
7
+ identity :href, :Href
8
+
9
+ ignore_attributes :xmlns, :xmlns_i, :xmlns_xsi, :xmlns_xsd
10
+
11
+ attribute :type
12
+ attribute :name
13
+ attribute :entity, :aliases => :Entity
14
+ attribute :link, :aliases => :Link
15
+ attribute :property, :aliases => :Property
16
+
17
+ def customization_options
18
+ load_unless_loaded!
19
+ if data = connection.get_customization_options( link[:href] ).body
20
+ data.delete_if { |key, value| [:xmlns_i, :xmlns].include?(key) }
21
+ data
22
+ else
23
+ nil
24
+ end
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,49 +1,48 @@
1
- require 'fog/model'
2
-
3
1
  module Fog
4
2
  module Vcloud
5
3
  module Terremark
6
4
  module Ecloud
7
5
  class InternetService < Fog::Vcloud::Model
8
6
 
9
- identity :href
7
+ identity :href, :Href
10
8
 
11
- attribute :name
12
- attribute :id
13
- attribute :type
14
- attribute :protocol
15
- attribute :port
16
- attribute :enabled
17
- attribute :description
18
- attribute :public_ip
19
- attribute :timeout
20
- attribute :url_send_string
21
- attribute :http_header
9
+ ignore_attributes :xmlns, :xmlns_i
22
10
 
23
- attr_accessor :new
11
+ attribute :name, :aliases => :Name
12
+ attribute :id, :aliases => :Id
13
+ attribute :protocol, :aliases => :Protocol
14
+ attribute :port, :aliases => :Port
15
+ attribute :enabled, :aliases => :Enabled
16
+ attribute :description, :aliases => :Description
17
+ attribute :public_ip, :aliases => :PublicIpAddress
18
+ attribute :timeout, :aliases => :Timeout
19
+ attribute :redirect_url, :aliases => :RedirectURL
20
+ attribute :monitor, :aliases => :Monitor
24
21
 
25
22
  def delete
26
23
  requires :href
27
24
 
28
- connection.delete_internet_service( self.href )
29
- collection.reload
25
+ connection.delete_internet_service( href )
30
26
  end
31
27
 
32
28
  def save
33
29
  if new_record?
34
30
  result = connection.add_internet_service( collection.href, _compose_service_data )
35
- self.href = result.body.href
36
- self.reload
31
+ merge_attributes(result.body)
37
32
  else
38
- connection.configure_internet_service( self.href, _compose_service_data, _compose_ip_data )
33
+ connection.configure_internet_service( href, _compose_service_data, _compose_ip_data )
39
34
  end
40
35
  end
41
36
 
37
+ def nodes
38
+ @nodes ||= Fog::Vcloud::Terremark::Ecloud::Nodes.new( :connection => connection, :href => href + "/nodeServices" )
39
+ end
40
+
42
41
  private
43
42
 
44
43
  def _compose_service_data
45
44
  service_data = {}
46
- self.class.attributes.select{ |attribute| !attribute.nil? }.each { |attribute| service_data[attribute] = send(attribute).to_s }
45
+ self.class.attributes.select{ |attribute| !send(attribute).nil? }.each { |attribute| service_data[attribute] = send(attribute).to_s }
47
46
  service_data
48
47
  end
49
48
 
@@ -51,7 +50,7 @@ module Fog
51
50
  if public_ip.nil?
52
51
  {}
53
52
  else
54
- { :id => self.public_ip.id, :href => self.public_ip.href.to_s, :name => self.public_ip.name }
53
+ { :id => public_ip[:Id], :href => public_ip[:Href], :name => public_ip[:Name] }
55
54
  end
56
55
  end
57
56
 
@@ -3,12 +3,6 @@ module Fog
3
3
  module Terremark
4
4
  module Ecloud
5
5
 
6
- module Mock
7
- def internet_services(options = {})
8
- @internet_services ||= Fog::Vcloud::Terremark::Ecloud::InternetServices.new(options.merge(:connection => self))
9
- end
10
- end
11
-
12
6
  module Real
13
7
  def internet_services(options = {})
14
8
  @internet_services ||= Fog::Vcloud::Terremark::Ecloud::InternetServices.new(options.merge(:connection => self))
@@ -19,29 +13,21 @@ module Fog
19
13
 
20
14
  model Fog::Vcloud::Terremark::Ecloud::InternetService
21
15
 
22
- vcloud_type "application/vnd.tmrk.ecloud.internetService+xml"
23
- all_request lambda { |internet_services| internet_services.send(:raw_results) }
16
+ attribute :href, :aliases => :Href
24
17
 
25
- def get(uri)
26
- if internet_service = get_raw(uri)
27
- item = new(:href => internet_service.href)
28
- item.reload
18
+ def all
19
+ if data = connection.get_internet_services(href).body[:InternetService]
20
+ load(data)
29
21
  end
30
22
  end
31
23
 
32
- def get_raw(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
39
- end
40
-
41
- private
42
-
43
- def raw_results
44
- @raw_results ||= connection.get_internet_services(self.href)
24
+ # Optimize later, no need to get_internet_services again
25
+ def get(uri)
26
+ if data = connection.get_internet_services(href).body[:InternetService].detect { |service| service[:Href] == uri }
27
+ new(data)
28
+ end
29
+ rescue Fog::Errors::NotFound
30
+ nil
45
31
  end
46
32
 
47
33
  end
@@ -1,15 +1,48 @@
1
- require 'fog/model'
2
-
3
1
  module Fog
4
2
  module Vcloud
5
3
  module Terremark
6
4
  module Ecloud
7
5
  class Ip < Fog::Vcloud::Model
8
6
 
9
- identity :name
7
+ ignore_attributes :xmlns_i, :xmlns
8
+
9
+ identity :href, :Href
10
+
11
+ attribute :name, :Name
12
+ attribute :status, :aliases => :Status
13
+ attribute :server, :aliases => :Server
14
+ attribute :rnat, :aliases => :RnatAddress
15
+ attribute :id, :aliases => :Id, :type => :integer
16
+
17
+ def rnat=(new_rnat)
18
+ @rnat = new_rnat
19
+ @changed = true
20
+ end
21
+
22
+ def save
23
+ if @changed
24
+ connection.configure_network_ip( href, _compose_network_ip_data )
25
+ end
26
+ true
27
+ end
28
+
29
+ def reload
30
+ super
31
+ @changed = false
32
+ true
33
+ end
10
34
 
11
- attribute :status
12
- attribute :server
35
+ private
36
+ def _compose_network_ip_data
37
+ {
38
+ :id => id,
39
+ :href => href,
40
+ :name => name,
41
+ :status => status,
42
+ :server => server,
43
+ :rnat => rnat
44
+ }
45
+ end
13
46
 
14
47
  end
15
48
  end