fog 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. data/.gitignore +1 -0
  2. data/Rakefile +3 -3
  3. data/changelog.txt +213 -0
  4. data/docs/compute/index.markdown +15 -1
  5. data/fog.gemspec +3 -3
  6. data/lib/fog.rb +1 -1
  7. data/lib/fog/aws.rb +9 -0
  8. data/lib/fog/aws/auto_scaling.rb +3 -1
  9. data/lib/fog/aws/cloud_formation.rb +2 -0
  10. data/lib/fog/aws/cloud_watch.rb +2 -0
  11. data/lib/fog/aws/compute.rb +9 -3
  12. data/lib/fog/aws/elasticache.rb +8 -1
  13. data/lib/fog/aws/elb.rb +2 -0
  14. data/lib/fog/aws/models/cloud_watch/metric_statistic.rb +1 -2
  15. data/lib/fog/aws/models/compute/security_group.rb +1 -1
  16. data/lib/fog/aws/models/compute/server.rb +3 -1
  17. data/lib/fog/aws/models/dns/records.rb +3 -3
  18. data/lib/fog/aws/models/elb/load_balancer.rb +6 -0
  19. data/lib/fog/aws/models/storage/file.rb +2 -2
  20. data/lib/fog/aws/models/storage/files.rb +4 -4
  21. data/lib/fog/aws/parsers/compute/describe_instance_status.rb +64 -0
  22. data/lib/fog/aws/parsers/compute/describe_security_groups.rb +1 -1
  23. data/lib/fog/aws/parsers/sqs/receive_message.rb +1 -1
  24. data/lib/fog/aws/parsers/sts/get_session_token.rb +31 -0
  25. data/lib/fog/aws/rds.rb +36 -1
  26. data/lib/fog/aws/requests/compute/describe_availability_zones.rb +3 -0
  27. data/lib/fog/aws/requests/compute/describe_instance_status.rb +36 -0
  28. data/lib/fog/aws/requests/compute/describe_security_groups.rb +2 -0
  29. data/lib/fog/aws/requests/elb/set_load_balancer_listener_ssl_certificate.rb +27 -0
  30. data/lib/fog/aws/requests/rds/create_db_instance.rb +64 -1
  31. data/lib/fog/aws/requests/rds/delete_db_instance.rb +19 -3
  32. data/lib/fog/aws/requests/rds/describe_db_instances.rb +40 -1
  33. data/lib/fog/aws/requests/rds/describe_db_reserved_instances.rb +1 -1
  34. data/lib/fog/aws/requests/rds/modify_db_instance.rb +24 -1
  35. data/lib/fog/aws/requests/rds/reboot_db_instance.rb +17 -1
  36. data/lib/fog/aws/requests/storage/{hash_to_acl.rb → acl_utils.rb} +8 -0
  37. data/lib/fog/aws/requests/storage/copy_object.rb +8 -0
  38. data/lib/fog/aws/requests/storage/get_bucket_acl.rb +7 -1
  39. data/lib/fog/aws/requests/storage/get_object_acl.rb +7 -1
  40. data/lib/fog/aws/requests/storage/get_object_http_url.rb +4 -3
  41. data/lib/fog/aws/requests/storage/get_object_https_url.rb +4 -3
  42. data/lib/fog/aws/requests/storage/put_bucket_acl.rb +2 -2
  43. data/lib/fog/aws/requests/storage/put_object_acl.rb +1 -1
  44. data/lib/fog/aws/requests/sts/get_federation_token.rb +20 -0
  45. data/lib/fog/aws/requests/sts/get_session_token.rb +18 -0
  46. data/lib/fog/aws/simpledb.rb +5 -1
  47. data/lib/fog/aws/sns.rb +2 -0
  48. data/lib/fog/aws/sqs.rb +5 -1
  49. data/lib/fog/aws/storage.rb +6 -0
  50. data/lib/fog/aws/sts.rb +137 -0
  51. data/lib/fog/bin.rb +1 -0
  52. data/lib/fog/bin/aws.rb +2 -0
  53. data/lib/fog/bin/clodo.rb +31 -0
  54. data/lib/fog/brightbox/compute.rb +7 -0
  55. data/lib/fog/brightbox/models/compute/cloud_ip.rb +10 -2
  56. data/lib/fog/brightbox/models/compute/firewall_policies.rb +29 -0
  57. data/lib/fog/brightbox/models/compute/firewall_policy.rb +65 -0
  58. data/lib/fog/brightbox/models/compute/firewall_rule.rb +54 -0
  59. data/lib/fog/brightbox/models/compute/firewall_rules.rb +24 -0
  60. data/lib/fog/brightbox/models/compute/image.rb +2 -0
  61. data/lib/fog/brightbox/models/compute/server.rb +41 -6
  62. data/lib/fog/brightbox/models/compute/server_group.rb +56 -17
  63. data/lib/fog/brightbox/requests/compute/remove_firewall_policy.rb +14 -0
  64. data/lib/fog/clodo.rb +34 -0
  65. data/lib/fog/clodo/compute.rb +152 -0
  66. data/lib/fog/clodo/models/compute/image.rb +31 -0
  67. data/lib/fog/clodo/models/compute/images.rb +28 -0
  68. data/lib/fog/clodo/models/compute/server.rb +163 -0
  69. data/lib/fog/clodo/models/compute/servers.rb +36 -0
  70. data/lib/fog/clodo/requests/compute/add_ip_address.rb +49 -0
  71. data/lib/fog/clodo/requests/compute/create_server.rb +112 -0
  72. data/lib/fog/clodo/requests/compute/delete_ip_address.rb +47 -0
  73. data/lib/fog/clodo/requests/compute/delete_server.rb +44 -0
  74. data/lib/fog/clodo/requests/compute/get_image_details.rb +20 -0
  75. data/lib/fog/clodo/requests/compute/get_server_details.rb +49 -0
  76. data/lib/fog/clodo/requests/compute/list_images.rb +48 -0
  77. data/lib/fog/clodo/requests/compute/list_images_detail.rb +61 -0
  78. data/lib/fog/clodo/requests/compute/list_servers.rb +50 -0
  79. data/lib/fog/clodo/requests/compute/list_servers_detail.rb +51 -0
  80. data/lib/fog/clodo/requests/compute/move_ip_address.rb +34 -0
  81. data/lib/fog/clodo/requests/compute/reboot_server.rb +19 -0
  82. data/lib/fog/clodo/requests/compute/rebuild_server.rb +21 -0
  83. data/lib/fog/clodo/requests/compute/server_action.rb +25 -0
  84. data/lib/fog/clodo/requests/compute/start_server.rb +19 -0
  85. data/lib/fog/clodo/requests/compute/stop_server.rb +19 -0
  86. data/lib/fog/compute.rb +3 -0
  87. data/lib/fog/core/credentials.rb +3 -3
  88. data/lib/fog/core/errors.rb +2 -0
  89. data/lib/fog/core/wait_for.rb +1 -1
  90. data/lib/fog/dnsmadeeasy/dns.rb +1 -1
  91. data/lib/fog/libvirt/compute.rb +2 -0
  92. data/lib/fog/libvirt/models/compute/nodes.rb +1 -3
  93. data/lib/fog/libvirt/models/compute/server.rb +8 -1
  94. data/lib/fog/providers.rb +1 -0
  95. data/lib/fog/rackspace/dns.rb +10 -2
  96. data/lib/fog/rackspace/load_balancers.rb +3 -0
  97. data/lib/fog/rackspace/models/compute/server.rb +2 -2
  98. data/lib/fog/rackspace/models/dns/callback.rb +3 -1
  99. data/lib/fog/rackspace/models/dns/record.rb +4 -0
  100. data/lib/fog/rackspace/models/load_balancers/load_balancer.rb +18 -8
  101. data/lib/fog/rackspace/requests/load_balancers/delete_nodes.rb +1 -2
  102. data/lib/fog/rackspace/requests/load_balancers/get_error_page.rb +15 -0
  103. data/lib/fog/rackspace/requests/load_balancers/list_load_balancers.rb +8 -2
  104. data/lib/fog/rackspace/requests/load_balancers/remove_error_page.rb +15 -0
  105. data/lib/fog/rackspace/requests/load_balancers/set_error_page.rb +21 -0
  106. data/lib/fog/vcloud/compute.rb +7 -1
  107. data/lib/fog/vcloud/models/compute/catalogs.rb +4 -5
  108. data/lib/fog/vcloud/models/compute/helpers/status.rb +37 -0
  109. data/lib/fog/vcloud/models/compute/network.rb +13 -49
  110. data/lib/fog/vcloud/models/compute/networks.rb +12 -3
  111. data/lib/fog/vcloud/models/compute/organization.rb +44 -0
  112. data/lib/fog/vcloud/models/compute/organizations.rb +29 -0
  113. data/lib/fog/vcloud/models/compute/server.rb +35 -56
  114. data/lib/fog/vcloud/models/compute/servers.rb +11 -13
  115. data/lib/fog/vcloud/models/compute/vapp.rb +41 -0
  116. data/lib/fog/vcloud/models/compute/vapps.rb +32 -0
  117. data/lib/fog/vcloud/models/compute/vdc.rb +11 -26
  118. data/lib/fog/vcloud/models/compute/vdcs.rb +6 -8
  119. data/lib/fog/vcloud/requests/compute/get_server.rb +10 -0
  120. data/lib/fog/vsphere/compute.rb +1 -0
  121. data/lib/fog/vsphere/models/compute/server.rb +18 -0
  122. data/lib/fog/vsphere/models/compute/servers.rb +8 -2
  123. data/lib/fog/vsphere/requests/compute/datacenters.rb +34 -0
  124. data/lib/fog/vsphere/requests/compute/list_virtual_machines.rb +132 -91
  125. data/lib/fog/vsphere/requests/compute/vm_clone.rb +76 -37
  126. data/spec/lib/fog/aws/parsers/sqs/receive_message_spec.rb +58 -0
  127. data/tests/aws/models/elb/model_tests.rb +5 -0
  128. data/tests/aws/requests/compute/instance_tests.rb +23 -0
  129. data/tests/aws/requests/compute/security_group_tests.rb +1 -0
  130. data/tests/aws/requests/elb/listener_tests.rb +4 -0
  131. data/tests/aws/requests/storage/{hash_to_acl_tests.rb → acl_utils_tests.rb} +38 -2
  132. data/tests/aws/requests/storage/bucket_tests.rb +0 -3
  133. data/tests/aws/requests/storage/object_tests.rb +2 -4
  134. data/tests/aws/requests/sts/get_federation_token_tests.rb +21 -0
  135. data/tests/aws/requests/sts/session_token_tests.rb +16 -0
  136. data/tests/brightbox/requests/compute/account_tests.rb +11 -6
  137. data/tests/brightbox/requests/compute/api_client_tests.rb +23 -12
  138. data/tests/brightbox/requests/compute/cloud_ip_tests.rb +32 -17
  139. data/tests/brightbox/requests/compute/helper.rb +29 -3
  140. data/tests/brightbox/requests/compute/image_tests.rb +17 -14
  141. data/tests/brightbox/requests/compute/interface_tests.rb +3 -2
  142. data/tests/brightbox/requests/compute/load_balancer_tests.rb +57 -11
  143. data/tests/brightbox/requests/compute/server_group_tests.rb +29 -22
  144. data/tests/brightbox/requests/compute/server_tests.rb +41 -22
  145. data/tests/brightbox/requests/compute/server_type_tests.rb +7 -6
  146. data/tests/brightbox/requests/compute/user_tests.rb +11 -16
  147. data/tests/brightbox/requests/compute/zone_tests.rb +7 -6
  148. data/tests/clodo/requests/compute/image_tests.rb +36 -0
  149. data/tests/clodo/requests/compute/server_tests.rb +152 -0
  150. data/tests/compute/helper.rb +1 -1
  151. data/tests/core/credential_tests.rb +2 -2
  152. data/tests/glesys/requests/compute/helper.rb +91 -66
  153. data/tests/glesys/requests/compute/ip_tests.rb +1 -1
  154. data/tests/glesys/requests/compute/server_tests.rb +5 -5
  155. data/tests/helpers/mock_helper.rb +2 -0
  156. data/tests/rackspace/models/dns/zone_tests.rb +14 -0
  157. data/tests/rackspace/models/{access_list_tests.rb → load_balancers/access_list_tests.rb} +0 -0
  158. data/tests/rackspace/models/{access_lists_tests.rb → load_balancers/access_lists_tests.rb} +0 -0
  159. data/tests/rackspace/models/{load_balancer_tests.rb → load_balancers/load_balancer_tests.rb} +25 -0
  160. data/tests/rackspace/models/{load_balancers_tests.rb → load_balancers/load_balancers_tests.rb} +0 -0
  161. data/tests/rackspace/models/{node_tests.rb → load_balancers/node_tests.rb} +0 -0
  162. data/tests/rackspace/models/{nodes_tests.rb → load_balancers/nodes_tests.rb} +0 -0
  163. data/tests/rackspace/models/{virtual_ip_tests.rb → load_balancers/virtual_ip_tests.rb} +0 -0
  164. data/tests/rackspace/models/{virtual_ips_tests.rb → load_balancers/virtual_ips_tests.rb} +0 -0
  165. data/tests/rackspace/requests/dns/dns_tests.rb +4 -2
  166. data/tests/rackspace/requests/load_balancers/error_page_tests.rb +31 -0
  167. data/tests/rackspace/requests/load_balancers/helper.rb +27 -11
  168. data/tests/rackspace/requests/load_balancers/load_balancer_tests.rb +4 -1
  169. data/tests/rackspace/requests/load_balancers/node_tests.rb +24 -25
  170. data/tests/slicehost/requests/compute/slice_tests.rb +2 -2
  171. data/tests/storm_on_demand/requests/compute/server_tests.rb +3 -3
  172. data/tests/vcloud/data/api_+_v1.0_+_admin_+_network_+_2 +110 -0
  173. data/tests/vcloud/data/api_+_v1.0_+_login +5 -0
  174. data/tests/vcloud/data/api_+_v1.0_+_network_+_1 +44 -0
  175. data/tests/vcloud/data/api_+_v1.0_+_network_+_2 +31 -0
  176. data/tests/vcloud/data/api_+_v1.0_+_org_+_1 +17 -0
  177. data/tests/vcloud/data/api_+_v1.0_+_vApp_+_vapp-1 +369 -0
  178. data/tests/vcloud/data/api_+_v1.0_+_vApp_+_vm-1 +139 -0
  179. data/tests/vcloud/data/api_+_v1.0_+_vApp_+_vm-2 +155 -0
  180. data/tests/vcloud/data/api_+_v1.0_+_vdc_+_1 +61 -0
  181. data/tests/vcloud/models/compute/conn_helper.rb +20 -0
  182. data/tests/vcloud/models/compute/network_tests.rb +65 -0
  183. data/tests/vcloud/models/compute/networks_tests.rb +42 -0
  184. data/tests/vcloud/models/compute/organization_tests.rb +13 -0
  185. data/tests/vcloud/models/compute/organizations_tests.rb +14 -0
  186. data/tests/vcloud/models/compute/server_tests.rb +136 -0
  187. data/tests/vcloud/models/compute/servers_tests.rb +10 -89
  188. data/tests/vcloud/models/compute/vapp_tests.rb +27 -0
  189. data/tests/vcloud/models/compute/vapps_tests.rb +17 -0
  190. data/tests/vcloud/models/compute/vdc_tests.rb +42 -0
  191. data/tests/vcloud/models/compute/vdcs_tests.rb +17 -0
  192. data/tests/vsphere/requests/compute/vm_clone_tests.rb +2 -6
  193. metadata +151 -55
