fog 1.7.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (219) hide show
  1. data/.gitignore +2 -2
  2. data/README.md +9 -10
  3. data/Rakefile +15 -299
  4. data/changelog.txt +153 -0
  5. data/docs/about/contributing.markdown +1 -0
  6. data/docs/dns/index.markdown +1 -1
  7. data/docs/index.markdown +8 -3
  8. data/fog.gemspec +3 -3
  9. data/lib/fog.rb +0 -5
  10. data/lib/fog/aws/auto_scaling.rb +1 -1
  11. data/lib/fog/aws/cloud_watch.rb +1 -1
  12. data/lib/fog/aws/compute.rb +2 -1
  13. data/lib/fog/aws/dynamodb.rb +30 -64
  14. data/lib/fog/aws/elb.rb +1 -1
  15. data/lib/fog/aws/glacier.rb +1 -1
  16. data/lib/fog/aws/iam.rb +1 -0
  17. data/lib/fog/aws/models/auto_scaling/group.rb +1 -1
  18. data/lib/fog/aws/models/compute/server.rb +2 -0
  19. data/lib/fog/aws/models/compute/volume.rb +0 -1
  20. data/lib/fog/aws/models/iam/user.rb +1 -1
  21. data/lib/fog/aws/parsers/compute/describe_instances.rb +3 -1
  22. data/lib/fog/aws/parsers/compute/describe_reserved_instances_offerings.rb +1 -1
  23. data/lib/fog/aws/parsers/storage/delete_multiple_objects.rb +50 -0
  24. data/lib/fog/aws/rds.rb +2 -2
  25. data/lib/fog/aws/requests/compute/describe_availability_zones.rb +3 -0
  26. data/lib/fog/aws/requests/compute/describe_reserved_instances_offerings.rb +11 -8
  27. data/lib/fog/aws/requests/compute/modify_volume_attribute.rb +51 -0
  28. data/lib/fog/aws/requests/dns/change_resource_record_sets.rb +1 -0
  29. data/lib/fog/aws/requests/storage/delete_multiple_objects.rb +172 -0
  30. data/lib/fog/aws/signaturev4.rb +1 -1
  31. data/lib/fog/aws/sqs.rb +1 -1
  32. data/lib/fog/aws/storage.rb +2 -0
  33. data/lib/fog/bluebox/requests/compute/create_block.rb +1 -3
  34. data/lib/fog/brightbox/compute.rb +239 -84
  35. data/lib/fog/brightbox/models/compute/account.rb +9 -3
  36. data/lib/fog/brightbox/models/compute/server.rb +2 -1
  37. data/lib/fog/brightbox/models/compute/servers.rb +33 -1
  38. data/lib/fog/brightbox/oauth2.rb +164 -0
  39. data/lib/fog/brightbox/requests/compute/activate_console_server.rb +9 -2
  40. data/lib/fog/brightbox/requests/compute/add_listeners_load_balancer.rb +11 -2
  41. data/lib/fog/brightbox/requests/compute/add_nodes_load_balancer.rb +11 -2
  42. data/lib/fog/brightbox/requests/compute/add_servers_server_group.rb +9 -11
  43. data/lib/fog/brightbox/requests/compute/apply_to_firewall_policy.rb +11 -2
  44. data/lib/fog/brightbox/requests/compute/create_api_client.rb +11 -2
  45. data/lib/fog/brightbox/requests/compute/create_application.rb +11 -2
  46. data/lib/fog/brightbox/requests/compute/create_cloud_ip.rb +11 -1
  47. data/lib/fog/brightbox/requests/compute/create_firewall_policy.rb +13 -2
  48. data/lib/fog/brightbox/requests/compute/create_firewall_rule.rb +17 -2
  49. data/lib/fog/brightbox/requests/compute/create_image.rb +18 -2
  50. data/lib/fog/brightbox/requests/compute/create_load_balancer.rb +14 -2
  51. data/lib/fog/brightbox/requests/compute/create_server.rb +17 -2
  52. data/lib/fog/brightbox/requests/compute/create_server_group.rb +11 -2
  53. data/lib/fog/brightbox/requests/compute/destroy_api_client.rb +9 -2
  54. data/lib/fog/brightbox/requests/compute/destroy_application.rb +9 -2
  55. data/lib/fog/brightbox/requests/compute/destroy_cloud_ip.rb +9 -2
  56. data/lib/fog/brightbox/requests/compute/destroy_firewall_policy.rb +9 -2
  57. data/lib/fog/brightbox/requests/compute/destroy_firewall_rule.rb +9 -2
  58. data/lib/fog/brightbox/requests/compute/destroy_image.rb +9 -2
  59. data/lib/fog/brightbox/requests/compute/destroy_load_balancer.rb +9 -2
  60. data/lib/fog/brightbox/requests/compute/destroy_server.rb +9 -2
  61. data/lib/fog/brightbox/requests/compute/destroy_server_group.rb +9 -2
  62. data/lib/fog/brightbox/requests/compute/get_account.rb +7 -15
  63. data/lib/fog/brightbox/requests/compute/get_api_client.rb +9 -2
  64. data/lib/fog/brightbox/requests/compute/get_application.rb +9 -2
  65. data/lib/fog/brightbox/requests/compute/get_authenticated_user.rb +1 -3
  66. data/lib/fog/brightbox/requests/compute/get_cloud_ip.rb +9 -2
  67. data/lib/fog/brightbox/requests/compute/get_firewall_policy.rb +9 -2
  68. data/lib/fog/brightbox/requests/compute/get_firewall_rule.rb +9 -2
  69. data/lib/fog/brightbox/requests/compute/get_image.rb +9 -2
  70. data/lib/fog/brightbox/requests/compute/get_interface.rb +9 -2
  71. data/lib/fog/brightbox/requests/compute/get_load_balancer.rb +9 -2
  72. data/lib/fog/brightbox/requests/compute/get_scoped_account.rb +1 -5
  73. data/lib/fog/brightbox/requests/compute/get_server.rb +9 -2
  74. data/lib/fog/brightbox/requests/compute/get_server_group.rb +9 -2
  75. data/lib/fog/brightbox/requests/compute/get_server_type.rb +9 -2
  76. data/lib/fog/brightbox/requests/compute/get_user.rb +7 -15
  77. data/lib/fog/brightbox/requests/compute/get_zone.rb +9 -2
  78. data/lib/fog/brightbox/requests/compute/list_accounts.rb +6 -2
  79. data/lib/fog/brightbox/requests/compute/list_api_clients.rb +8 -2
  80. data/lib/fog/brightbox/requests/compute/list_applications.rb +8 -2
  81. data/lib/fog/brightbox/requests/compute/list_cloud_ips.rb +8 -2
  82. data/lib/fog/brightbox/requests/compute/list_firewall_policies.rb +8 -2
  83. data/lib/fog/brightbox/requests/compute/list_images.rb +8 -2
  84. data/lib/fog/brightbox/requests/compute/list_load_balancers.rb +8 -2
  85. data/lib/fog/brightbox/requests/compute/list_server_groups.rb +8 -2
  86. data/lib/fog/brightbox/requests/compute/list_server_types.rb +8 -2
  87. data/lib/fog/brightbox/requests/compute/list_servers.rb +8 -2
  88. data/lib/fog/brightbox/requests/compute/list_users.rb +8 -2
  89. data/lib/fog/brightbox/requests/compute/list_zones.rb +8 -2
  90. data/lib/fog/brightbox/requests/compute/map_cloud_ip.rb +11 -2
  91. data/lib/fog/brightbox/requests/compute/move_servers_server_group.rb +10 -12
  92. data/lib/fog/brightbox/requests/compute/remove_firewall_policy.rb +11 -2
  93. data/lib/fog/brightbox/requests/compute/remove_listeners_load_balancer.rb +11 -2
  94. data/lib/fog/brightbox/requests/compute/remove_nodes_load_balancer.rb +11 -2
  95. data/lib/fog/brightbox/requests/compute/remove_servers_server_group.rb +9 -10
  96. data/lib/fog/brightbox/requests/compute/reset_ftp_password_account.rb +22 -3
  97. data/lib/fog/brightbox/requests/compute/reset_ftp_password_scoped_account.rb +18 -0
  98. data/lib/fog/brightbox/requests/compute/reset_secret_api_client.rb +13 -1
  99. data/lib/fog/brightbox/requests/compute/reset_secret_application.rb +9 -2
  100. data/lib/fog/brightbox/requests/compute/shutdown_server.rb +9 -2
  101. data/lib/fog/brightbox/requests/compute/snapshot_server.rb +9 -2
  102. data/lib/fog/brightbox/requests/compute/start_server.rb +9 -2
  103. data/lib/fog/brightbox/requests/compute/stop_server.rb +9 -2
  104. data/lib/fog/brightbox/requests/compute/unmap_cloud_ip.rb +9 -2
  105. data/lib/fog/brightbox/requests/compute/update_account.rb +32 -34
  106. data/lib/fog/brightbox/requests/compute/update_api_client.rb +12 -2
  107. data/lib/fog/brightbox/requests/compute/update_application.rb +12 -2
  108. data/lib/fog/brightbox/requests/compute/update_cloud_ip.rb +13 -2
  109. data/lib/fog/brightbox/requests/compute/update_firewall_rule.rb +16 -1
  110. data/lib/fog/brightbox/requests/compute/update_image.rb +17 -2
  111. data/lib/fog/brightbox/requests/compute/update_load_balancer.rb +15 -2
  112. data/lib/fog/brightbox/requests/compute/update_scoped_account.rb +12 -19
  113. data/lib/fog/brightbox/requests/compute/update_server.rb +12 -2
  114. data/lib/fog/brightbox/requests/compute/update_server_group.rb +12 -2
  115. data/lib/fog/brightbox/requests/compute/update_user.rb +15 -2
  116. data/lib/fog/cloudstack/models/compute/server.rb +3 -1
  117. data/lib/fog/core.rb +1 -0
  118. data/lib/fog/core/connection.rb +1 -0
  119. data/lib/fog/google/storage.rb +13 -2
  120. data/lib/fog/libvirt/models/compute/server.rb +1 -0
  121. data/lib/fog/libvirt/requests/compute/list_domains.rb +2 -2
  122. data/lib/fog/openstack.rb +57 -58
  123. data/lib/fog/openstack/compute.rb +15 -14
  124. data/lib/fog/openstack/identity.rb +10 -2
  125. data/lib/fog/openstack/image.rb +1 -1
  126. data/lib/fog/openstack/models/compute/flavor.rb +5 -1
  127. data/lib/fog/openstack/models/compute/security_group.rb +1 -1
  128. data/lib/fog/openstack/models/compute/server.rb +5 -0
  129. data/lib/fog/openstack/models/identity/users.rb +1 -2
  130. data/lib/fog/openstack/requests/compute/create_flavor.rb +4 -1
  131. data/lib/fog/openstack/requests/compute/create_security_group.rb +1 -1
  132. data/lib/fog/openstack/requests/compute/get_limits.rb +93 -0
  133. data/lib/fog/openstack/requests/compute/list_tenants.rb +1 -0
  134. data/lib/fog/openstack/requests/compute/release_address.rb +13 -1
  135. data/lib/fog/openstack/requests/compute/reset_server_state.rb +24 -0
  136. data/lib/fog/openstack/requests/identity/create_role.rb +1 -1
  137. data/lib/fog/openstack/requests/identity/set_tenant.rb +21 -0
  138. data/lib/fog/openstack/volume.rb +2 -1
  139. data/lib/fog/rackspace/models/compute_v2/server.rb +27 -0
  140. data/lib/fog/rackspace/models/compute_v2/servers.rb +8 -0
  141. data/lib/fog/rackspace/models/dns/record.rb +14 -1
  142. data/lib/fog/rackspace/models/storage/file.rb +68 -2
  143. data/lib/fog/rackspace/requests/compute_v2/create_server.rb +3 -0
  144. data/lib/fog/version.rb +5 -0
  145. data/lib/fog/vsphere/compute.rb +74 -8
  146. data/lib/fog/vsphere/models/compute/cluster.rb +31 -0
  147. data/lib/fog/vsphere/models/compute/clusters.rb +26 -0
  148. data/lib/fog/vsphere/models/compute/datacenter.rb +35 -0
  149. data/lib/fog/vsphere/models/compute/datacenters.rb +23 -0
  150. data/lib/fog/vsphere/models/compute/datastore.rb +24 -0
  151. data/lib/fog/vsphere/models/compute/datastores.rb +25 -0
  152. data/lib/fog/vsphere/models/compute/folder.rb +28 -0
  153. data/lib/fog/vsphere/models/compute/folders.rb +27 -0
  154. data/lib/fog/vsphere/models/compute/interface.rb +39 -0
  155. data/lib/fog/vsphere/models/compute/interfaces.rb +33 -0
  156. data/lib/fog/vsphere/models/compute/network.rb +21 -0
  157. data/lib/fog/vsphere/models/compute/networks.rb +25 -0
  158. data/lib/fog/vsphere/models/compute/resource_pool.rb +23 -0
  159. data/lib/fog/vsphere/models/compute/resource_pools.rb +26 -0
  160. data/lib/fog/vsphere/models/compute/server.rb +78 -12
  161. data/lib/fog/vsphere/models/compute/servers.rb +16 -20
  162. data/lib/fog/vsphere/models/compute/template.rb +13 -0
  163. data/lib/fog/vsphere/models/compute/templates.rb +23 -0
  164. data/lib/fog/vsphere/models/compute/volume.rb +45 -0
  165. data/lib/fog/vsphere/models/compute/volumes.rb +33 -0
  166. data/lib/fog/vsphere/requests/compute/create_vm.rb +114 -0
  167. data/lib/fog/vsphere/requests/compute/get_cluster.rb +25 -0
  168. data/lib/fog/vsphere/requests/compute/get_datacenter.rb +29 -0
  169. data/lib/fog/vsphere/requests/compute/get_datastore.rb +25 -0
  170. data/lib/fog/vsphere/requests/compute/get_folder.rb +73 -0
  171. data/lib/fog/vsphere/requests/compute/get_network.rb +25 -0
  172. data/lib/fog/vsphere/requests/compute/get_resource_pool.rb +26 -0
  173. data/lib/fog/vsphere/requests/compute/get_virtual_machine.rb +62 -0
  174. data/lib/fog/vsphere/requests/compute/list_clusters.rb +37 -0
  175. data/lib/fog/vsphere/requests/compute/list_datacenters.rb +34 -0
  176. data/lib/fog/vsphere/requests/compute/list_datastores.rb +40 -0
  177. data/lib/fog/vsphere/requests/compute/list_folders.rb +45 -0
  178. data/lib/fog/vsphere/requests/compute/list_networks.rb +38 -0
  179. data/lib/fog/vsphere/requests/compute/list_resource_pools.rb +39 -0
  180. data/lib/fog/vsphere/requests/compute/list_virtual_machines.rb +132 -166
  181. data/lib/fog/vsphere/requests/compute/list_vm_interfaces.rb +52 -0
  182. data/lib/fog/vsphere/requests/compute/list_vm_volumes.rb +51 -0
  183. data/lib/fog/vsphere/requests/compute/vm_clone.rb +6 -8
  184. data/lib/fog/vsphere/requests/compute/vm_destroy.rb +1 -8
  185. data/lib/fog/vsphere/requests/compute/vm_reconfig_hardware.rb +1 -2
  186. data/lib/tasks/changelog_task.rb +98 -0
  187. data/lib/tasks/documentation_task.rb +155 -0
  188. data/lib/tasks/test_task.rb +46 -0
  189. data/tests/aws/models/iam/users_tests.rb +16 -2
  190. data/tests/aws/requests/auto_scaling/notification_configuration_tests.rb +1 -0
  191. data/tests/aws/requests/auto_scaling/tag_tests.rb +1 -0
  192. data/tests/aws/requests/compute/instance_tests.rb +2 -0
  193. data/tests/aws/requests/compute/volume_tests.rb +8 -0
  194. data/tests/aws/requests/storage/object_tests.rb +18 -1
  195. data/tests/aws/requests/storage/versioning_tests.rb +70 -0
  196. data/tests/brightbox/compute_tests.rb +96 -4
  197. data/tests/brightbox/models/compute/account_tests.rb +15 -0
  198. data/tests/brightbox/oauth2_tests.rb +103 -0
  199. data/tests/brightbox/requests/compute/account_tests.rb +9 -2
  200. data/tests/brightbox/requests/compute/interface_tests.rb +18 -4
  201. data/tests/dns/models/record_tests.rb +17 -3
  202. data/tests/openstack/requests/compute/address_tests.rb +22 -19
  203. data/tests/openstack/requests/compute/flavor_tests.rb +4 -2
  204. data/tests/openstack/requests/compute/limit_tests.rb +60 -0
  205. data/tests/openstack/requests/compute/quota_tests.rb +16 -3
  206. data/tests/openstack/requests/compute/security_group_tests.rb +1 -1
  207. data/tests/rackspace/models/compute_v2/servers_tests.rb +6 -0
  208. data/tests/rackspace/models/storage/file_tests.rb +172 -0
  209. data/tests/rackspace/requests/dns/helper.rb +12 -26
  210. data/tests/vsphere/compute_tests.rb +3 -3
  211. data/tests/vsphere/models/compute/server_tests.rb +1 -2
  212. data/tests/vsphere/requests/compute/list_virtual_machines_tests.rb +5 -13
  213. data/tests/vsphere/requests/compute/vm_clone_tests.rb +2 -2
  214. metadata +59 -11
  215. data/lib/fog/vsphere/requests/compute/datacenters.rb +0 -34
  216. data/lib/fog/vsphere/requests/compute/find_vm_by_ref.rb +0 -41
  217. data/lib/fog/vsphere/requests/compute/vm_create.rb +0 -97
  218. data/tests/vsphere/requests/compute/find_vm_by_ref_tests.rb +0 -26
  219. data/tests/vsphere/requests/compute/vm_create_tests.rb +0 -20
