fog 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. data/README.rdoc +2 -9
  2. data/Rakefile +3 -2
  3. data/docs/_layouts/default.html +13 -13
  4. data/docs/about/contributing.markdown +1 -1
  5. data/docs/about/getting_started.markdown +28 -3
  6. data/docs/dns/index.markdown +4 -4
  7. data/docs/index.markdown +2 -10
  8. data/docs/public/css/fog.css +14 -1
  9. data/docs/storage/index.markdown +2 -2
  10. data/fog.gemspec +6 -5
  11. data/lib/fog.rb +1 -1
  12. data/lib/fog/aws.rb +26 -1
  13. data/lib/fog/aws/auto_scaling.rb +3 -1
  14. data/lib/fog/aws/cloud_formation.rb +3 -0
  15. data/lib/fog/aws/cloud_watch.rb +17 -1
  16. data/lib/fog/aws/compute.rb +50 -18
  17. data/lib/fog/aws/elb.rb +4 -2
  18. data/lib/fog/aws/emr.rb +133 -0
  19. data/lib/fog/aws/models/cloud_watch/alarm.rb +12 -0
  20. data/lib/fog/aws/models/cloud_watch/alarm_data.rb +39 -0
  21. data/lib/fog/aws/models/cloud_watch/alarm_datum.rb +66 -0
  22. data/lib/fog/aws/models/cloud_watch/alarm_histories.rb +18 -0
  23. data/lib/fog/aws/models/cloud_watch/alarm_history.rb +16 -0
  24. data/lib/fog/aws/models/cloud_watch/alarms.rb +30 -0
  25. data/lib/fog/aws/models/compute/addresses.rb +1 -1
  26. data/lib/fog/aws/models/compute/key_pairs.rb +1 -1
  27. data/lib/fog/aws/models/compute/security_groups.rb +1 -1
  28. data/lib/fog/aws/models/compute/server.rb +4 -2
  29. data/lib/fog/aws/models/compute/servers.rb +1 -1
  30. data/lib/fog/aws/models/compute/snapshots.rb +1 -1
  31. data/lib/fog/aws/models/compute/spot_request.rb +21 -4
  32. data/lib/fog/aws/models/compute/spot_requests.rb +45 -1
  33. data/lib/fog/aws/models/compute/volumes.rb +1 -1
  34. data/lib/fog/aws/models/elb/load_balancer.rb +2 -0
  35. data/lib/fog/aws/models/storage/file.rb +1 -1
  36. data/lib/fog/aws/parsers/cdn/get_invalidation_list.rb +0 -1
  37. data/lib/fog/aws/parsers/cloud_formation/update_stack.rb +19 -0
  38. data/lib/fog/aws/parsers/cloud_watch/delete_alarms.rb +26 -0
  39. data/lib/fog/aws/parsers/cloud_watch/describe_alarm_history.rb +40 -0
  40. data/lib/fog/aws/parsers/cloud_watch/describe_alarms.rb +73 -0
  41. data/lib/fog/aws/parsers/cloud_watch/describe_alarms_for_metric.rb +71 -0
  42. data/lib/fog/aws/parsers/cloud_watch/disable_alarm_actions.rb +26 -0
  43. data/lib/fog/aws/parsers/cloud_watch/enable_alarm_actions.rb +26 -0
  44. data/lib/fog/aws/parsers/cloud_watch/get_metric_statistics.rb +1 -0
  45. data/lib/fog/aws/parsers/cloud_watch/put_metric_alarm.rb +26 -0
  46. data/lib/fog/aws/parsers/cloud_watch/set_alarm_state.rb +26 -0
  47. data/lib/fog/aws/parsers/compute/spot_instance_requests.rb +2 -2
  48. data/lib/fog/aws/parsers/emr/add_instance_groups.rb +28 -0
  49. data/lib/fog/aws/parsers/emr/add_job_flow_steps.rb +17 -0
  50. data/lib/fog/aws/parsers/emr/describe_job_flows.rb +140 -0
  51. data/lib/fog/aws/parsers/emr/modify_instance_groups.rb +17 -0
  52. data/lib/fog/aws/parsers/emr/run_job_flow.rb +19 -0
  53. data/lib/fog/aws/parsers/emr/set_termination_protection.rb +17 -0
  54. data/lib/fog/aws/parsers/emr/terminate_job_flows.rb +17 -0
  55. data/lib/fog/aws/rds.rb +3 -1
  56. data/lib/fog/aws/requests/cloud_formation/create_stack.rb +6 -0
  57. data/lib/fog/aws/requests/cloud_formation/update_stack.rb +62 -0
  58. data/lib/fog/aws/requests/cloud_watch/delete_alarms.rb +30 -0
  59. data/lib/fog/aws/requests/cloud_watch/describe_alarm_history.rb +33 -0
  60. data/lib/fog/aws/requests/cloud_watch/describe_alarms.rb +38 -0
  61. data/lib/fog/aws/requests/cloud_watch/describe_alarms_for_metric.rb +39 -0
  62. data/lib/fog/aws/requests/cloud_watch/disable_alarm_actions.rb +30 -0
  63. data/lib/fog/aws/requests/cloud_watch/enable_alarm_actions.rb +30 -0
  64. data/lib/fog/aws/requests/cloud_watch/put_metric_alarm.rb +84 -0
  65. data/lib/fog/aws/requests/cloud_watch/set_alarm_state.rb +31 -0
  66. data/lib/fog/aws/requests/compute/authorize_security_group_ingress.rb +141 -36
  67. data/lib/fog/aws/requests/compute/create_snapshot.rb +2 -3
  68. data/lib/fog/aws/requests/compute/create_tags.rb +5 -3
  69. data/lib/fog/aws/requests/compute/create_volume.rb +0 -1
  70. data/lib/fog/aws/requests/compute/delete_security_group.rb +25 -0
  71. data/lib/fog/aws/requests/compute/delete_tags.rb +3 -4
  72. data/lib/fog/aws/requests/compute/describe_addresses.rb +2 -2
  73. data/lib/fog/aws/requests/compute/describe_availability_zones.rb +5 -2
  74. data/lib/fog/aws/requests/compute/describe_images.rb +6 -9
  75. data/lib/fog/aws/requests/compute/describe_instances.rb +17 -8
  76. data/lib/fog/aws/requests/compute/describe_key_pairs.rb +2 -2
  77. data/lib/fog/aws/requests/compute/describe_regions.rb +2 -2
  78. data/lib/fog/aws/requests/compute/describe_reserved_instances.rb +1 -1
  79. data/lib/fog/aws/requests/compute/describe_security_groups.rb +2 -2
  80. data/lib/fog/aws/requests/compute/describe_snapshots.rb +7 -5
  81. data/lib/fog/aws/requests/compute/describe_volumes.rb +5 -4
  82. data/lib/fog/aws/requests/compute/modify_image_attribute.rb +32 -0
  83. data/lib/fog/aws/requests/compute/modify_instance_attribute.rb +1 -1
  84. data/lib/fog/aws/requests/compute/purchase_reserved_instances_offering.rb +1 -1
  85. data/lib/fog/aws/requests/compute/register_image.rb +0 -1
  86. data/lib/fog/aws/requests/compute/revoke_security_group_ingress.rb +41 -29
  87. data/lib/fog/aws/requests/compute/run_instances.rb +1 -2
  88. data/lib/fog/aws/requests/elb/create_load_balancer.rb +1 -1
  89. data/lib/fog/aws/requests/elb/create_load_balancer_listeners.rb +1 -1
  90. data/lib/fog/aws/requests/elb/deregister_instances_from_load_balancer.rb +1 -1
  91. data/lib/fog/aws/requests/elb/describe_instance_health.rb +2 -2
  92. data/lib/fog/aws/requests/elb/describe_load_balancers.rb +3 -3
  93. data/lib/fog/aws/requests/elb/register_instances_with_load_balancer.rb +2 -2
  94. data/lib/fog/aws/requests/emr/add_instance_groups.rb +46 -0
  95. data/lib/fog/aws/requests/emr/add_job_flow_steps.rb +49 -0
  96. data/lib/fog/aws/requests/emr/describe_job_flows.rb +108 -0
  97. data/lib/fog/aws/requests/emr/modify_instance_groups.rb +40 -0
  98. data/lib/fog/aws/requests/emr/run_job_flow.rb +106 -0
  99. data/lib/fog/aws/requests/emr/set_termination_protection.rb +39 -0
  100. data/lib/fog/aws/requests/emr/terminate_job_flows.rb +37 -0
  101. data/lib/fog/aws/requests/iam/get_server_certificate.rb +5 -7
  102. data/lib/fog/aws/requests/iam/upload_server_certificate.rb +1 -0
  103. data/lib/fog/aws/requests/simpledb/get_attributes.rb +2 -2
  104. data/lib/fog/aws/requests/simpledb/select.rb +1 -1
  105. data/lib/fog/aws/requests/storage/copy_object.rb +1 -1
  106. data/lib/fog/aws/requests/storage/get_object_url.rb +2 -2
  107. data/lib/fog/aws/requests/storage/hash_to_acl.rb +35 -25
  108. data/lib/fog/aws/ses.rb +1 -1
  109. data/lib/fog/aws/simpledb.rb +2 -0
  110. data/lib/fog/aws/sns.rb +3 -1
  111. data/lib/fog/aws/sqs.rb +4 -2
  112. data/lib/fog/aws/storage.rb +12 -3
  113. data/lib/fog/bin.rb +1 -1
  114. data/lib/fog/bin/aws.rb +8 -4
  115. data/lib/fog/bin/bluebox.rb +2 -2
  116. data/lib/fog/bin/brightbox.rb +1 -1
  117. data/lib/fog/bin/dnsimple.rb +1 -1
  118. data/lib/fog/bin/dnsmadeeasy.rb +1 -1
  119. data/lib/fog/bin/ecloud.rb +1 -1
  120. data/lib/fog/bin/glesys.rb +1 -1
  121. data/lib/fog/bin/go_grid.rb +1 -1
  122. data/lib/fog/bin/google.rb +1 -1
  123. data/lib/fog/bin/libvirt.rb +1 -1
  124. data/lib/fog/bin/linode.rb +2 -2
  125. data/lib/fog/bin/local.rb +1 -1
  126. data/lib/fog/bin/new_servers.rb +1 -1
  127. data/lib/fog/bin/ninefold.rb +2 -2
  128. data/lib/fog/bin/openstack.rb +1 -1
  129. data/lib/fog/bin/rackspace.rb +3 -3
  130. data/lib/fog/bin/slicehost.rb +1 -1
  131. data/lib/fog/bin/stormondemand.rb +1 -1
  132. data/lib/fog/bin/virtual_box.rb +1 -1
  133. data/lib/fog/bin/vmfusion.rb +1 -1
  134. data/lib/fog/bin/voxel.rb +1 -1
  135. data/lib/fog/bin/zerigo.rb +1 -1
  136. data/lib/fog/brightbox/models/compute/account.rb +1 -1
  137. data/lib/fog/compute/models/server.rb +1 -2
  138. data/lib/fog/core/attributes.rb +5 -5
  139. data/lib/fog/core/connection.rb +1 -1
  140. data/lib/fog/core/deprecation.rb +2 -2
  141. data/lib/fog/core/logger.rb +8 -3
  142. data/lib/fog/core/mock.rb +4 -0
  143. data/lib/fog/core/provider.rb +7 -2
  144. data/lib/fog/core/service.rb +8 -2
  145. data/lib/fog/dnsmadeeasy/models/dns/record.rb +3 -2
  146. data/lib/fog/dynect/dns.rb +25 -3
  147. data/lib/fog/ecloud/compute.rb +2 -6
  148. data/lib/fog/go_grid/requests/compute/grid_server_power.rb +1 -1
  149. data/lib/fog/google/models/storage/file.rb +1 -1
  150. data/lib/fog/google/requests/storage/get_object_url.rb +2 -2
  151. data/lib/fog/google/storage.rb +1 -1
  152. data/lib/fog/libvirt/models/compute/uri.rb +7 -3
  153. data/lib/fog/linode/models/compute/server.rb +10 -0
  154. data/lib/fog/ninefold/models/storage/file.rb +8 -6
  155. data/lib/fog/ninefold/models/storage/files.rb +3 -2
  156. data/lib/fog/ninefold/requests/storage/head_namespace.rb +20 -0
  157. data/lib/fog/ninefold/storage.rb +4 -2
  158. data/lib/fog/openstack.rb +4 -3
  159. data/lib/fog/openstack/compute.rb +8 -5
  160. data/lib/fog/openstack/models/compute/server.rb +10 -1
  161. data/lib/fog/openstack/requests/compute/create_server.rb +6 -8
  162. data/lib/fog/rackspace/load_balancers.rb +1 -0
  163. data/lib/fog/rackspace/models/dns/callback.rb +1 -1
  164. data/lib/fog/rackspace/models/dns/record.rb +1 -1
  165. data/lib/fog/rackspace/models/dns/zone.rb +1 -1
  166. data/lib/fog/slicehost/dns.rb +1 -0
  167. data/lib/fog/slicehost/models/dns/record.rb +7 -3
  168. data/lib/fog/slicehost/models/dns/zone.rb +1 -1
  169. data/lib/fog/slicehost/parsers/dns/create_record.rb +8 -2
  170. data/lib/fog/slicehost/parsers/dns/get_record.rb +17 -5
  171. data/lib/fog/slicehost/parsers/dns/get_records.rb +10 -2
  172. data/lib/fog/slicehost/requests/dns/get_record.rb +1 -1
  173. data/lib/fog/slicehost/requests/dns/get_records.rb +7 -8
  174. data/lib/fog/slicehost/requests/dns/update_record.rb +43 -0
  175. data/lib/fog/storm_on_demand/models/compute/balancers.rb +1 -1
  176. data/lib/fog/storm_on_demand/models/compute/configs.rb +1 -1
  177. data/lib/fog/storm_on_demand/models/compute/images.rb +1 -1
  178. data/lib/fog/storm_on_demand/models/compute/servers.rb +1 -1
  179. data/lib/fog/storm_on_demand/models/compute/templates.rb +1 -1
  180. data/lib/fog/terremark/vcloud.rb +1 -1
  181. data/lib/fog/vsphere/compute.rb +40 -23
  182. data/lib/fog/vsphere/models/compute/server.rb +1 -0
  183. data/lib/fog/vsphere/requests/compute/list_virtual_machines.rb +36 -4
  184. data/lib/fog/zerigo/dns.rb +14 -3
  185. data/lib/fog/zerigo/models/dns/record.rb +1 -1
  186. data/lib/fog/zerigo/models/dns/records.rb +5 -0
  187. data/lib/fog/zerigo/models/dns/zones.rb +2 -2
  188. data/lib/fog/zerigo/requests/dns/count_hosts.rb +20 -1
  189. data/lib/fog/zerigo/requests/dns/count_zones.rb +12 -1
  190. data/lib/fog/zerigo/requests/dns/create_host.rb +67 -1
  191. data/lib/fog/zerigo/requests/dns/create_zone.rb +44 -1
  192. data/lib/fog/zerigo/requests/dns/delete_host.rb +19 -0
  193. data/lib/fog/zerigo/requests/dns/delete_zone.rb +17 -0
  194. data/lib/fog/zerigo/requests/dns/find_hosts.rb +22 -1
  195. data/lib/fog/zerigo/requests/dns/get_host.rb +18 -1
  196. data/lib/fog/zerigo/requests/dns/get_zone.rb +19 -2
  197. data/lib/fog/zerigo/requests/dns/get_zone_stats.rb +23 -0
  198. data/lib/fog/zerigo/requests/dns/list_hosts.rb +20 -1
  199. data/lib/fog/zerigo/requests/dns/list_zones.rb +15 -0
  200. data/lib/fog/zerigo/requests/dns/update_host.rb +20 -1
  201. data/lib/fog/zerigo/requests/dns/update_zone.rb +20 -1
  202. data/tests/aws/models/cloud_watch/alarm_data_tests.rb +42 -0
  203. data/tests/aws/models/cloud_watch/alarm_history_tests.rb +22 -0
  204. data/tests/aws/models/compute/security_group_tests.rb +15 -10
  205. data/tests/aws/models/elb/model_tests.rb +4 -4
  206. data/tests/aws/requests/cloud_formation/stack_tests.rb +14 -0
  207. data/tests/aws/requests/cloud_watch/list_metrics_test.rb +5 -5
  208. data/tests/aws/requests/compute/image_tests.rb +33 -2
  209. data/tests/aws/requests/compute/instance_tests.rb +16 -1
  210. data/tests/aws/requests/compute/security_group_tests.rb +251 -32
  211. data/tests/aws/requests/compute/tag_tests.rb +42 -2
  212. data/tests/aws/requests/emr/helper.rb +172 -0
  213. data/tests/aws/requests/emr/instance_group_tests.rb +106 -0
  214. data/tests/aws/requests/emr/job_flow_tests.rb +88 -0
  215. data/tests/aws/requests/iam/server_certificate_tests.rb +20 -7
  216. data/tests/aws/requests/storage/bucket_tests.rb +82 -54
  217. data/tests/aws/requests/storage/hash_to_acl_tests.rb +173 -0
  218. data/tests/aws/requests/storage/object_tests.rb +44 -24
  219. data/tests/brightbox/requests/compute/helper.rb +15 -6
  220. data/tests/core/attribute_tests.rb +29 -0
  221. data/tests/core/mocking_tests.rb +60 -0
  222. data/tests/dns/models/record_tests.rb +4 -2
  223. data/tests/dns/models/records_tests.rb +4 -2
  224. data/tests/dns/models/zone_tests.rb +3 -1
  225. data/tests/dns/models/zones_tests.rb +4 -2
  226. data/tests/helper.rb +4 -0
  227. data/tests/rackspace/requests/dns/dns_tests.rb +16 -12
  228. data/tests/rackspace/requests/dns/records_tests.rb +13 -11
  229. data/tests/slicehost/requests/dns/dns_tests.rb +58 -11
  230. data/tests/vsphere/compute_tests.rb +18 -10
  231. data/tests/vsphere/requests/compute/vm_clone_tests.rb +1 -1
  232. metadata +214 -221