@@ -4,10 +4,9 @@ module Fog
4
4
  class Real
5
5
  def delete_nodes(load_balancer_id, *node_ids)
6
6
  query_string = node_ids.collect { |node_id| "id=#{node_id}" }.join('&')
7
- puts query_string
8
7
  request(
9
8
  :expects => [200, 202],
10
- :path => "loadbalancers/#{load_balancer_id}/nodes?#{node_ids}",
9
+ :path => "loadbalancers/#{load_balancer_id}/nodes?#{query_string}",
11
10
  :method => 'DELETE'
12
11
  )
13
12
  end
@@ -0,0 +1,15 @@
1
+ module Fog
2
+ module Rackspace
3
+ class LoadBalancers
4
+ class Real
5
+ def get_error_page(load_balancer_id)
6
+ request(
7
+ :expects => 200,
8
+ :path => "loadbalancers/#{load_balancer_id}/errorpage",
9
+ :method => 'GET'
10
+ )
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -2,11 +2,17 @@ module Fog
2
2
  module Rackspace
3
3
  class LoadBalancers
4
4
  class Real
5
- def list_load_balancers
5
+ def list_load_balancers(options = {})
6
+ if options.has_key? :node_address
7
+ query_string = "?nodeaddress=#{options[:node_address]}"
8
+ else
9
+ query_string = ''
10
+ end
11
+
6
12
  request(
7
13
  :expects => 200,
8
14
  :method => 'GET',
9
- :path => 'loadbalancers.json'
15
+ :path => "loadbalancers.json?#{query_string}"
10
16
  )
