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
@@ -0,0 +1,43 @@
1
+ module Fog
2
+ module Vcloud
3
+ module Terremark
4
+ module Ecloud
5
+
6
+ class Servers < Fog::Vcloud::Collection
7
+
8
+ model Fog::Vcloud::Terremark::Ecloud::Server
9
+
10
+ attribute :href, :aliases => :Href
11
+
12
+ def all
13
+ load(_vapps)
14
+ end
15
+
16
+ def get(uri)
17
+ if data = connection.get_vapp(uri)
18
+ new(data.body)
19
+ end
20
+ rescue Fog::Errors::NotFound
21
+ nil
22
+ end
23
+
24
+ private
25
+
26
+ def _resource_entities
27
+ connection.get_vdc(href).body[:ResourceEntities][:ResourceEntity]
28
+ end
29
+
30
+ def _vapps
31
+ resource_entities = _resource_entities
32
+ if resource_entities.nil?
33
+ []
34
+ else
35
+ resource_entities
36
+ end
37
+ end
38
+
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,22 @@
1
+ module Fog
2
+ module Vcloud
3
+ module Terremark
4
+ module Ecloud
5
+ class Task < Fog::Vcloud::Model
6
+
7
+ identity :href, :Href
8
+
9
+ ignore_attributes :xmlns, :xmlns_i, :xmlns_xsi, :xmlns_xsd
10
+
11
+ attribute :status
12
+ attribute :type
13
+ attribute :result, :aliases => :Result
14
+ attribute :owner, :aliases => :Owner
15
+ attribute :start_time, :aliases => :startTime, :type => :time
16
+ attribute :end_time, :aliases => :endTime, :type => :time
17
+
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module Vcloud
3
+ module Terremark
4
+ module Ecloud
5
+
6
+ class Tasks < Fog::Vcloud::Collection
7
+
8
+ model Fog::Vcloud::Terremark::Ecloud::Task
9
+
10
+ attribute :href, :aliases => :Href
11
+
12
+ def all
13
+ if data = connection.get_task_list(href).body[:Task]
14
+ load(data)
15
+ end
16
+ end
17
+
18
+ def get(uri)
19
+ if data = connection.get_task(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
@@ -2,23 +2,27 @@ module Fog
2
2
  module Vcloud
3
3
  module Terremark
4
4
  module Ecloud
5
- class Vdc < Fog::Vcloud::Vdc
5
+ class Vdc < Fog::Vcloud::Model
6
6
 
7
- delete_attribute :enabled
8
- delete_attribute :vm_quota
9
- delete_attribute :nic_quota
10
- delete_attribute :network_quota
11
- delete_attribute :allocation_model
7
+ identity :href
12
8
 
9
+ ignore_attributes :xmlns, :xmlns_xsi, :xmlns_xsd
10
+
11
+ attribute :name
12
+ attribute :type
13
+ attribute :description, :aliases => :Description
14
+ attribute :other_links, :aliases => :Link
15
+ attribute :compute_capacity, :aliases => :ComputeCapacity
16
+ attribute :storage_capacity, :aliases => :StorageCapacity
17
+ attribute :available_networks, :aliases => :AvailableNetworks, :squash => :Network
18
+ attribute :resource_entities, :aliases => :ResourceEntities, :squash => :ResourceEntity
13
19
  attribute :deployed_vm_quota
14
20
  attribute :instantiated_vm_quota
15
21
 
16
22
  def public_ips
17
- unless @loaded
18
- reload
19
- end
23
+ load_unless_loaded!
20
24
  @public_ips ||= Fog::Vcloud::Terremark::Ecloud::PublicIps.new( :connection => connection,
21
- :href => other_links.detect { |link| link.type == "application/vnd.tmrk.ecloud.publicIpsList+xml" }.href )
25
+ :href => other_links.detect { |link| link[:type] == "application/vnd.tmrk.ecloud.publicIpsList+xml" }[:href] )
22
26
  end
23
27
 
24
28
  def internet_services
@@ -33,6 +37,24 @@ module Fog
33
37
  :href => href )
34
38
  end
35
39
 
40
+ def servers
41
+ @servers ||= Fog::Vcloud::Terremark::Ecloud::Servers.
42
+ new( :connection => connection,
43
+ :href => href )
44
+ end
45
+
46
+ def tasks
47
+ @tasks ||= Fog::Vcloud::Terremark::Ecloud::Tasks.
48
+ new( :connection => connection,
49
+ :href => href + "/tasksList" )
50
+ end
51
+
52
+ def catalog
53
+ @catalog ||= Fog::Vcloud::Terremark::Ecloud::Catalog.
54
+ new( :connection => connection,
55
+ :href => href + "/catalog" )
56
+ end
57
+
36
58
  end