@@ -39,7 +39,7 @@ module Fog
39
39
  Fog::DNS::Slicehost::Records.new(
40
40
  :zone => self,
41
41
  :connection => connection
42
- )
42
+ ).all
43
43
  end
44
44
  end
45
45
 
@@ -11,9 +11,15 @@ module Fog
11
11
 
12
12
  def end_element(name)
13
13
  case name
14
- when 'zone-id', 'ttl', 'id'
14
+ when 'zone_id'
15
+ @response["zone-id"] = value.to_i
16
+ when 'record_type'
17
+ @response["record-type"] = value
18
+ when 'ttl', 'id'
15
19
  @response[name] = value.to_i
16
- when 'record-type', 'name', 'data', 'active', 'aux'
20
+ when 'value'
21
+ @response["data"] = value
22
+ when 'name', 'data', 'active', 'aux'
17
23
  @response[name] = value
18
24
  end
19
25
  end
@@ -6,15 +6,27 @@ module Fog
6
6
  class GetRecord < Fog::Parsers::Base
7
7
 
8
8
  def reset
9
+ @record = {}
9
10
  @response = { }
10
11
  end
11
12
 
12
13
  def end_element(name)
13
14
  case name
14
- when 'zone-id', 'ttl'
15
- @response[name] = value.to_i
16
- when 'record-type', 'name', 'data', 'active', 'aux'
17
- @response[name] = value
15
+ when 'id'
16
+ @record["id"] = value.to_i
17
+ when 'zone-id'
18
+ @record["zone_id"] = value.to_i
19
+ when 'record-type'
20
+ @record["record_type"] = value
21
+ when 'ttl'
22
+ @record[name] = value.to_i
23
+ when 'data'
24
+ @record["value"] = value
25
+ when 'name', 'active', 'aux'
26
+ @record[name] = value
27
+ when 'record'
28
+ @response = @record
29
+ @record = {}
18
30
  end