11
17
  end
12
18
  end
@@ -0,0 +1,15 @@
1
+ module Fog
2
+ module Rackspace
3
+ class LoadBalancers
4
+ class Real
5
+ def remove_error_page(load_balancer_id)
6
+ request(
7
+ :expects => [200, 202],
8
+ :path => "loadbalancers/#{load_balancer_id}/errorpage",
9
+ :method => 'DELETE'
10
+ )
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,21 @@
1
+ module Fog
2
+ module Rackspace
3
+ class LoadBalancers
4
+ class Real
5
+ def set_error_page(load_balancer_id, content)
6
+ data = {
7
+ 'errorpage' => {
8
+ 'content' => content
9
+ }
10
+ }
11
+ request(
12
+ :body => MultiJson.encode(data),
13
+ :expects => [200, 202],
14
+ :path => "loadbalancers/#{load_balancer_id}/errorpage",
15
+ :method => 'PUT'
16
+ )
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -64,6 +64,8 @@ module Fog
64
64
  PORT = 443
65
65
  SCHEME = 'https'
66
66
 
67
+ attr_writer :default_organization_uri
68
+
67
69
  requires :vcloud_username, :vcloud_password, :vcloud_host
68
70
  recognizes :vcloud_port, :vcloud_scheme, :vcloud_path, :vcloud_default_vdc