37
59
  end
38
60
  end
@@ -2,17 +2,20 @@ module Fog
2
2
  module Vcloud
3
3
  module Terremark
4
4
  module Ecloud
5
- module Mock
5
+
6
+ module Real
6
7
  def vdcs(options = {})
7
8
  @vdcs ||= Fog::Vcloud::Terremark::Ecloud::Vdcs.new(options.merge(:connection => self))
8
9
  end
9
10
  end
10
11
 
11
- module Real
12
+ #FIXME: Should be no need to do this ... duplicte code ... find a better way
13
+ module Mock
12
14
  def vdcs(options = {})
13
15
  @vdcs ||= Fog::Vcloud::Terremark::Ecloud::Vdcs.new(options.merge(:connection => self))
14
16
  end
15
17
  end
18
+ #/FIXME
16
19
 
17
20
  class Vdcs < Fog::Vcloud::Vdcs
18
21
 
@@ -20,10 +23,6 @@ module Fog
20
23
 
21
24
  model Fog::Vcloud::Terremark::Ecloud::Vdc
22
25
 
23
- #get_request :get_vdc
24
- #vcloud_type "application/vnd.vmware.vcloud.vdc+xml"
25
- #all_request lambda { |vdcs| vdcs.connection.get_organization(vdcs.organization_uri) }
26
-
27
26
  end
28
27
  end
29
28
  end
@@ -4,21 +4,33 @@ module Fog
4
4
  module Ecloud
5
5
  module Real
6
6
 
7
- def self.generate_internet_service_request(service_data)
7
+ def generate_internet_service_request(service_data)
8
8
  builder = Builder::XmlMarkup.new
9
9
  builder.CreateInternetServiceRequest(:"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
10
10
  :"xmlns:xsd" => "http://www.w3.org/2001/XMLSchema",
11
- :xmlns => "urn:tmrk:eCloudExtensions-2.0") {
11
+ :xmlns => "urn:tmrk:eCloudExtensions-2.3") {
12
12
  builder.Name(service_data[:name])
13
13
  builder.Protocol(service_data[:protocol])
14
14
  builder.Port(service_data[:port])
15
15
  builder.Enabled(service_data[:enabled])
16
16
  builder.Description(service_data[:description])
17
+ builder.RedirectUrl(service_data[:redirect_url])
18
+ #builder.Monitor {
19
+ # builder.MonitorType {}
20
+ # builder.UrlSendString {}
21
+ # builder.HttpHeader {}
22
+ # builder.ReceiveString {}
23
+ # builder.Interval {}
24
+ # builder.ResponseTimeOut {}
25
+ # builder.DownTime {}
26
+ # builder.Retries {}
27
+ # builder.IsEnabled {}
28
+ #}
17
29
  }
18
30
  end
19
31
 
20
- def self.validate_internet_service_data(service_data, configure=false)
21
- valid_opts = [:name, :protocol, :port, :description, :enabled, :description]
32
+ def validate_internet_service_data(service_data, configure=false)
33
+ valid_opts = [:name, :protocol, :port, :description, :enabled, :redirect_url]
22
34
  if configure
23
35
  valid_opts + [ :id, :href, :timeout ]
24
36
  end
@@ -28,14 +40,13 @@ module Fog
28
40
  end
29
41
 
30
42
  def add_internet_service(internet_services_uri, service_data)
31
- Fog::Vcloud::Terremark::Ecloud::Real.validate_internet_service_data(service_data)
43
+ validate_internet_service_data(service_data)
32
44
 
33
45
  request(
34
- :body => Fog::Vcloud::Terremark::Ecloud::Real.generate_internet_service_request(service_data),
46
+ :body => generate_internet_service_request(service_data),
35
47
  :expects => 200,
36
48
  :headers => {'Content-Type' => 'application/vnd.tmrk.ecloud.internetService+xml'},
37
49
  :method => 'POST',
38
- :parser => Fog::Parsers::Vcloud::Terremark::Ecloud::InternetService.new,
39
50
  :uri => internet_services_uri
40
51
  )
41
52
  end
@@ -49,9 +60,11 @@ module Fog
49
60
  #
50
61
 
51
62
  def add_internet_service(internet_services_uri, service_data)
52
- Fog::Vcloud::Terremark::Ecloud::Real.validate_internet_service_data(service_data)
63
+ validate_internet_service_data(service_data)
53
64
 