@@ -0,0 +1,52 @@
1
+ module Fog
2
+ module Compute
3
+ class Vsphere
4
+ class Real
5
+ # => VirtualE1000(
6
+ #addressType: "assigned",
7
+ #backing: VirtualEthernetCardNetworkBackingInfo(
8
+ # deviceName: "VM Network",
9
+ # dynamicProperty: [],
10
+ # network: Network("network-163"),
11
+ # useAutoDetect: false
12
+ #),
13
+ #connectable: VirtualDeviceConnectInfo(
14
+ # allowGuestControl: true,
15
+ # connected: true,
16
+ # dynamicProperty: [],
17
+ # startConnected: true,
18
+ # status: "ok"
19
+ #),
20
+ #controllerKey: 100,
21
+ #deviceInfo: Description(
22
+ # dynamicProperty: [],
23
+ # label: "Network adapter 1",
24
+ # summary: "VM Network"
25
+ #),
26
+ #dynamicProperty: [],
27
+ #key: 4000,
28
+ #macAddress: "00:50:56:a9:00:28",
29
+ #unitNumber: 7,
30
+ #
31
+ def list_vm_interfaces(vm_id)
32
+ get_vm_ref(vm_id).config.hardware.device.grep(RbVmomi::VIM::VirtualEthernetCard).map do |nic|
33
+ {
34
+ :name => nic.deviceInfo.label,
35
+ :mac => nic.macAddress,
36
+ :network => nic.backing.network.name,
37
+ :status => nic.connectable.status,
38
+ :summary => nic.deviceInfo.summary,
39
+ :type => nic.class,
40
+ }
41
+ end
42
+
43
+ end
44
+
45
+ end
46
+ class Mock
47
+ def list_vm_interfaces(vm_id)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,51 @@
1
+ module Fog
2
+ module Compute
3
+ class Vsphere
4
+ class Real
5
+ # [VirtualDisk(
6
+ # backing: VirtualDiskFlatVer2BackingInfo(
7
+ # contentId: "a172d19487e878e17d6b16ff2505d7eb",
8
+ # datastore: Datastore("datastore-162"),
9
+ # diskMode: "persistent",
10
+ # dynamicProperty: [],
11
+ # fileName: "[Storage1] rhel6-mfojtik/rhel6-mfojtik.vmdk",
12
+ # split: false,
13
+ # thinProvisioned: true,
14
+ # uuid: "6000C29c-a47d-4cd9-5249-c371de775f06",
15
+ # writeThrough: false
16
+ # ),
17
+ # capacityInKB: 8388608,
18
+ # controllerKey: 1000,
19
+ # deviceInfo: Description(
20
+ # dynamicProperty: [],
21
+ # label: "Hard disk 1",
22
+ # summary: "8,388,608 KB"
23
+ # ),
24
+ # dynamicProperty: [],
25
+ # key: 2001,
26
+ # shares: SharesInfo( dynamicProperty: [], level: "normal", shares: 1000 ),
27
+ # unitNumber: 1
28
+ #)]
29
+
30
+ def list_vm_volumes(vm_id)
31
+ get_vm_ref(vm_id).disks.map do |vol|
32
+ {
33
+ :id => vol.backing.uuid,
34
+ :thin => vol.backing.thinProvisioned,
35
+ :mode => vol.backing.diskMode,
36
+ :filename => vol.backing.fileName,
37
+ :datastore => (vol.backing.datastore.name rescue(nil)),
38
+ :size => vol.capacityInKB,
39
+ :name => vol.deviceInfo.label
40
+ }
41
+ end
42
+ end
43
+
44
+ end
45
+ class Mock
46
+ def list_vm_volumes(vm_id)
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -21,8 +21,8 @@ module Fog
21
21
  raise ArgumentError, "vm_clone path option must start with /Datacenters. Got: #{options['path']}"