69
71
  recognizes :provider # remove post deprecation
@@ -81,8 +83,12 @@ module Fog
81
83
  collection :servers
82
84
  model :task
83
85
  collection :tasks
86
+ model :vapp
87
+ collection :vapps
84
88
  model :vdc
85
89
  collection :vdcs
90
+ model :organization
91
+ collection :organizations
86
92
 
87
93
  request_path 'fog/vcloud/requests/compute'
88
94
  request :clone_vapp
@@ -101,6 +107,7 @@ module Fog
101
107
  request :get_network_ips
102
108
  request :get_network_extensions
103
109
  request :get_organization
110
+ request :get_server
104
111
  request :get_task
105
112
  request :get_task_list
106
113
  request :get_vapp
@@ -296,7 +303,6 @@ module Fog
296
303
  parser = Nokogiri::XML::SAX::PushParser.new(document)
297
304
  parser << response.body
298
305
  parser.finish
299
-
300
306
  response.body = document.body
301
307
  end
302
308
  end
@@ -7,8 +7,11 @@ module Fog
7
7
 
8
8
  model Fog::Vcloud::Compute::Catalog
9
9
 
10
+ attribute :organization_uri
11
+
10
12
  def all
11
- data = connection.get_organization(organization_uri).body[:Link].select { |link| link[:type] == "application/vnd.vmware.vcloud.catalog+xml" }
13
+ org_uri = self.organization_uri || connection.default_organization_uri
14
+ data = connection.get_organization(org_uri).body[:Link].select { |link| link[:type] == "application/vnd.vmware.vcloud.catalog+xml" }
12
15
  load(data)