54
- if ip = Fog::Vcloud::Mock.ip_from_uri(internet_services_uri.to_s)
65
+ internet_services_uri = ensure_unparsed(internet_services_uri)
66
+
67
+ if ip = ip_from_uri(internet_services_uri)
55
68
  new_service = service_data.merge!( { :id => rand(1000), :timeout => 2 } )
56
69
  ip[:services] << new_service
57
70
  builder = Builder::XmlMarkup.new
@@ -72,7 +85,7 @@ module Fog
72
85
  builder.Timeout(new_service[:timeout])
73
86
  }
74
87
 
75
- mock_it Fog::Parsers::Vcloud::Terremark::Ecloud::InternetService.new, 200, xml, {'Content-Type' => 'application/vnd.tmrk.ecloud.internetService+xml'}
88
+ mock_it 200, xml, {'Content-Type' => 'application/vnd.tmrk.ecloud.internetService+xml'}
76
89
  else
77
90
  mock_error 200, "401 Unauthorized"
78
91
  end
@@ -0,0 +1,54 @@
1
+ module Fog
2
+ module Vcloud
3
+ module Terremark
4
+ module Ecloud
5
+ module Real
6
+
7
+ def add_node(nodes_uri, node_data)
8
+ validate_node_data(node_data)
9
+
10
+ request(
11
+ :body => generate_node_request(node_data),
12
+ :expects => 200,
13
+ :headers => {'Content-Type' => 'application/vnd.tmrk.ecloud.nodeService+xml'},
14
+ :method => 'POST',
15
+ :uri => nodes_uri
16
+ )
17
+ end
18
+
19
+ private
20
+
21
+ def generate_node_request(node_data)
22
+ builder = Builder::XmlMarkup.new
23
+ builder.CreateNodeServiceRequest(:"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
24
+ :"xmlns:xsd" => "http://www.w3.org/2001/XMLSchema",
25
+ :xmlns => "urn:tmrk:eCloudExtensions-2.3") {
26
+ builder.IpAddress(node_data[:ip_address])
27
+ builder.Name(node_data[:name])
28
+ builder.Port(node_data[:port])
29
+ builder.Enabled(node_data[:enabled])
30
+ builder.Description(node_data[:description])
31
+ }
32
+ end
33
+
34
+ def validate_node_data(node_data, configure=false)
35
+ valid_opts = [:name, :port, :enabled, :description, :ip_address]
36
+ if configure
37
+ valid_opts.delete_if { |opt| ![:name, :enabled, :description].include?(opt) }
38
+ end
39
+ unless valid_opts.all? { |opt| node_data.keys.include?(opt) }
40
+ raise ArgumentError.new("Required data missing: #{(valid_opts - node_data.keys).map(&:inspect).join(", ")}")
41
+ end
42
+ end
43
+ end
44
+
45
+ module Mock
46
+
47
+ def add_node(nodes_uri, node_data)
48
+ Fog::Mock.not_implemented
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -4,10 +4,10 @@ module Fog
4
4
  module Ecloud
5
5
  module Real
6
6
 
7
- def self.generate_configure_internet_service_request(service_data,ip_address_data)
7
+ def generate_configure_internet_service_request(service_data,ip_address_data)
8
8
  builder = Builder::XmlMarkup.new