19
31
  end
20
32
 
@@ -23,4 +35,4 @@ module Fog
23
35
  end
24
36
  end
25
37
  end
26
- end
38
+ end
@@ -12,9 +12,17 @@ module Fog
12
12
 
13
13
  def end_element(name)
14
14
  case name
15
- when 'zone-id', 'ttl'
15
+ when 'id'
16
+ @record["id"] = value.to_i
17
+ when 'zone-id'
18
+ @record["zone_id"] = value.to_i
19
+ when 'record-type'
20
+ @record["record_type"] = value
21
+ when 'ttl'
16
22
  @record[name] = value.to_i
17
- when 'record-type', 'name', 'data', 'active', 'aux'
23
+ when 'data'
24
+ @record["value"] = value
25
+ when 'name', 'active', 'aux'
18
26
  @record[name] = value
19
27
  when 'record'
20
28
  @response['records'] << @record
@@ -21,7 +21,7 @@ module Fog
21
21
  request(
22
22
  :expects => 200,
23
23
  :method => 'GET',
24
- :parser => Fog::Parsers::DNS::Slicehost::GetRecords.new,
24
+ :parser => Fog::Parsers::DNS::Slicehost::GetRecord.new,
25
25
  :path => "records/#{record_id}.xml"
26
26
  )