13
16
  end
14
17
 
@@ -20,10 +23,6 @@ module Fog
20
23
  nil
21
24
  end
22
25
 
23
- def organization_uri
24
- @organization_uri ||= connection.default_organization_uri
25
- end
26
-
27
26
  def item_by_name(name)
28
27
  res = nil
29
28
  items = all.collect { |catalog| catalog.catalog_items }
@@ -0,0 +1,37 @@
1
+ module Fog
2
+ module Vcloud
3
+ class Compute
4
+ module Helpers
5
+ module Status
6
+ def friendly_status
7
+ load_unless_loaded!
8
+ case status
9
+ when '0'
10
+ 'creating'
11
+ when '8'
12
+ 'off'
13
+ when '4'
14
+ 'on'
15
+ else
16
+ 'unknown'
17
+ end
18
+ end
19
+
20
+ def on?
21
+ reload_status
22
+ status == '4'
23
+ end
24
+
25
+ def off?
26
+ reload_status
27
+ status == '8'
28
+ end
29
+
30
+ def reload_status
31
+ reload # always ensure we have the correct status
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -3,61 +3,25 @@ module Fog
3
3
  class Compute
4
4
  class Network < Fog::Vcloud::Model
5
5
 
6
- identity :href
6
+ identity :href, :aliases => :Href
7
7
 
8
- ignore_attributes :xmlns, :xmlns_xsi, :xmlns_xsd, :xmlns_i, :Configuration, :Id
8
+ ignore_attributes :xmlns, :xmlns_xsi, :xmlns_xsd, :xmlns_i, :Id
9
9
 