22
22
  end
23
23
  dc_name = path_elements.shift
24
- if not self.datacenters.include? dc_name then
25
- raise ArgumentError, "Datacenter #{dc_name} does not exist, only datacenters #{self.datacenters.join(",")} are accessible."
24
+ if not datacenters.get dc_name then
25
+ raise ArgumentError, "Datacenter #{dc_name} does not exist, only datacenters #{datacenters.all.map(:name).join(",")} are accessible."
26
26
  end
27
27
  options
28
28
  end
@@ -75,10 +75,8 @@ module Fog
75
75
  # The template name. The remaining elements are the folders in the
76
76
  # datacenter.
77
77
  template_name = path_elements.pop
78
- # Make sure @datacenters is populated. We need the instances from the Hash keys.
79
- self.datacenters
80
- # Get the datacenter managed object from the hash
81
- dc = @datacenters[template_dc]
78
+
79
+ dc = find_raw_datacenter(template_dc)
82
80
  # Get the VM Folder (Group) efficiently
83
81
  vm_folder = dc.vmFolder
84
82
  # Walk the tree resetting the folder pointer as we go
@@ -195,8 +193,8 @@ module Fog
195
193
  # Option handling
196
194
  options = vm_clone_check_options(options)
197
195
  notfound = lambda { raise Fog::Compute::Vsphere::NotFound, "Could not find VM template" }