27
27
  end
@@ -10,14 +10,13 @@ module Fog
10
10
  # ==== Returns
11
11
  # * response<~Excon::Response>:
12
12
  # * body<~Array>:
13
- # * 'addresses'<~Array> - Ip addresses for the slice
14
- # * 'backup-id'<~Integer> - Id of backup slice was booted from
15
- # * 'flavor_id'<~Integer> - Id of flavor slice was booted from
16
- # * 'id'<~Integer> - Id of the slice
17
- # * 'image-id'<~Integer> - Id of image slice was booted from
18
- # * 'name'<~String> - Name of the slice
19
- # * 'progress'<~Integer> - Progress of current action, in percentage
20
- # * 'status'<~String> - Current status of the slice
13
+ # * 'name'<~String> - Record NAME field (e.g. "example.org." or "www")
14
+ # * 'data'<~String> - Data contained by the record (e.g. an IP address, for A records)
15
+ # * 'record_type'<~String> - Type of record (A, CNAME, TXT, etc)
16
+ # * 'aux'<~String> - Aux data for the record, for those types which have it (e.g. TXT)
17
+ # * 'zone_id'<~Integer> - zone ID to which this record belongs
18
+ # * 'active'<~String> - whether this record is active in the Slicehost DNS (Y for yes, N for no)
19
+ # * 'ttl'<~Integer> - TTL in seconds
21
20
  def get_records