10
10
  attribute :name, :aliases => :Name
11
- #attribute :id, :aliases => :Id
12
- attribute :features, :aliases => :Features, :type => :array
13
- attribute :links, :aliases => :Link, :type => :array
14
- attribute :type
15
- attribute :gateway, :aliases => :GatewayAddress
16
- attribute :broadcast, :aliases => :BroadcastAddress
17
- attribute :address, :aliases => :Address
18
- attribute :extension_href, :aliases => :Href
19
- attribute :network_type, :aliases => :NetworkType
20
- attribute :vlan, :aliases => :Vlan
21
- attribute :friendly_name, :aliases => :FriendlyName
22
-
23
- def ips
24
- load_unless_loaded!
25
- Fog::Vcloud::Compute::Ips.new( :connection => connection,
26
- :href => links.detect { |link| link[:name] == "IP Addresses" }[:href] )
27
- end
28
11
 
29
- def save
30
- if @changed
31
- connection.configure_network( extension_href, _compose_network_data )
32
- end
33
- true
34
- end
35
-
36
- def reload
37
- super
38
- merge_attributes(extension_data.body)
39
- self
40
- end
12
+ attribute :description, :aliases => :Description
13
+ attribute :configuration, :aliases => :Configuration
14
+ attribute :provider_info, :aliases => :ProviderInfo
41
15
 
42
- private
43
-
44
- def extension_data
45
- connection.get_network_extensions( extensions_link[:href] )
46
- end
47
-
48
- def extensions_link
49
- links.detect { |link| link[:name] == name }
50
- end
16
+ attribute :links, :aliases => :Link, :type => :array
51
17
 
52
- def _compose_network_data
53
- {
54
- :id => id,
55
- :href => extension_href,
56
- :name => name,
57
- :address => address,
58
- :broadcast => broadcast,
59
- :gateway => gateway
60
- }
18
+ def parent_network
19
+ return nil if configuration[:ParentNetwork].nil?
20
+ @parent_network ||= Fog::Vcloud::Compute::Network.new(
21
+ :connection => connection,
22
+ :collection => Fog::Vcloud::Compute::Networks.new(:connection => connection),
23
+ :href => configuration[:ParentNetwork][:href]
24
+ )
61
25
  end
62
26
  end
63
27
  end
@@ -14,10 +14,19 @@ module Fog
14
14
 
15
15
  def all
16
16
  self.href = connection.default_vdc_href unless self.href
17
- check_href!("Vdc")
18
- if data = connection.get_vdc(href).body[:AvailableNetworks][:Network]
19
- load(data)
17
+ data = nil
18
+ if self.href =~ /\/vdc\//
19
+ check_href!("Vdc")
20
+ data = [connection.get_vdc(self.href).body[:AvailableNetworks][:Network]].flatten.compact
21
+ elsif self.href =~ /\/org\//
22
+ check_href!("Org")
23
+ links = (l=connection.get_organization(self.href).body[:Link]).is_a?(Array) ? l : [l].compact
24
+ data = links.select{|l| l[:type] == 'application/vnd.vmware.vcloud.network+xml' }
25
+ elsif self.href =~ /\/vApp\//
26
+ check_href!("Vapp")
27
+ data = [(connection.get_vapp(self.href).body[:NetworkConfigSection]||{})[:NetworkConfig]].flatten.compact.collect{|n| n[:Configuration][:ParentNetwork] unless n[:Configuration].nil? }.compact
20
28
  end
29
+ load([*data]) unless data.nil?
21
30
  end
22
31
 
23
32
  def get(uri)