9
9
  builder.InternetService(:"xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance",
10
- :xmlns => "urn:tmrk:eCloudExtensions-2.0") {
10
+ :xmlns => "urn:tmrk:eCloudExtensions-2.3") {
11
11
  builder.Id(service_data[:id])
12
12
  builder.Href(service_data[:href].to_s)
13
13
  builder.Name(service_data[:name])
@@ -16,6 +16,7 @@ module Fog
16
16
  builder.Enabled(service_data[:enabled])
17
17
  builder.Description(service_data[:description])
18
18
  builder.Timeout(service_data[:timeout])
19
+ builder.RedirectUrl(service_data[:redirect_url])
19
20
  builder.PublicIpAddress {
20
21
  builder.Id(ip_address_data[:id])
21
22
  builder.Href(ip_address_data[:href].to_s)
@@ -24,7 +25,7 @@ module Fog
24
25
  }
25
26
  end
26
27
 
27
- def self.validate_public_ip_address_data(ip_address_data)
28
+ def validate_public_ip_address_data(ip_address_data)
28
29
  valid_opts = [:name, :href, :id]
29
30
  unless valid_opts.all? { |opt| ip_address_data.keys.include?(opt) }
30
31
  raise ArgumentError.new("Required Internet Service data missing: #{(valid_opts - ip_address_data.keys).map(&:inspect).join(", ")}")
@@ -32,16 +33,15 @@ module Fog
32
33
  end
33
34
 
34
35
  def configure_internet_service(internet_service_uri, service_data, ip_address_data)
35
- Fog::Vcloud::Terremark::Ecloud::Real.validate_internet_service_data(service_data, true)
36
+ validate_internet_service_data(service_data, true)
36
37
 
37
- Fog::Vcloud::Terremark::Ecloud::Real.validate_public_ip_address_data(ip_address_data)
38
+ validate_public_ip_address_data(ip_address_data)
38
39
 
39
40
  request(
40
- :body => Fog::Vcloud::Terremark::Ecloud::Real.generate_configure_internet_service_request(service_data, ip_address_data),
41
+ :body => generate_configure_internet_service_request(service_data, ip_address_data),
41
42
  :expects => 200,
42
43
  :headers => {'Content-Type' => 'application/vnd.tmrk.ecloud.internetService+xml'},
43
44
  :method => 'PUT',
44
- :parser => Fog::Parsers::Vcloud::Terremark::Ecloud::InternetService.new,
45
45
  :uri => internet_service_uri
46
46
  )
47
47
  end
@@ -55,14 +55,16 @@ module Fog
55
55
  #
56
56
 
57
57
  def configure_internet_service(internet_service_uri, service_data, ip_address_data)
58
- Fog::Vcloud::Terremark::Ecloud::Real.validate_internet_service_data(service_data, true)
58
+ validate_internet_service_data(service_data, true)
59
59
 
60
- Fog::Vcloud::Terremark::Ecloud::Real.validate_public_ip_address_data(ip_address_data)
60
+ validate_public_ip_address_data(ip_address_data)
61
+
62
+ internet_service_uri = ensure_unparsed(internet_service_uri)
61
63
 
62
64
  found = false
63
65
  xml = nil
64
- if ip = Fog::Vcloud::Mock.ip_from_uri(ip_address_data[:href])
65
- if service = ip[:services].detect { |service| service[:id] == internet_service_uri.to_s.split('/')[-1].to_i }
66
+ if ip = ip_from_uri(ip_address_data[:href])
67
+ if service = ip[:services].detect { |service| service[:id] == internet_service_uri.split('/')[-1] }
66
68
  found = true
67
69
  ip[:services][ip[:services].index(service)] = service_data
68
70
 
@@ -86,7 +88,7 @@ module Fog
86
88
  end
87
89
  end
88
90
  if found
89
- mock_it Fog::Parsers::Vcloud::Terremark::Ecloud::InternetService.new, 200, xml, {'Content-Type' => 'application/vnd.tmrk.ecloud.internetService+xml'}
91
+ mock_it 200, xml, {'Content-Type' => 'application/vnd.tmrk.ecloud.internetService+xml'}
90
92
  else
91
93
  mock_error 200, "401 Unauthorized"
92
94
  end
@@ -0,0 +1,53 @@
1
+ module Fog
2
+ module Vcloud
3
+ module Terremark
4
+ module Ecloud
5
+ module Real
6
+
7
+ def validate_network_data(network_data, configure=false)
8
+ valid_opts = [:id, :href, :name, :rnat, :address, :broadcast, :gateway]
9
+ unless valid_opts.all? { |opt| network_data.keys.include?(opt) }
10
+ raise ArgumentError.new("Required data missing: #{(valid_opts - network_data.keys).map(&:inspect).join(", ")}")
11
+ end
12
+ end
13
+
14
+ def configure_network(network_uri, network_data)
15
+ validate_network_data(network_data)
16
+
17
+ request(
18
+ :body => generate_configure_network_request(network_data),
19
+ :expects => 200,
20
+ :headers => {'Content-Type' => 'application/vnd.tmrk.ecloud.networkService+xml'},
21
+ :method => 'PUT',
22
+ :uri => network_uri
23
+ )
24
+ end
25
+
26
+ private
27
+
28
+ def generate_configure_network_request(network_data)
29
+ builder = Builder::XmlMarkup.new
30
+ builder.Network(:"xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance",
31
+ :xmlns => "urn:tmrk:eCloudExtensions-2.3") {
32
+ builder.Id(network_data[:id])
33
+ builder.Href(network_data[:href])
34
+ builder.Name(network_data[:name])
35
+ builder.RnatAddress(network_data[:rnat])
36
+ builder.Address(network_data[:address])
37
+ builder.BroadcastAddress(network_data[:broadcast])
38
+ builder.GatewayAddress(network_data[:gateway])
39
+ }
40
+ end
41
+
42
+ end
43
+
44
+ module Mock
45
+
46
+ def configure_network(network_uri, network_data)
47
+ Fog::Mock.not_implemented
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end