22
21
  request(
23
22
  :expects => 200,
@@ -0,0 +1,43 @@
1
+ module Fog
2
+ module DNS
3
+ class Slicehost
4
+ class Real
5
+
6
+ #require 'fog/slicehost/parsers/dns/update_record'
7
+
8
+ # Get an individual DNS record from the specified zone
9
+ #
10
+ # ==== Returns
11
+ # * response<~Excon::Response>:
12
+ # * body<~Hash>:
13
+ # * 'record_type'<~String> - type of DNS record to create (A, CNAME, etc)
14
+ # * 'zone_id'<~Integer> - ID of the zone to update
15
+ # * 'name'<~String> - host name this DNS record is for
16
+ # * 'data'<~String> - data for the DNS record (ie for an A record, the IP address)
17
+ # * 'ttl'<~Integer> - time to live in seconds
18
+ # * 'active'<~String> - whether this record is active or not ('Y' or 'N')
19
+ # * 'aux'<~String> - extra data required by the record
20
+ def update_record(record_id, record_type, zone_id, name, data, options = {})
21
+ optional_tags= ''
22
+ options.each { |option, value|
23
+ case option
24
+ when :ttl
25
+ optional_tags+= "<ttl type='integer'>#{value}</ttl>"
26
+ when :active
27
+ optional_tags+= "<active>#{value}</active>"
28
+ when :aux
29
+ optional_tags+= "<aux>#{value}</aux>"
30
+ end
31
+ }
32
+ request(
33
+ :body => %Q{<?xml version="1.0" encoding="UTF-8"?><record><record_type>#{record_type}</record_type><zone_id type="integer">#{zone_id}</zone_id><name>#{name}</name><data>#{data}</data>#{optional_tags}</record>},
34
+ :expects => 200,
35
+ :method => 'PUT',
36
+ :path => "records/#{record_id}.xml"
37
+ )
38
+ end
39
+
40
+ end
41
+ end
42
+ end
43
+ end
@@ -10,7 +10,7 @@ module Fog
10
10
  model Fog::Compute::StormOnDemand::Balancer
11
11
 
12
12
  def all
13
- data = connection.list_balancers.body['loadbalancers']
13
+ data = connection.list_balancers.body['items']
14
14
  load(data)
15
15
  end
16
16
 
@@ -10,7 +10,7 @@ module Fog
10
10
  model Fog::Compute::StormOnDemand::Config
11
11
 
12
12
  def all
13
- data = connection.list_configs.body['configs']
13
+ data = connection.list_configs.body['items']
14
14
  load(data)
15
15
  end
16
16
 
@@ -10,7 +10,7 @@ module Fog
10
10
  model Fog::Compute::StormOnDemand::Image
11
11
 
12
12
  def all
13
- data = connection.list_images.body['images']
13
+ data = connection.list_images.body['items']
14
14
  load(data)
15
15
  end
16
16
 
@@ -10,7 +10,7 @@ module Fog
10
10
  model Fog::Compute::StormOnDemand::Server
11
11
 
12
12
  def all
13
- data = connection.list_servers.body['servers']
13
+ data = connection.list_servers.body['items']
14
14
  load(data)
15
15
  end
16
16
 
@@ -10,7 +10,7 @@ module Fog
10
10
  model Fog::Compute::StormOnDemand::Template
11
11
 
12
12
  def all
13
- data = connection.list_templates.body['templates']
13
+ data = connection.list_templates.body['items']
14
14
  load(data)
15
15
  end
16
16
 
@@ -15,7 +15,7 @@ module Fog
15
15
  extend Fog::Terremark::Shared
16
16
 
17
17
  def self.new(options={})
18
- Fog::Logger.warning("Fog::Terremark::Vcloud is deprecated, to be replaced with Vcloud 1.0 someday/maybe [light_black](#{caller.first})[/]")
18
+ Fog::Logger.deprecation("Fog::Terremark::Vcloud is deprecated, to be replaced with Vcloud 1.0 someday/maybe [light_black](#{caller.first})[/]")
19
19
 
20
20
  unless @required
21
21
  shared_requires
@@ -29,36 +29,52 @@ module Fog
29
29
  attr_reader :vsphere_server
30
30
  attr_reader :vsphere_username
31
31
 
32
+ ATTR_TO_PROP = {
33
+ :id => 'config.instanceUuid',
34
+ :name => 'name',
35
+ :uuid => 'config.uuid',
36
+ :instance_uuid => 'config.instanceUuid',
37
+ :hostname => 'summary.guest.hostName',
38
+ :operatingsystem => 'summary.guest.guestFullName',
39
+ :ipaddress => 'guest.ipAddress',
40
+ :power_state => 'runtime.powerState',
41
+ :connection_state => 'runtime.connectionState',
42
+ :hypervisor => 'runtime.host',
43
+ :tools_state => 'guest.toolsStatus',
44
+ :tools_version => 'guest.toolsVersionStatus',
45
+ :is_a_template => 'config.template',
46
+ }
47
+
32
48
  # Utility method to convert a VMware managed object into an attribute hash.
33
49
  # This should only really be necessary for the real class.
34
50
  # This method is expected to be called by the request methods
35
51
  # in order to massage VMware Managed Object References into Attribute Hashes.
36
52
  def convert_vm_mob_ref_to_attr_hash(vm_mob_ref)
37
53
  return nil unless vm_mob_ref
38
- # A cloning VM doesn't have a configuration yet. Unfortuantely we just get
39
- # a RunTime exception.
40
- begin
41
- is_ready = vm_mob_ref.config ? true : false
42
- rescue RuntimeError
43
- is_ready = nil
54
+
55
+ props = vm_mob_ref.collect! *ATTR_TO_PROP.values.uniq
56
+ # NOTE: Object.tap is in 1.8.7 and later.
57
+ # Here we create the hash object that this method returns, but first we need
58
+ # to add a few more attributes that require additional calls to the vSphere
59
+ # API. The hypervisor name and mac_addresses attributes may not be available
60
+ # so we need catch any exceptions thrown during lookup and set them to nil.
61
+ #
62
+ # The use of the "tap" method here is a convience, it allows us to update the
63
+ # hash object without expliclty returning the hash at the end of the method.
64
+ Hash[ATTR_TO_PROP.map { |k,v| [k.to_s, props[v]] }].tap do |attrs|
65
+ attrs['id'] ||= vm_mob_ref._ref
66
+ attrs['mo_ref'] = vm_mob_ref._ref
67
+ # The name method "magically" appears after a VM is ready and
68
+ # finished cloning.
69
+ if attrs['hypervisor'].kind_of?(RbVmomi::VIM::HostSystem) then
70
+ # If it's not ready, set the hypervisor to nil
71
+ attrs['hypervisor'] = attrs['hypervisor'].name rescue nil
72
+ end
73
+ # This inline rescue catches any standard error. While a VM is
74
+ # cloning, a call to the macs method will throw and NoMethodError
75
+ attrs['mac_addresses'] = vm_mob_ref.macs rescue nil
76
+ attrs['path'] = get_folder_path(vm_mob_ref.parent)
44
77
  end
45
- {
46
- 'id' => is_ready ? vm_mob_ref.config.instanceUuid : vm_mob_ref._ref,
47
- 'mo_ref' => vm_mob_ref._ref,
48
- 'name' => vm_mob_ref.name,
49
- 'uuid' => is_ready ? vm_mob_ref.config.uuid : nil,
50
- 'instance_uuid' => is_ready ? vm_mob_ref.config.instanceUuid : nil,
51
- 'hostname' => vm_mob_ref.summary.guest.hostName,
52
- 'operatingsystem' => vm_mob_ref.summary.guest.guestFullName,
53
- 'ipaddress' => vm_mob_ref.summary.guest.ipAddress,
54
- 'power_state' => vm_mob_ref.runtime.powerState,
55
- 'connection_state' => vm_mob_ref.runtime.connectionState,
56
- 'hypervisor' => vm_mob_ref.runtime.host ? vm_mob_ref.runtime.host.name : nil,
57
- 'tools_state' => vm_mob_ref.summary.guest.toolsStatus,
58
- 'tools_version' => vm_mob_ref.summary.guest.toolsVersionStatus,
59
- 'mac_addresses' => is_ready ? vm_mob_ref.macs : nil,
60
- 'is_a_template' => is_ready ? vm_mob_ref.config.template : nil
61
- }
62
78
  end
63
79
 
64
80
  end
@@ -68,6 +84,7 @@ module Fog
68
84
  include Shared
69
85
 
70
86
  def initialize(options={})
87
+ require 'rbvmomi'
71
88
  @vsphere_username = options[:vsphere_username]
72
89
  @vsphere_password = 'REDACTED'
73
90
  @vsphere_server = options[:vsphere_server]
@@ -33,6 +33,7 @@ module Fog
33
33
  attribute :is_a_template
34
34
  attribute :connection_state
35
35
  attribute :mo_ref
36
+ attribute :path
36
37
 
37
38
  def start(options = {})
38
39
  requires :instance_uuid
@@ -34,6 +34,7 @@ module Fog
34
34
  { 'virtual_machines' => virtual_machines }
35
35
  end
36
36
 
37
+
37
38
  # NOTE: This is a private instance method required by the vm_clone
38
39
  # request. It's very hard to get the Managed Object Reference
39
40
  # of a Template because we can't search for it by instance_uuid
@@ -45,19 +46,50 @@ module Fog
45
46
  datacenters = @connection.rootFolder.children.find_all do |child|
46
47
  child.kind_of? RbVmomi::VIM::Datacenter
47
48
  end
48
- # Next, look in the "vmFolder" of each data center:
49
+ # Next, search the "vmFolder" inventory of each data center:
49
50
  datacenters.each do |dc|
50
- dc.vmFolder.children.each do |vm|
51
- virtual_machines << vm
51
+ inventory = dc.vmFolder.inventory( 'VirtualMachine' => :all )
52
+ virtual_machines << find_all_in_inventory(inventory, :type => RbVmomi::VIM::VirtualMachine, :property => 'name' )
53
+ end
54
+
55
+ virtual_machines.flatten
56
+ end
57
+
58
+ def find_all_in_inventory(inventory, properties = { :type => RbVmomi::VIM::VirtualMachine, :property => nil } )
59
+ results = Array.new
60
+
61
+ inventory.each do |k,v|
62
+
63
+ # If we have a VMware folder we need to traverse the directory
64
+ # to ensure we pick VMs inside folders. So we do a bit of recursion
65
+ # here.
66
+ results << find_all_in_inventory(v) if k.is_a? RbVmomi::VIM::Folder
67
+
68
+ if v[0].is_a? properties[:type]
69
+ if properties[:property].nil?
70
+ results << v[0]
71
+ else
72
+ results << v[1][properties[:property]]
73
+ end
52
74
  end
53
75
  end
54
- virtual_machines
76
+ results.flatten
55
77
  end
56
78
 
79
+ def get_folder_path(folder, root = nil)
80
+ if ( not folder.methods.include?('parent') ) or ( folder == root )
81
+ return
82
+ end
83
+ "#{get_folder_path(folder.parent)}/#{folder.name}"
84
+ end
57
85
  end
58
86
 
59
87
  class Mock
60
88
 
89
+ def get_folder_path(folder, root = nil)
90
+ nil
91
+ end
92
+
61
93
  def list_virtual_machines(options = {})
62
94
  case options['instance_uuid']
63
95
  when nil
@@ -34,7 +34,7 @@ module Fog
34
34
 
35
35
  def self.data
36
36
  @data ||= Hash.new do |hash, key|
37
- hash[key] = {}
37
+ hash[key] = key == :zones ? [] : {}
38
38
  end
39
39
  end
40
40
 
@@ -48,13 +48,24 @@ module Fog
48
48
  end
49
49
 
50
50
  def data
51
- self.class.data[@zerigo_email]
51
+ self.class.data
52
52
  end
53
53
 
54
54
  def reset_data
55
- self.class.data.delete(@zerigo_email)
55
+ self.class.reset
56
56
  end
57
57
 
58
+ def find_by_zone_id(zone_id)
59
+ self.data[:zones].find { |z| z['id'] == zone_id }
60
+ end
61
+
62
+ def find_by_domain(domain)
63
+ self.data[:zones].find { |z| z['domain'] == domain }
64
+ end
65
+
66
+ def find_host(host_id)
67
+ self.data[:zones].collect { |z| z['hosts'].find { |h| h['id'] == host_id } }.compact.first
68
+ end
58
69
  end
59
70
 
60
71
  class Real
@@ -48,7 +48,7 @@ module Fog
48
48
  connection.create_host(@zone.id, type, value, options)
49
49
  else
50
50
  options[:host_type] = type
51
- options[:data] = data
51
+ options[:data] = value
52
52
  connection.update_host(identity, options)
53
53
  end
54
54
  merge_attributes(data.body)
@@ -34,6 +34,11 @@ module Fog
34
34
  super({ :zone => zone }.merge!(attributes))
35
35
  end
36
36
 
37
+ def find(fqdn)
38
+ hosts = connection.find_hosts(fqdn, zone.id).body['hosts']
39
+ hosts.collect { |host| new(host) }
40
+ end
41
+
37
42
  end
38
43
 
39
44
  end
@@ -14,8 +14,8 @@ module Fog
14
14
  load(data)
15
15
  end
16
16
 
17
- def get(zone_id)
18
- data = connection.get_zone(zone_id).body
17
+ def get(zone_id_or_domain)
18
+ data = connection.get_zone(zone_id_or_domain).body
19
19
  zone = new(data)
20
20
  zone.records.load(data['hosts'])
21
21
  zone