@@ -0,0 +1,44 @@
1
+ module Fog
2
+ module Vcloud
3
+ class Compute
4
+ class Organization < Fog::Vcloud::Model
5
+
6
+ identity :href
7
+
8
+ ignore_attributes :xmlns, :xmlns_xsi, :xmlns_xsd
9
+
10
+ attribute :name
11
+ attribute :description, :aliases => :Description
12
+ attribute :type
13
+ attribute :full_name, :aliases => :FullName
14
+ attribute :other_links, :aliases => :Link
15
+
16
+ def networks
17
+ @networks ||= Fog::Vcloud::Compute::Networks.
18
+ new( :connection => connection,
19
+ :href => href )
20
+ end
21
+
22
+ def tasks
23
+ load_unless_loaded!
24
+ @tasks ||= Fog::Vcloud::Compute::Tasks.
25
+ new( :connection => connection,
26
+ :href => other_links.find{|l| l[:type] == 'application/vnd.vmware.vcloud.tasksList+xml'}[:href] )
27
+ end
28
+
29
+ def vdcs
30
+ @vdcs ||= Fog::Vcloud::Compute::Vdcs.
31
+ new( :connection => connection,
32
+ :href => href )
33
+ end
34
+
35
+ def catalogs
36
+ @catalogs ||= Fog::Vcloud::Compute::Catalogs.
37
+ new( :connection => connection,
38
+ :href => href )
39
+ end
40
+
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,29 @@
1
+ require 'fog/vcloud/models/compute/organization'
2
+
3
+ module Fog
4
+ module Vcloud
5
+ class Compute
6
+
7
+ class Organizations < Collection
8
+
9
+ model Fog::Vcloud::Compute::Organization
10
+
11
+ undef_method :create
12
+
13
+ def all
14
+ data = connection.login.body[:Org].select { |org| org[:type] == "application/vnd.vmware.vcloud.org+xml" }
15
+ data.each { |org| org.delete_if { |key, value| [:rel].include?(key) } }
16
+ load(data)
17
+ end
18
+
19
+ def get(uri)
20
+ if data = connection.get_organization(uri)
21
+ new(data.body)
22
+ end
23
+ rescue Fog::Errors::NotFound
24
+ nil
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,8 +1,11 @@
1
+ require 'fog/vcloud/models/compute/helpers/status'
1
2
  module Fog
2
3
  module Vcloud
3
4
  class Compute
4
5
  class Server < Fog::Vcloud::Model
5
6
 
7
+ include Fog::Vcloud::Compute::Helpers::Status
8
+
6
9
  identity :href, :aliases => :Href
7
10
 
8
11
  ignore_attributes :xmlns, :xmlns_i, :xmlns_xsi, :xmlns_xsd
@@ -10,49 +13,44 @@ module Fog
10
13
  attribute :type
11
14
  attribute :name
12
15
  attribute :status
13
- attribute :network_connections, :aliases => :NetworkConnectionSection, :squash => :NetworkConnection
14
- attribute :os, :aliases => :OperatingSystemSection
15
- attribute :virtual_hardware, :aliases => :VirtualHardwareSection
16
+ attribute :deployed, :type => :boolean
16
17
  attribute :description, :aliases => :Description
17
- attribute :storage_size, :aliases => :size
18
+
19
+ attribute :vapp_scoped_local_id, :aliases => :VAppScopedLocalId
20
+
21
+ attribute :network_connections, :aliases => :NetworkConnectionSection, :squash => :NetworkConnection
22
+ attribute :virtual_hardware, :aliases => :'ovf:VirtualHardwareSection', :squash => :'ovf:Item'
23
+
24
+ attribute :guest_customization, :aliases => :GuestCustomizationSection
25
+ attribute :operating_system, :aliases => :'ovf:OperatingSystemSection'
26
+
18
27
  attribute :links, :aliases => :Link, :type => :array
19
28
  attribute :tasks, :aliases => :Tasks, :type => :array
20
29
 
21
- attribute :vm_data, :aliases => :Children, :squash => :Vm
22
-
23
- def ip_address
30
+ def computer_name
24
31
  load_unless_loaded!
25
- vm[0][:NetworkConnectionSection][:NetworkConnection][:IpAddress]
32
+ self.guest_customization[:ComputerName]
26
33
  end
27
34
 
28
- def friendly_status
35
+ def os_desc
29
36
  load_unless_loaded!
30
- case status
31
- when '0'
32
- 'creating'
33
- when '8'
34
- 'off'
35
- when '4'
36
- 'on'
37
- else
38
- 'unkown'
39
- end
37
+ self.operating_system[:'ovf:Description']
40
38
  end
41
39
 
42
- def ready?
43
- reload_status # always ensure we have the correct status
44
- running_tasks = tasks && tasks.flatten.any? {|ti| ti.kind_of?(Hash) && ti[:status] == 'running' }
45
- status != '0' && !running_tasks # 0 is provisioning, and no running tasks
40
+ def os_type
41
+ load_unless_loaded!
42
+ self.operating_system[:vmw_osType]
46
43
  end
47
44
 