198
- vm_mob_ref = list_virtual_machines['virtual_machines'].find(notfound) do |vm|
199
- vm['name'] == options['path'].split("/")[-1]
196
+ list_virtual_machines.find(notfound) do |vm|
197
+ vm[:name] == options['path'].split("/")[-1]
200
198
  end
201
199
  {
202
200
  'vm_ref' => 'vm-123',
@@ -6,14 +6,7 @@ module Fog
6
6
  def vm_destroy(options = {})
7
7
  raise ArgumentError, "instance_uuid is a required parameter" unless options.has_key? 'instance_uuid'
8
8
 
9
- # Find the VM Object
10
- search_filter = { :uuid => options['instance_uuid'], 'vmSearch' => true, 'instanceUuid' => true }
11
- vm_mob_ref = @connection.searchIndex.FindAllByUuid(search_filter).first
12
-
13
- unless vm_mob_ref.kind_of? RbVmomi::VIM::VirtualMachine
14
- raise Fog::Vsphere::Errors::NotFound,
15
- "Could not find VirtualMachine with instance uuid #{options['instance_uuid']}"
16
- end
9
+ vm_mob_ref = get_vm_ref(options['instance_uuid'])
17
10
  task = vm_mob_ref.Destroy_Task
18
11
  task.wait_for_completion
19
12
  { 'task_state' => task.info.state }
@@ -5,8 +5,7 @@ module Fog
5
5
  def vm_reconfig_hardware(options = {})
6
6
  raise ArgumentError, "hardware_spec is a required parameter" unless options.has_key? 'hardware_spec'
7
7
  raise ArgumentError, "instance_uuid is a required parameter" unless options.has_key? 'instance_uuid'
8
- search_filter = { :uuid => options['instance_uuid'], 'vmSearch' => true, 'instanceUuid' => true }
9
- vm_mob_ref = @connection.searchIndex.FindAllByUuid(search_filter).first
8
+ vm_mob_ref = get_vm_by_ref(options['instance_uuid'])
10
9
  task = vm_mob_ref.ReconfigVM_Task(:spec => RbVmomi::VIM.VirtualMachineConfigSpec(options['hardware_spec']))
11
10
  task.wait_for_completion
12
11
  { 'task_state' => task.info.state }
@@ -0,0 +1,98 @@
1
+ require "rake"
2
+ require "rake/tasklib"
3
+
4
+ module Fog
5
+ module Rake
6
+ class ChangelogTask < ::Rake::TaskLib
7
+
8
+ def initialize
9
+ desc "Update the changelog since the last release"
10
+ task(:changelog) do
11
+ timestamp = Time.now.utc.strftime('%m/%d/%Y')
12
+ sha = `git log | head -1`.split(' ').last
13
+ changelog = ["#{Fog::VERSION} #{timestamp} #{sha}"]
14
+ changelog << ('=' * changelog[0].length)
15
+ changelog << ''
16
+
17
+ require 'multi_json'
18
+ github_repo_data = Fog::JSON.decode(Excon.get('https://api.github.com/repos/fog/fog').body)
19
+ data = github_repo_data.reject {|key, value| !['forks', 'open_issues', 'watchers'].include?(key)}
20
+ github_collaborator_data = Fog::JSON.decode(Excon.get('https://api.github.com/repos/fog/fog/collaborators').body)
21
+ data['collaborators'] = github_collaborator_data.length
22
+ rubygems_data = Fog::JSON.decode(Excon.get('https://rubygems.org/api/v1/gems/fog.json').body)
23
+ data['downloads'] = rubygems_data['downloads']
24
+ stats = []
25
+ for key in data.keys.sort
26
+ stats << "'#{key}' => #{data[key]}"
27
+ end
28
+ changelog << "Stats! { #{stats.join(', ')} }"
29
+ changelog << ''
30
+
31
+ last_sha = `cat changelog.txt | head -1`.split(' ').last
32
+ shortlog = `git shortlog #{last_sha}..HEAD`
33
+ changes = {}
34
+ committers = {}
35
+ for line in shortlog.split("\n")
36
+ if line =~ /^\S/
37
+ committer = line.split(' (', 2).first
38
+ committers[committer] = 0
39
+ elsif line =~ /^\s*((Merge.*)|(Release.*))?$/
40
+ # skip empty lines, Merge and Release commits
41
+ else
42
+ unless line[-1..-1] == '.'
43
+ line << '.'
44
+ end
45
+ line.lstrip!
46
+ line.gsub!(/^\[([^\]]*)\] /, '')
47
+ tag = $1 || 'misc'
48
+ changes[tag] ||= []
49
+ changes[tag] << (line << ' thanks ' << committer)
50
+ committers[committer] += 1
51
+ end
52
+ end
53
+
54
+ for committer, commits in committers.to_a.sort {|x,y| y[1] <=> x[1]}
55
+ if [
56
+ 'Aaron Suggs',
57
+ 'Brian Hartsock',
58
+ 'Christopher Oliver',
59
+ 'Decklin Foster',
60
+ 'Dylan Egan',
61
+ 'geemus',
62
+ 'Henry Addison',
63
+ 'Kevin Menard',
64
+ 'Lincoln Stoll',
65
+ 'Luqman Amjad',
66
+ 'Michael Zeng',
67
+ 'Nick Osborn',
68
+ 'nightshade427',
69
+ 'Patrick Debois',
70
+ 'Stepan G. Fedorov',
71
+ 'Wesley Beary'
72
+ ].include?(committer)
73
+ next
74
+ end
75
+ changelog << "MVP! #{committer}"
76
+ changelog << ''
77
+ break
78
+ end
79
+
80
+ for tag in changes.keys.sort
81
+ changelog << ('[' << tag << ']')
82
+ for commit in changes[tag]
83
+ changelog << (' ' << commit)
84
+ end
85
+ changelog << ''
86
+ end
87
+
88
+ old_changelog = File.read('changelog.txt')
89
+ File.open('changelog.txt', 'w') do |file|
90
+ file.write(changelog.join("\n"))
91
+ file.write("\n\n")
92
+ file.write(old_changelog)
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,155 @@
1
+ require "rake"
2
+ require "rake/tasklib"
3
+
4
+ module Fog
5
+ module Rake
6
+ class DocumentationTask < ::Rake::TaskLib
7
+ def initialize
8
+ task :docs do
9
+ Rake::Task[:supported_services_docs].invoke
10
+ Rake::Task[:upload_fog_io].invoke
11
+ Rake::Task[:upload_yardoc].invoke
12
+
13
+ # connect to storage provider
14
+ Fog.credential = :geemus
15
+ storage = Fog::Storage.new(:provider => 'AWS')
16
+ directory = storage.directories.new(:key => 'fog.io')
17
+ # write base index with redirect to new version
18
+ directory.files.create(
19
+ :body => redirecter('latest'),
20
+ :content_type => 'text/html',
21
+ :key => 'index.html',
22
+ :public => true
23
+ )
24
+
25
+ Formatador.display_line
26
+ end
27
+
28
+ task :supported_services_docs do
29
+ support, shared = {}, []
30
+ for key, values in Fog.services
31
+ unless values.length == 1
32
+ shared |= [key]
33
+ values.each do |value|
34
+ support[value] ||= {}
35
+ support[value][key] = '+'
36
+ end
37
+ else
38
+ value = values.first
39
+ support[value] ||= {}
40
+ support[value][:other] ||= []
41
+ support[value][:other] << key
42
+ end
43
+ end
44
+ shared.sort! {|x,y| x.to_s <=> y.to_s}
45
+ columns = [:provider] + shared + [:other]
46
+ data = []
47
+ for key in support.keys.sort {|x,y| x.to_s <=> y.to_s}
48
+ data << { :provider => key }.merge!(support[key])
49
+ end
50
+
51
+ table = ''
52
+ table << "<table border='1'>\n"
53
+
54
+ table << " <tr>"
55
+ for column in columns
56
+ table << "<th>#{column}</th>"
57
+ end
58
+ table << "</tr>\n"
59
+
60
+ for datum in data
61
+ table << " <tr>"
62
+ for column in columns
63
+ if value = datum[column]
64
+ case value
65
+ when Array
66
+ table << "<td>#{value.join(', ')}</td>"
67
+ when '+'
68
+ table << "<td style='text-align: center;'>#{value}</td>"
69
+ else
70
+ table << "<th>#{value}</th>"
71
+ end
72
+ else
73
+ table << "<td></td>"
74
+ end
75
+ end
76
+ table << "</tr>\n"
77
+ end
78
+
79
+ table << "</table>\n"
80
+
81
+ File.open('docs/about/supported_services.markdown', 'w') do |file|
82
+ file.puts <<-METADATA
83
+ ---
84
+ layout: default
85
+ title: Supported Services
86
+ ---
87
+
88
+ METADATA
89
+ file.puts(table)
90
+ end
91
+ end
92
+
93
+ desc "Builds the fog.io site content locally"
94
+ task :build_fog_io do
95
+ sh "jekyll docs docs/_site"
96
+ end
97
+
98
+ task :upload_fog_io => :build_fog_io do
99
+ # connect to storage provider
100
+ Fog.credential = :geemus
101
+ storage = Fog::Storage.new(:provider => 'AWS')
102
+ directory = storage.directories.new(:key => 'fog.io')
103
+
104
+ # write web page files to versioned 'folder'
105
+ for file_path in Dir.glob('docs/_site/**/*')
106
+ next if File.directory?(file_path)
107
+ file_name = file_path.gsub('docs/_site/', '')
108
+ key = '' << version << '/' << file_name
109
+ Formatador.redisplay(' ' * 128)
110
+ Formatador.redisplay("Uploading [bold]#{key}[/]")
111
+ if File.extname(file_name) == '.html'
112
+ # rewrite links with version
113
+ body = File.read(file_path)
114
+ body.gsub!(/vX.Y.Z/, 'v' << version)
115
+ body.gsub!(/='\//, %{='/} << version << '/')
116
+ body.gsub!(/="\//, %{="/} << version << '/')
117
+ content_type = 'text/html'
118
+ directory.files.create(
119
+ :body => redirecter(key),
120
+ :content_type => 'text/html',
121
+ :key => 'latest/' << file_name,
122
+ :public => true
123
+ )
124
+ else
125
+ body = File.open(file_path)
126
+ content_type = nil # leave it up to mime-types
127
+ end
128
+ directory.files.create(
129
+ :body => body,
130
+ :content_type => content_type,
131
+ :key => key,
132
+ :public => true
133
+ )
134
+ end
135
+ Formatador.redisplay(' ' * 128)
136
+ Formatador.redisplay("Uploaded docs/_site\n")
137
+ end
138
+
139
+ def redirecter(path)
140
+ redirecter = <<-HTML
141
+ <!doctype html>
142
+ <head>
143
+ <title>fog</title>
144
+ <meta http-equiv="REFRESH" content="0;url=http://fog.io/#{path}">
145
+ </head>
146
+ <body>
147
+ <a href="http://fog.io/#{path}">redirecting to lastest (#{path})</a>
148
+ </body>
149
+ </html>
150
+ HTML
151
+ end
152
+ end
153
+ end
154
+ end
155
+ end
@@ -0,0 +1,46 @@
1
+ require "rake"
2
+ require "rake/tasklib"
3
+
4
+ module Fog
5
+ module Rake
6
+ class TestTask < ::Rake::TaskLib
7
+
8
+ def initialize
9
+ desc "Run the mocked tests"
10
+ task :test do
11
+ Rake::Task[:mock_tests].invoke
12
+ end
13
+
14
+ task :mock_tests do
15
+ tests(true)
16
+ end
17
+
18
+ task :real_tests do
19
+ tests(false)
20
+ end
21
+ end
22
+
23
+ def tests(mocked)
24
+ Formatador.display_line
25
+ start = Time.now.to_i
26
+ threads = []
27
+ Thread.main[:results] = []
28
+ Fog.providers.each do |key, value|
29
+ threads << Thread.new do
30
+ Thread.main[:results] << {
31
+ :provider => value,
32
+ :success => sh("export FOG_MOCK=#{mocked} && bundle exec shindont +#{key}")
33
+ }
34
+ end
35
+ end
36
+ threads.each do |thread|
37
+ thread.join
38
+ end
39
+ Formatador.display_table(Thread.main[:results].sort {|x,y| x[:provider] <=> y[:provider]})
40
+ Formatador.display_line("[bold]FOG_MOCK=#{mocked}[/] tests completed in [bold]#{Time.now.to_i - start}[/] seconds")
41
+ Formatador.display_line
42
+ end
43
+
44
+ end
45
+ end
46
+ end