48
- def on?
49
- reload_status # always ensure we have the correct status
50
- status == '4'
45
+ def ip_addresses
46
+ load_unless_loaded!
47
+ self.network_connections.collect{|n| n[:IpAddress] }
51
48
  end
52
49
 
53
- def off?
50
+ def ready?
54
51
  reload_status # always ensure we have the correct status
55
- status == '8'
52
+ running_tasks = tasks && tasks.flatten.any? {|ti| ti.kind_of?(Hash) && ti[:status] == 'running' }
53
+ status != '0' && !running_tasks # 0 is provisioning, and no running tasks
56
54
  end
57
55
 
58
56
  def power_on
@@ -83,11 +81,6 @@ module Fog
83
81
  power_on
84
82
  end
85
83
 
86
- def vm
87
- load_unless_loaded!
88
- self.vm_data
89
- end
90
-
91
84
  def name=(new_name)
92
85
  attributes[:name] = new_name
93
86
  @changed = true
@@ -120,7 +113,7 @@ module Fog
120
113
 
121
114
  def disks
122
115
  disk_mess.map do |dm|
123
- { :number => dm[:"rasd:AddressOnParent"], :size => dm[:"rasd:VirtualQuantity"].to_i, :resource => dm[:"rasd:HostResource"] }
116
+ { :number => dm[:"rasd:AddressOnParent"].to_i, :size => dm[:"rasd:HostResource"][:vcloud_capacity].to_i, :resource => dm[:"rasd:HostResource"], :disk_data => dm }
124
117
  end
125
118
  end
126
119
 
@@ -187,12 +180,12 @@ module Fog
187
180
  vh[:'rasd:ResourceType'] == '17' &&
188
181
  vh[:'rasd:AddressOnParent'].to_s == @remove_disk.to_s
189
182
  end
190
- connection.configure_vm_disks(vm_href, data)
183
+ connection.configure_vm_disks(self.href, data)
191
184
  end
192
185
  if @disk_change == :added
193
186
  data = disk_mess
194
187
  data << @add_disk
195
- connection.configure_vm_disks(vm_href, data)
188
+ connection.configure_vm_disks(self.href, data)
196
189
  end
197
190
  if @name_changed || @description_changed
198
191
  edit_uri = links.select {|i| i[:rel] == 'edit'}
@@ -216,14 +209,6 @@ module Fog
216
209
  end
217
210
  alias :delete :destroy
218
211
 
219
- def vm_href
220
- load_unless_loaded!
221
- #require 'pp'
222
- #pp vm_data
223
- #vm_data[0][:Link].select {|v| v[:rel] == 'edit'}[0][:href]
224
- vm_data.kind_of?(Array)? vm_data[0][:href] : vm_data[:href]
225
- end
226
-
227
212
  private
228
213
 
229
214
  def reset_tracking
@@ -242,29 +227,24 @@ module Fog
242
227
  }
243
228
  end
244
229
 
245
- def virtual_hardware_section
246
- load_unless_loaded!
247
- vm[0][:"ovf:VirtualHardwareSection"][:"ovf:Item"]
248
- end
249
-
250
230
  def memory_mess
251
231
  load_unless_loaded!
252
- if virtual_hardware_section
253
- virtual_hardware_section.detect { |item| item[:"rasd:ResourceType"] == "4" }
232
+ if virtual_hardware
233
+ virtual_hardware.detect { |item| item[:"rasd:ResourceType"] == "4" }
254
234
  end
255
235
  end
256
236
 
257
237
  def cpu_mess
258
238
  load_unless_loaded!
259
- if virtual_hardware_section
260
- virtual_hardware_section.detect { |item| item[:"rasd:ResourceType"] == "3" }
239
+ if virtual_hardware
240
+ virtual_hardware.detect { |item| item[:"rasd:ResourceType"] == "3" }
261
241
  end
262
242
  end
263
243
 
264
244
  def disk_mess
265
245
  load_unless_loaded!
266
- if virtual_hardware_section
267
- virtual_hardware_section.select { |item| item[:"rasd:ResourceType"] == "17" }
246
+ if virtual_hardware
247
+ virtual_hardware.select { |item| item[:"rasd:ResourceType"] == "17" }
268
248
  else
269
249
  []
270
250
  end
@@ -284,7 +264,6 @@ module Fog
284
264
  def reload_status
285
265
  self.status = connection.get_vapp(href).body[:status]
286
266
  end
287
-
288
267
  end
289
268
  end
290
269
  end