fog-vcloud-director 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (315) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +11 -0
  3. data/.gitignore +17 -0
  4. data/.hound.yml +2 -0
  5. data/.rubocop.yml +240 -0
  6. data/.ruby-gemset +1 -0
  7. data/.travis.yml +15 -0
  8. data/Gemfile +4 -0
  9. data/LICENSE.md +20 -0
  10. data/README.md +962 -0
  11. data/Rakefile +19 -0
  12. data/fog-vcloud-director.gemspec +31 -0
  13. data/lib/fog/vcloud_director.rb +1 -0
  14. data/lib/fog/vcloud_director/compute.rb +916 -0
  15. data/lib/fog/vcloud_director/core.rb +69 -0
  16. data/lib/fog/vcloud_director/generators/compute/compose_common.rb +122 -0
  17. data/lib/fog/vcloud_director/generators/compute/compose_vapp.rb +25 -0
  18. data/lib/fog/vcloud_director/generators/compute/create_snapshot.rb +25 -0
  19. data/lib/fog/vcloud_director/generators/compute/customization.rb +105 -0
  20. data/lib/fog/vcloud_director/generators/compute/disks.rb +186 -0
  21. data/lib/fog/vcloud_director/generators/compute/edge_gateway_service_configuration.rb +243 -0
  22. data/lib/fog/vcloud_director/generators/compute/instantiate_vapp_template_params.rb +30 -0
  23. data/lib/fog/vcloud_director/generators/compute/metadata.rb +104 -0
  24. data/lib/fog/vcloud_director/generators/compute/org_vdc_network.rb +88 -0
  25. data/lib/fog/vcloud_director/generators/compute/recompose_vapp.rb +34 -0
  26. data/lib/fog/vcloud_director/generators/compute/vapp.rb +28 -0
  27. data/lib/fog/vcloud_director/generators/compute/vm.rb +32 -0
  28. data/lib/fog/vcloud_director/generators/compute/vm_network.rb +119 -0
  29. data/lib/fog/vcloud_director/models/compute/catalog.rb +22 -0
  30. data/lib/fog/vcloud_director/models/compute/catalog_item.rb +30 -0
  31. data/lib/fog/vcloud_director/models/compute/catalog_items.rb +33 -0
  32. data/lib/fog/vcloud_director/models/compute/catalogs.rb +30 -0
  33. data/lib/fog/vcloud_director/models/compute/custom_field.rb +18 -0
  34. data/lib/fog/vcloud_director/models/compute/custom_fields.rb +67 -0
  35. data/lib/fog/vcloud_director/models/compute/disk.rb +53 -0
  36. data/lib/fog/vcloud_director/models/compute/disks.rb +44 -0
  37. data/lib/fog/vcloud_director/models/compute/media.rb +26 -0
  38. data/lib/fog/vcloud_director/models/compute/medias.rb +75 -0
  39. data/lib/fog/vcloud_director/models/compute/network.rb +25 -0
  40. data/lib/fog/vcloud_director/models/compute/networks.rb +62 -0
  41. data/lib/fog/vcloud_director/models/compute/organization.rb +37 -0
  42. data/lib/fog/vcloud_director/models/compute/organizations.rb +28 -0
  43. data/lib/fog/vcloud_director/models/compute/tag.rb +31 -0
  44. data/lib/fog/vcloud_director/models/compute/tags.rb +41 -0
  45. data/lib/fog/vcloud_director/models/compute/task.rb +55 -0
  46. data/lib/fog/vcloud_director/models/compute/tasks.rb +36 -0
  47. data/lib/fog/vcloud_director/models/compute/template_vm.rb +52 -0
  48. data/lib/fog/vcloud_director/models/compute/template_vms.rb +41 -0
  49. data/lib/fog/vcloud_director/models/compute/vapp.rb +144 -0
  50. data/lib/fog/vcloud_director/models/compute/vapp_template.rb +26 -0
  51. data/lib/fog/vcloud_director/models/compute/vapp_templates.rb +40 -0
  52. data/lib/fog/vcloud_director/models/compute/vapps.rb +40 -0
  53. data/lib/fog/vcloud_director/models/compute/vdc.rb +45 -0
  54. data/lib/fog/vcloud_director/models/compute/vdcs.rb +37 -0
  55. data/lib/fog/vcloud_director/models/compute/vm.rb +197 -0
  56. data/lib/fog/vcloud_director/models/compute/vm_customization.rb +40 -0
  57. data/lib/fog/vcloud_director/models/compute/vm_customizations.rb +29 -0
  58. data/lib/fog/vcloud_director/models/compute/vm_network.rb +27 -0
  59. data/lib/fog/vcloud_director/models/compute/vm_networks.rb +19 -0
  60. data/lib/fog/vcloud_director/models/compute/vms.rb +46 -0
  61. data/lib/fog/vcloud_director/parsers/compute/disks.rb +53 -0
  62. data/lib/fog/vcloud_director/parsers/compute/metadata.rb +61 -0
  63. data/lib/fog/vcloud_director/parsers/compute/network.rb +104 -0
  64. data/lib/fog/vcloud_director/parsers/compute/vm.rb +86 -0
  65. data/lib/fog/vcloud_director/parsers/compute/vm_customization.rb +55 -0
  66. data/lib/fog/vcloud_director/parsers/compute/vm_network.rb +107 -0
  67. data/lib/fog/vcloud_director/parsers/compute/vm_parser_helper.rb +62 -0
  68. data/lib/fog/vcloud_director/parsers/compute/vms.rb +68 -0
  69. data/lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb +37 -0
  70. data/lib/fog/vcloud_director/query.rb +59 -0
  71. data/lib/fog/vcloud_director/requests/compute/delete_catalog_item.rb +22 -0
  72. data/lib/fog/vcloud_director/requests/compute/delete_catalog_item_metadata_item_metadata.rb +25 -0
  73. data/lib/fog/vcloud_director/requests/compute/delete_disk.rb +60 -0
  74. data/lib/fog/vcloud_director/requests/compute/delete_disk_metadata_item_metadata.rb +25 -0
  75. data/lib/fog/vcloud_director/requests/compute/delete_logout.rb +18 -0
  76. data/lib/fog/vcloud_director/requests/compute/delete_media.rb +122 -0
  77. data/lib/fog/vcloud_director/requests/compute/delete_media_metadata_item_metadata.rb +25 -0
  78. data/lib/fog/vcloud_director/requests/compute/delete_network.rb +62 -0
  79. data/lib/fog/vcloud_director/requests/compute/delete_shadow_vm.rb +30 -0
  80. data/lib/fog/vcloud_director/requests/compute/delete_vapp.rb +59 -0
  81. data/lib/fog/vcloud_director/requests/compute/delete_vapp_metadata_item_metadata.rb +30 -0
  82. data/lib/fog/vcloud_director/requests/compute/delete_vapp_template.rb +27 -0
  83. data/lib/fog/vcloud_director/requests/compute/delete_vapp_template_metadata_item_metadata.rb +26 -0
  84. data/lib/fog/vcloud_director/requests/compute/get_allocated_ip_addresses.rb +25 -0
  85. data/lib/fog/vcloud_director/requests/compute/get_catalog.rb +63 -0
  86. data/lib/fog/vcloud_director/requests/compute/get_catalog_item.rb +48 -0
  87. data/lib/fog/vcloud_director/requests/compute/get_catalog_item_metadata.rb +25 -0
  88. data/lib/fog/vcloud_director/requests/compute/get_catalog_item_metadata_item_metadata.rb +26 -0
  89. data/lib/fog/vcloud_director/requests/compute/get_catalog_metadata.rb +25 -0
  90. data/lib/fog/vcloud_director/requests/compute/get_catalog_metadata_item_metadata.rb +26 -0
  91. data/lib/fog/vcloud_director/requests/compute/get_catalogs_from_query.rb +94 -0
  92. data/lib/fog/vcloud_director/requests/compute/get_control_access_params_catalog.rb +26 -0
  93. data/lib/fog/vcloud_director/requests/compute/get_control_access_params_vapp.rb +25 -0
  94. data/lib/fog/vcloud_director/requests/compute/get_cpu_rasd_item.rb +65 -0
  95. data/lib/fog/vcloud_director/requests/compute/get_current_session.rb +83 -0
  96. data/lib/fog/vcloud_director/requests/compute/get_disk.rb +123 -0
  97. data/lib/fog/vcloud_director/requests/compute/get_disk_metadata.rb +25 -0
  98. data/lib/fog/vcloud_director/requests/compute/get_disk_metadata_item_metadata.rb +26 -0
  99. data/lib/fog/vcloud_director/requests/compute/get_disk_owner.rb +70 -0
  100. data/lib/fog/vcloud_director/requests/compute/get_disks_from_query.rb +94 -0
  101. data/lib/fog/vcloud_director/requests/compute/get_disks_rasd_items_list.rb +90 -0
  102. data/lib/fog/vcloud_director/requests/compute/get_edge_gateway.rb +109 -0
  103. data/lib/fog/vcloud_director/requests/compute/get_entity.rb +38 -0
  104. data/lib/fog/vcloud_director/requests/compute/get_execute_query.rb +736 -0
  105. data/lib/fog/vcloud_director/requests/compute/get_groups_from_query.rb +95 -0
  106. data/lib/fog/vcloud_director/requests/compute/get_guest_customization_system_section_vapp.rb +69 -0
  107. data/lib/fog/vcloud_director/requests/compute/get_guest_customization_system_section_vapp_template.rb +25 -0
  108. data/lib/fog/vcloud_director/requests/compute/get_href.rb +21 -0
  109. data/lib/fog/vcloud_director/requests/compute/get_lease_settings_section_vapp.rb +59 -0
  110. data/lib/fog/vcloud_director/requests/compute/get_lease_settings_section_vapp_template.rb +25 -0
  111. data/lib/fog/vcloud_director/requests/compute/get_media.rb +111 -0
  112. data/lib/fog/vcloud_director/requests/compute/get_media_drives_rasd_items_list.rb +92 -0
  113. data/lib/fog/vcloud_director/requests/compute/get_media_metadata.rb +25 -0
  114. data/lib/fog/vcloud_director/requests/compute/get_media_metadata_item_metadata.rb +26 -0
  115. data/lib/fog/vcloud_director/requests/compute/get_media_owner.rb +70 -0
  116. data/lib/fog/vcloud_director/requests/compute/get_medias_from_query.rb +94 -0
  117. data/lib/fog/vcloud_director/requests/compute/get_memory_rasd_item.rb +64 -0
  118. data/lib/fog/vcloud_director/requests/compute/get_metadata.rb +41 -0
  119. data/lib/fog/vcloud_director/requests/compute/get_network.rb +67 -0
  120. data/lib/fog/vcloud_director/requests/compute/get_network_cards_items_list.rb +70 -0
  121. data/lib/fog/vcloud_director/requests/compute/get_network_complete.rb +78 -0
  122. data/lib/fog/vcloud_director/requests/compute/get_network_config_section_vapp.rb +61 -0
  123. data/lib/fog/vcloud_director/requests/compute/get_network_config_section_vapp_template.rb +25 -0
  124. data/lib/fog/vcloud_director/requests/compute/get_network_connection_system_section_vapp.rb +68 -0
  125. data/lib/fog/vcloud_director/requests/compute/get_network_connection_system_section_vapp_template.rb +25 -0
  126. data/lib/fog/vcloud_director/requests/compute/get_network_metadata.rb +25 -0
  127. data/lib/fog/vcloud_director/requests/compute/get_network_metadata_item_metadata.rb +26 -0
  128. data/lib/fog/vcloud_director/requests/compute/get_network_section_vapp.rb +25 -0
  129. data/lib/fog/vcloud_director/requests/compute/get_network_section_vapp_template.rb +25 -0
  130. data/lib/fog/vcloud_director/requests/compute/get_operating_system_section.rb +59 -0
  131. data/lib/fog/vcloud_director/requests/compute/get_org_settings.rb +38 -0
  132. data/lib/fog/vcloud_director/requests/compute/get_org_vdc_gateways.rb +83 -0
  133. data/lib/fog/vcloud_director/requests/compute/get_organization.rb +100 -0
  134. data/lib/fog/vcloud_director/requests/compute/get_organization_metadata.rb +25 -0
  135. data/lib/fog/vcloud_director/requests/compute/get_organization_metadata_item_metadata.rb +28 -0
  136. data/lib/fog/vcloud_director/requests/compute/get_organizations.rb +52 -0
  137. data/lib/fog/vcloud_director/requests/compute/get_organizations_from_query.rb +95 -0
  138. data/lib/fog/vcloud_director/requests/compute/get_product_sections_vapp.rb +25 -0
  139. data/lib/fog/vcloud_director/requests/compute/get_product_sections_vapp_template.rb +26 -0
  140. data/lib/fog/vcloud_director/requests/compute/get_request.rb +19 -0
  141. data/lib/fog/vcloud_director/requests/compute/get_runtime_info_section_type.rb +57 -0
  142. data/lib/fog/vcloud_director/requests/compute/get_serial_ports_items_list.rb +25 -0
  143. data/lib/fog/vcloud_director/requests/compute/get_shadow_vm.rb +24 -0
  144. data/lib/fog/vcloud_director/requests/compute/get_snapshot_section.rb +55 -0
  145. data/lib/fog/vcloud_director/requests/compute/get_startup_section.rb +64 -0
  146. data/lib/fog/vcloud_director/requests/compute/get_supported_systems_info.rb +239 -0
  147. data/lib/fog/vcloud_director/requests/compute/get_supported_versions.rb +1159 -0
  148. data/lib/fog/vcloud_director/requests/compute/get_task.rb +168 -0
  149. data/lib/fog/vcloud_director/requests/compute/get_task_list.rb +130 -0
  150. data/lib/fog/vcloud_director/requests/compute/get_template_vm.rb +74 -0
  151. data/lib/fog/vcloud_director/requests/compute/get_template_vms.rb +41 -0
  152. data/lib/fog/vcloud_director/requests/compute/get_thumbnail.rb +28 -0
  153. data/lib/fog/vcloud_director/requests/compute/get_users_from_query.rb +95 -0
  154. data/lib/fog/vcloud_director/requests/compute/get_vapp.rb +176 -0
  155. data/lib/fog/vcloud_director/requests/compute/get_vapp_metadata.rb +84 -0
  156. data/lib/fog/vcloud_director/requests/compute/get_vapp_metadata_item_metadata.rb +26 -0
  157. data/lib/fog/vcloud_director/requests/compute/get_vapp_ovf_descriptor.rb +24 -0
  158. data/lib/fog/vcloud_director/requests/compute/get_vapp_owner.rb +58 -0
  159. data/lib/fog/vcloud_director/requests/compute/get_vapp_template.rb +25 -0
  160. data/lib/fog/vcloud_director/requests/compute/get_vapp_template_customization_system_section.rb +25 -0
  161. data/lib/fog/vcloud_director/requests/compute/get_vapp_template_metadata.rb +25 -0
  162. data/lib/fog/vcloud_director/requests/compute/get_vapp_template_metadata_item_metadata.rb +27 -0
  163. data/lib/fog/vcloud_director/requests/compute/get_vapp_template_ovf_descriptor.rb +24 -0
  164. data/lib/fog/vcloud_director/requests/compute/get_vapp_template_owner.rb +25 -0
  165. data/lib/fog/vcloud_director/requests/compute/get_vapp_templates_from_query.rb +95 -0
  166. data/lib/fog/vcloud_director/requests/compute/get_vapps_in_lease_from_query.rb +94 -0
  167. data/lib/fog/vcloud_director/requests/compute/get_vcloud.rb +76 -0
  168. data/lib/fog/vcloud_director/requests/compute/get_vdc.rb +174 -0
  169. data/lib/fog/vcloud_director/requests/compute/get_vdc_metadata.rb +25 -0
  170. data/lib/fog/vcloud_director/requests/compute/get_vdc_metadata_item_metadata.rb +28 -0
  171. data/lib/fog/vcloud_director/requests/compute/get_vdc_storage_class.rb +83 -0
  172. data/lib/fog/vcloud_director/requests/compute/get_vdc_storage_class_metadata.rb +27 -0
  173. data/lib/fog/vcloud_director/requests/compute/get_vdc_storage_class_metadata_item_metadata.rb +25 -0
  174. data/lib/fog/vcloud_director/requests/compute/get_vdcs_from_query.rb +94 -0
  175. data/lib/fog/vcloud_director/requests/compute/get_virtual_hardware_section.rb +29 -0
  176. data/lib/fog/vcloud_director/requests/compute/get_vm.rb +74 -0
  177. data/lib/fog/vcloud_director/requests/compute/get_vm_capabilities.rb +61 -0
  178. data/lib/fog/vcloud_director/requests/compute/get_vm_compliance_results.rb +24 -0
  179. data/lib/fog/vcloud_director/requests/compute/get_vm_customization.rb +31 -0
  180. data/lib/fog/vcloud_director/requests/compute/get_vm_disks.rb +51 -0
  181. data/lib/fog/vcloud_director/requests/compute/get_vm_network.rb +56 -0
  182. data/lib/fog/vcloud_director/requests/compute/get_vm_pending_question.rb +34 -0
  183. data/lib/fog/vcloud_director/requests/compute/get_vms.rb +41 -0
  184. data/lib/fog/vcloud_director/requests/compute/get_vms_by_metadata.rb +20 -0
  185. data/lib/fog/vcloud_director/requests/compute/get_vms_disk_attached_to.rb +39 -0
  186. data/lib/fog/vcloud_director/requests/compute/get_vms_in_lease_from_query.rb +150 -0
  187. data/lib/fog/vcloud_director/requests/compute/instantiate_vapp_template.rb +173 -0
  188. data/lib/fog/vcloud_director/requests/compute/post_acquire_ticket.rb +27 -0
  189. data/lib/fog/vcloud_director/requests/compute/post_answer_vm_pending_question.rb +36 -0
  190. data/lib/fog/vcloud_director/requests/compute/post_attach_disk.rb +51 -0
  191. data/lib/fog/vcloud_director/requests/compute/post_cancel_task.rb +43 -0
  192. data/lib/fog/vcloud_director/requests/compute/post_capture_vapp.rb +70 -0
  193. data/lib/fog/vcloud_director/requests/compute/post_check_vm_compliance.rb +28 -0
  194. data/lib/fog/vcloud_director/requests/compute/post_clone_media.rb +102 -0
  195. data/lib/fog/vcloud_director/requests/compute/post_clone_vapp.rb +62 -0
  196. data/lib/fog/vcloud_director/requests/compute/post_clone_vapp_template.rb +52 -0
  197. data/lib/fog/vcloud_director/requests/compute/post_compose_vapp.rb +45 -0
  198. data/lib/fog/vcloud_director/requests/compute/post_configure_edge_gateway_services.rb +73 -0
  199. data/lib/fog/vcloud_director/requests/compute/post_consolidate_vm_vapp.rb +27 -0
  200. data/lib/fog/vcloud_director/requests/compute/post_consolidate_vm_vapp_template.rb +27 -0
  201. data/lib/fog/vcloud_director/requests/compute/post_create_catalog_item.rb +56 -0
  202. data/lib/fog/vcloud_director/requests/compute/post_create_org_vdc_network.rb +171 -0
  203. data/lib/fog/vcloud_director/requests/compute/post_create_snapshot.rb +21 -0
  204. data/lib/fog/vcloud_director/requests/compute/post_deploy_vapp.rb +51 -0
  205. data/lib/fog/vcloud_director/requests/compute/post_detach_disk.rb +39 -0
  206. data/lib/fog/vcloud_director/requests/compute/post_disable_nested_hv.rb +27 -0
  207. data/lib/fog/vcloud_director/requests/compute/post_disable_vapp_template_download.rb +24 -0
  208. data/lib/fog/vcloud_director/requests/compute/post_discard_vapp_state.rb +30 -0
  209. data/lib/fog/vcloud_director/requests/compute/post_eject_cd_rom.rb +39 -0
  210. data/lib/fog/vcloud_director/requests/compute/post_enable_nested_hv.rb +27 -0
  211. data/lib/fog/vcloud_director/requests/compute/post_enable_vapp_template_download.rb +24 -0
  212. data/lib/fog/vcloud_director/requests/compute/post_enter_maintenance_mode.rb +26 -0
  213. data/lib/fog/vcloud_director/requests/compute/post_exit_maintenance_mode.rb +22 -0
  214. data/lib/fog/vcloud_director/requests/compute/post_insert_cd_rom.rb +39 -0
  215. data/lib/fog/vcloud_director/requests/compute/post_install_vmware_tools.rb +27 -0
  216. data/lib/fog/vcloud_director/requests/compute/post_instantiate_vapp_template.rb +196 -0
  217. data/lib/fog/vcloud_director/requests/compute/post_login_session.rb +39 -0
  218. data/lib/fog/vcloud_director/requests/compute/post_power_off_vapp.rb +36 -0
  219. data/lib/fog/vcloud_director/requests/compute/post_power_on_vapp.rb +71 -0
  220. data/lib/fog/vcloud_director/requests/compute/post_reboot_vapp.rb +33 -0
  221. data/lib/fog/vcloud_director/requests/compute/post_recompose_vapp.rb +21 -0
  222. data/lib/fog/vcloud_director/requests/compute/post_reconfigure_vm.rb +118 -0
  223. data/lib/fog/vcloud_director/requests/compute/post_remove_all_snapshots.rb +27 -0
  224. data/lib/fog/vcloud_director/requests/compute/post_reset_vapp.rb +33 -0
  225. data/lib/fog/vcloud_director/requests/compute/post_revert_snapshot.rb +27 -0
  226. data/lib/fog/vcloud_director/requests/compute/post_shutdown_vapp.rb +33 -0
  227. data/lib/fog/vcloud_director/requests/compute/post_suspend_vapp.rb +33 -0
  228. data/lib/fog/vcloud_director/requests/compute/post_undeploy_vapp.rb +66 -0
  229. data/lib/fog/vcloud_director/requests/compute/post_update_catalog_item_metadata.rb +52 -0
  230. data/lib/fog/vcloud_director/requests/compute/post_update_disk_metadata.rb +52 -0
  231. data/lib/fog/vcloud_director/requests/compute/post_update_media_metadata.rb +52 -0
  232. data/lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb +86 -0
  233. data/lib/fog/vcloud_director/requests/compute/post_update_vapp_template_metadata.rb +52 -0
  234. data/lib/fog/vcloud_director/requests/compute/post_upgrade_hw_version.rb +28 -0
  235. data/lib/fog/vcloud_director/requests/compute/post_upload_disk.rb +133 -0
  236. data/lib/fog/vcloud_director/requests/compute/post_upload_media.rb +120 -0
  237. data/lib/fog/vcloud_director/requests/compute/post_upload_vapp_template.rb +46 -0
  238. data/lib/fog/vcloud_director/requests/compute/put_catalog_item_metadata_item_metadata.rb +50 -0
  239. data/lib/fog/vcloud_director/requests/compute/put_cpu.rb +88 -0
  240. data/lib/fog/vcloud_director/requests/compute/put_disk_metadata_item_metadata.rb +46 -0
  241. data/lib/fog/vcloud_director/requests/compute/put_disks.rb +39 -0
  242. data/lib/fog/vcloud_director/requests/compute/put_guest_customization_section_vapp.rb +141 -0
  243. data/lib/fog/vcloud_director/requests/compute/put_media_metadata_item_metadata.rb +50 -0
  244. data/lib/fog/vcloud_director/requests/compute/put_memory.rb +89 -0
  245. data/lib/fog/vcloud_director/requests/compute/put_metadata_value.rb +26 -0
  246. data/lib/fog/vcloud_director/requests/compute/put_network.rb +162 -0
  247. data/lib/fog/vcloud_director/requests/compute/put_network_connection_system_section_vapp.rb +152 -0
  248. data/lib/fog/vcloud_director/requests/compute/put_product_sections.rb +46 -0
  249. data/lib/fog/vcloud_director/requests/compute/put_vapp_metadata_item_metadata.rb +85 -0
  250. data/lib/fog/vcloud_director/requests/compute/put_vapp_name_and_description.rb +36 -0
  251. data/lib/fog/vcloud_director/requests/compute/put_vapp_template_metadata_item_metadata.rb +50 -0
  252. data/lib/fog/vcloud_director/requests/compute/put_vm.rb +72 -0
  253. data/lib/fog/vcloud_director/requests/compute/put_vm_capabilities.rb +44 -0
  254. data/lib/fog/vcloud_director/version.rb +5 -0
  255. data/spec/spec_helper.rb +15 -0
  256. data/spec/vcloud_director/generators/compute/instantiate_vapp_template_params_spec.rb +68 -0
  257. data/spec/vcloud_director/requests/compute/instantiate_vapp_template_spec.rb +78 -0
  258. data/spec/vcloud_director/spec_helper.rb +11 -0
  259. data/tasks/bundler.rake +3 -0
  260. data/tasks/console.rake +12 -0
  261. data/tasks/lint.rake +3 -0
  262. data/tasks/test.rake +13 -0
  263. data/tests/helper.rb +32 -0
  264. data/tests/helpers/collection_helper.rb +97 -0
  265. data/tests/helpers/compute/flavors_helper.rb +32 -0
  266. data/tests/helpers/compute/server_helper.rb +25 -0
  267. data/tests/helpers/compute/servers_helper.rb +10 -0
  268. data/tests/helpers/formats_helper.rb +98 -0
  269. data/tests/helpers/formats_helper_tests.rb +110 -0
  270. data/tests/helpers/mock_helper.rb +95 -0
  271. data/tests/helpers/model_helper.rb +31 -0
  272. data/tests/helpers/responds_to_helper.rb +11 -0
  273. data/tests/helpers/schema_validator_tests.rb +107 -0
  274. data/tests/helpers/succeeds_helper.rb +9 -0
  275. data/tests/lorem.txt +1 -0
  276. data/tests/vcloud_director/ensure_list_tests.rb +84 -0
  277. data/tests/vcloud_director/fixtures/test.iso +1 -0
  278. data/tests/vcloud_director/fixtures/vapp.xml +532 -0
  279. data/tests/vcloud_director/fixtures/vm.xml +213 -0
  280. data/tests/vcloud_director/generators/compute/compose_vapp_tests.rb +108 -0
  281. data/tests/vcloud_director/models/compute/catalog_items_tests.rb +42 -0
  282. data/tests/vcloud_director/models/compute/catalogs_tests.rb +40 -0
  283. data/tests/vcloud_director/models/compute/helper.rb +60 -0
  284. data/tests/vcloud_director/models/compute/media_tests.rb +58 -0
  285. data/tests/vcloud_director/models/compute/network_tests.rb +108 -0
  286. data/tests/vcloud_director/models/compute/organizations_tests.rb +18 -0
  287. data/tests/vcloud_director/models/compute/tasks_tests.rb +56 -0
  288. data/tests/vcloud_director/models/compute/vapp_life_cycle_tests.rb +93 -0
  289. data/tests/vcloud_director/models/compute/vapp_template_tests.rb +29 -0
  290. data/tests/vcloud_director/models/compute/vapp_tests.rb +61 -0
  291. data/tests/vcloud_director/models/compute/vdcs_tests.rb +54 -0
  292. data/tests/vcloud_director/models/compute/vms_tests.rb +101 -0
  293. data/tests/vcloud_director/requests/compute/admin_tests.rb +16 -0
  294. data/tests/vcloud_director/requests/compute/catalog_tests.rb +42 -0
  295. data/tests/vcloud_director/requests/compute/disk_tests.rb +178 -0
  296. data/tests/vcloud_director/requests/compute/edge_gateway_tests.rb +217 -0
  297. data/tests/vcloud_director/requests/compute/groups_tests.rb +18 -0
  298. data/tests/vcloud_director/requests/compute/helper.rb +32 -0
  299. data/tests/vcloud_director/requests/compute/media_tests.rb +195 -0
  300. data/tests/vcloud_director/requests/compute/network_tests.rb +186 -0
  301. data/tests/vcloud_director/requests/compute/organization_tests.rb +37 -0
  302. data/tests/vcloud_director/requests/compute/ovf_descriptor_tests.rb +36 -0
  303. data/tests/vcloud_director/requests/compute/query_tests.rb +99 -0
  304. data/tests/vcloud_director/requests/compute/schema_helper.rb +663 -0
  305. data/tests/vcloud_director/requests/compute/session_tests.rb +14 -0
  306. data/tests/vcloud_director/requests/compute/supported_systems_tests.rb +11 -0
  307. data/tests/vcloud_director/requests/compute/task_tests.rb +35 -0
  308. data/tests/vcloud_director/requests/compute/users_tests.rb +18 -0
  309. data/tests/vcloud_director/requests/compute/vapp_tests.rb +123 -0
  310. data/tests/vcloud_director/requests/compute/vdc_storage_profile_tests.rb +27 -0
  311. data/tests/vcloud_director/requests/compute/vdc_tests.rb +36 -0
  312. data/tests/vcloud_director/requests/compute/versions_tests.rb +13 -0
  313. data/tests/vcloud_director/requests/compute/vm_tests.rb +185 -0
  314. data/tests/watchr.rb +22 -0
  315. metadata +461 -0
@@ -0,0 +1,69 @@
1
+ require 'fog/core'
2
+ require 'fog/xml'
3
+
4
+ module Fog
5
+ module VcloudDirector
6
+ extend Fog::Provider
7
+
8
+ module Errors
9
+ class ServiceError < Fog::Errors::Error
10
+ attr_reader :minor_error_code
11
+ attr_reader :major_error_code
12
+ attr_reader :stack_trace
13
+ attr_reader :status_code
14
+ attr_reader :vendor_specific_error_code
15
+
16
+ def self.slurp(error, service=nil)
17
+ major_error_code = nil
18
+ message = nil
19
+ minor_error_code = nil
20
+ stack_trace = nil
21
+ status_code = nil
22
+ vendor_specific_error_code = nil
23
+
24
+ if error.response
25
+ status_code = error.response.status
26
+ unless error.response.body.empty?
27
+ _, media_type = error.response.headers.find {|k,v| k.downcase == 'content-type'}
28
+ if media_type =~ /vnd\.vmware\.vcloud\.error\+xml/i
29
+ begin
30
+ document = Fog::ToHashDocument.new
31
+ Nokogiri::XML::SAX::Parser.new(document).parse_memory(error.response.body)
32
+ major_error_code = document.body[:majorErrorCode]
33
+ message = document.body[:message]
34
+ minor_error_code = document.body[:minorErrorCode]
35
+ stack_trace = document.body[:stackTrace]
36
+ vendor_specific_error_code = document.body[:vendorSpecificErrorCode]
37
+ rescue => e
38
+ Fog::Logger.warning("Received exception '#{e}' while decoding>> #{error.response.body}")
39
+ message = error.response.body
40
+ end
41
+ else
42
+ message = CGI::unescapeHTML(error.response.body)
43
+ end
44
+ end
45
+ end
46
+
47
+ new_error = super(error, message)
48
+ new_error.instance_variable_set(:@major_error_code, major_error_code)
49
+ new_error.instance_variable_set(:@minor_error_code, minor_error_code)
50
+ new_error.instance_variable_set(:@stack_trace, stack_trace)
51
+ new_error.instance_variable_set(:@status_code, status_code)
52
+ new_error.instance_variable_set(:@vendor_specific_error_code, vendor_specific_error_code)
53
+ new_error
54
+ end
55
+ end
56
+
57
+ class BadRequest < ServiceError; end
58
+ class Unauthorized < ServiceError; end
59
+ class Forbidden < ServiceError; end
60
+ class Conflict < ServiceError; end
61
+ class MalformedResponse < ServiceError; end
62
+
63
+ class DuplicateName < ServiceError; end
64
+ class TaskError < ServiceError; end
65
+ end
66
+
67
+ service(:compute, 'Compute')
68
+ end
69
+ end
@@ -0,0 +1,122 @@
1
+ module Fog
2
+ module Generators
3
+ module Compute
4
+ module VcloudDirector
5
+ module ComposeCommon
6
+
7
+ def initialize(configuration={})
8
+ @configuration = configuration
9
+ end
10
+
11
+ private
12
+
13
+ def vapp_attrs
14
+ attrs = {
15
+ :xmlns => 'http://www.vmware.com/vcloud/v1.5',
16
+ 'xmlns:ovf' => 'http://schemas.dmtf.org/ovf/envelope/1'
17
+ }
18
+
19
+ [:deploy, :powerOn, :name].each do |a|
20
+ attrs[a] = @configuration[a] if @configuration.key?(a)
21
+ end
22
+
23
+ attrs
24
+ end
25
+
26
+ def has_source_items?
27
+ (@configuration[:source_vms] && (@configuration[:source_vms].size > 0)) ||
28
+ (@configuration[:source_templates] && (@configuration[:source_templates].size > 0))
29
+ end
30
+
31
+ def build_vapp_instantiation_params(xml)
32
+ xml.Description @configuration[:Description] if @configuration[:Description]
33
+
34
+ vapp = @configuration[:InstantiationParams]
35
+ if vapp
36
+ xml.InstantiationParams {
37
+ xml.DefaultStorageProfileSection {
38
+ xml.StorageProfile vapp[:DefaultStorageProfile]
39
+ } if (vapp.key? :DefaultStorageProfile)
40
+ xml.NetworkConfigSection {
41
+ xml['ovf'].Info
42
+ vapp[:NetworkConfig].each do |network|
43
+ xml.NetworkConfig(:networkName => network[:networkName]) {
44
+ xml.Configuration {
45
+ xml.ParentNetwork(:href => network[:networkHref])
46
+ xml.FenceMode network[:fenceMode]
47
+ }
48
+ }
49
+ end if vapp[:NetworkConfig]
50
+ }
51
+ }
52
+ end
53
+ end
54
+
55
+ def build_source_template(xml)
56
+ xml.Source(:href => @configuration[:Source])
57
+ end
58
+
59
+ def build_source_items(xml)
60
+ vms = @configuration[:source_vms]
61
+ vms.each do |vm|
62
+ xml.SourcedItem {
63
+ xml.Source(:name =>vm[:name], :href => vm[:href])
64
+ xml.VmGeneralParams {
65
+ xml.Name vm[:name]
66
+ xml.Description vm[:Description] if vm[:Description]
67
+ xml.NeedsCustomization if vm[:NeedsCustomization]
68
+ } if vm[:name]
69
+ xml.InstantiationParams {
70
+ if vm[:networks]
71
+ xml.NetworkConnectionSection(:href => "#{vm[:href]}/networkConnectionSection/", :type => "application/vnd.vmware.vcloud.networkConnectionSection+xml", 'xmlns:ovf' => "http://schemas.dmtf.org/ovf/envelope/1", "ovf:required" => "false") {
72
+ xml['ovf'].Info
73
+ xml.PrimaryNetworkConnectionIndex 0
74
+ vm[:networks].each_with_index do |network, i|
75
+ xml.NetworkConnection(:network => network[:networkName]) {
76
+ xml.NetworkConnectionIndex i
77
+ xml.IpAddress network[:IpAddress] if (network.key? :IpAddress)
78
+ xml.ExternalIpAddress network[:ExternalIpAddress] if (network.key? :ExternalIpAddress)
79
+ xml.IsConnected network[:IsConnected]
80
+ xml.MACAddress network[:MACAddress] if (network.key? :MACAddress)
81
+ xml.IpAddressAllocationMode network[:IpAddressAllocationMode]
82
+ }
83
+ end
84
+ }
85
+ end
86
+ if customization = vm[:guest_customization]
87
+ xml.GuestCustomizationSection(:xmlns => "http://www.vmware.com/vcloud/v1.5", 'xmlns:ovf' => "http://schemas.dmtf.org/ovf/envelope/1") {
88
+ xml['ovf'].Info
89
+ xml.Enabled (customization[:Enabled] || false)
90
+ xml.ChangeSid customization[:ChangeSid] if (customization.key? :ChangeSid)
91
+ xml.JoinDomainEnabled customization[:JoinDomainEnabled] if (customization.key? :JoinDomainEnabled)
92
+ xml.UseOrgSettings customization[:UseOrgSettings] if (customization.key? :UseOrgSettings)
93
+ xml.DomainName customization[:DomainName] if (customization.key? :DomainName)
94
+ xml.DomainUserName customization[:DomainUserName] if (customization.key? :DomainUserName)
95
+ xml.DomainUserPassword customization[:DomainUserPassword] if (customization.key? :DomainUserPassword)
96
+ xml.MachineObjectOU customization[:MachineObjectOU] if (customization.key? :MachineObjectOU)
97
+ xml.AdminPasswordEnabled customization[:AdminPasswordEnabled] if (customization.key? :AdminPasswordEnabled)
98
+ xml.AdminPasswordAuto customization[:AdminPasswordAuto] if (customization.key? :AdminPasswordAuto)
99
+ xml.AdminPassword customization[:AdminPassword] if (customization.key? :AdminPassword)
100
+ xml.ResetPasswordRequired customization[:ResetPasswordRequired] if (customization.key? :ResetPasswordRequired)
101
+ xml.CustomizationScript CGI::escapeHTML(customization[:CustomizationScript]).gsub(/\r/, "&#13;") if (customization.key? :CustomizationScript)
102
+ xml.ComputerName customization[:ComputerName]
103
+ }
104
+ end
105
+ }
106
+ xml.StorageProfile(:href => vm[:StorageProfileHref]) if (vm.key? :StorageProfileHref)
107
+ }
108
+ end if vms
109
+
110
+ templates = @configuration[:source_templates]
111
+ templates.each do |template|
112
+ xml.SourcedItem { xml.Source(:href => template[:href]) }
113
+ end if templates
114
+
115
+ xml.AllEULAsAccepted (@configuration[:AllEULAsAccepted] || true)
116
+ end
117
+
118
+ end
119
+ end
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,25 @@
1
+ require 'fog/vcloud_director/generators/compute/compose_common'
2
+
3
+ module Fog
4
+ module Generators
5
+ module Compute
6
+ module VcloudDirector
7
+ # @see http://pubs.vmware.com/vcd-51/index.jsp#types/ComposeVAppParamsType.html
8
+ class ComposeVapp
9
+
10
+ include ComposeCommon
11
+
12
+ def generate_xml
13
+ Nokogiri::XML::Builder.new do |xml|
14
+ xml.ComposeVAppParams(vapp_attrs) {
15
+ build_vapp_instantiation_params(xml)
16
+ build_source_items(xml)
17
+ }
18
+ end.to_xml
19
+ end
20
+
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ module Fog
2
+ module Generators
3
+ module Compute
4
+ module VcloudDirector
5
+ # @see http://pubs.vmware.com/vcd-56/topic/com.vmware.ICbase/PDF/vcd_56_api_guide.pdf @page 121
6
+ class CreateSnapshot
7
+ attr_reader :attrs
8
+
9
+ def initialize(attrs={})
10
+ @attrs = attrs
11
+ end
12
+
13
+ def generate_xml
14
+ attrs = @attrs
15
+ Nokogiri::XML::Builder.new do
16
+ CreateSnapshotParams('xmlns' => 'http://www.vmware.com/vcloud/v1.5', 'memory' => attrs[:memory], 'name' => attrs[:name], 'quiesce' => attrs[:quiesce]) {
17
+ Description attrs[:Description] if attrs.key?(:Description)
18
+ }
19
+ end.to_xml
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,105 @@
1
+ module Fog
2
+ module Generators
3
+ module Compute
4
+ module VcloudDirector
5
+ # This is the data structure it accepts, this is the output of
6
+ # #get_vm_customization:
7
+ #
8
+ # {:type=>"application/vnd.vmware.vcloud.guestCustomizationSection+xml",
9
+ # :href=>
10
+ # "https://example.com/api/vApp/vm-2bbbf556-55dc-4974-82e6-aa6e814f0b64/guestCustomizationSection/",
11
+ # :id=>"vm-2bbbf556-55dc-4974-82e6-aa6e814f0b64",
12
+ # :enabled=>false,
13
+ # :change_sid=>false,
14
+ # :virtual_machine_id=>"2bbbf556-55dc-4974-82e6-aa6e814f0b64",
15
+ # :join_domain_enabled=>false,
16
+ # :use_org_settings=>false,
17
+ # :admin_password_enabled=>false,
18
+ # :admin_password_auto=>true,
19
+ # :reset_password_required=>false,
20
+ # :customization_script=>"hola\nmundo",
21
+ # :has_customization_script=>true,
22
+ # :computer_name=>"DEVWEB-001"}
23
+ #
24
+ # This is what it generates:
25
+ #
26
+ # <vcloud:GuestCustomizationSection
27
+ # xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"
28
+ # xmlns:vcloud="http://www.vmware.com/vcloud/v1.5"
29
+ # href="https://vcloud.example.com/api/vApp/vm-55cc91f2-7e12-48d4-ad90-6f637a51fd88/guestCustomizationSection/"
30
+ # ovf:required="false"
31
+ # type="application/vnd.vmware.vcloud.guestCustomizationSection+xml">
32
+ # <ovf:Info>Specifies Guest OS Customization Settings</ovf:Info>
33
+ # <vcloud:Enabled>true</vcloud:Enabled>
34
+ # <vcloud:ChangeSid>true</vcloud:ChangeSid>
35
+ # <vcloud:VirtualMachineId>55cc91f2-7e12-48d4-ad90-6f637a51fd88</vcloud:VirtualMachineId>
36
+ # <vcloud:JoinDomainEnabled>false</vcloud:JoinDomainEnabled>
37
+ # <vcloud:UseOrgSettings>false</vcloud:UseOrgSettings>
38
+ # <vcloud:AdminPasswordEnabled>true</vcloud:AdminPasswordEnabled>
39
+ # <vcloud:AdminPasswordAuto>true</vcloud:AdminPasswordAuto>
40
+ # <vcloud:ResetPasswordRequired>false</vcloud:ResetPasswordRequired>
41
+ # <vcloud:ComputerName>DEVWEB-001</vcloud:ComputerName>
42
+ # </vcloud:GuestCustomizationSection>
43
+ #
44
+ # @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/types/GuestCustomizationSectionType.html
45
+ class Customization
46
+ def initialize(attrs={})
47
+ @attrs = attrs
48
+ end
49
+
50
+ def generate_xml
51
+ output = ""
52
+ output << header
53
+ output << body(@attrs)
54
+ output << tail
55
+ output
56
+ end
57
+
58
+ private
59
+
60
+ def header
61
+ <<-END
62
+ <GuestCustomizationSection xmlns="http://www.vmware.com/vcloud/v1.5"
63
+ xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"
64
+ type="application/vnd.vmware.vcloud.guestCustomizationSection+xml">
65
+ END
66
+ end
67
+
68
+ # The order matters: http://communities.vmware.com/thread/448760?start=0&tstart=0
69
+ #
70
+ # CustomizationScript: Script to run on guest customization. You
71
+ # could use XML escape sequence &#13; to make multiple lines script.
72
+ # The script could contain any UNICODE symbol by specifying its
73
+ # number in format &#xxxx; where xxxx is the number. The predefined
74
+ # symbols in the XML are:
75
+ # * & &amp;
76
+ # * < &lt;
77
+ # * > &gt;
78
+ # * " &quot;
79
+ # * ' &apos;
80
+ def body(opts={})
81
+ <<-END
82
+ <ovf:Info>Specifies Guest OS Customization Settings</ovf:Info>
83
+ <Enabled>#{opts[:enabled]}</Enabled>
84
+ <ChangeSid>#{opts[:change_sid]}</ChangeSid>
85
+ <VirtualMachineId>#{opts[:virtual_machine_id]}</VirtualMachineId>
86
+ <JoinDomainEnabled>#{opts[:join_domain_enabled]}</JoinDomainEnabled>
87
+ <UseOrgSettings>#{opts[:use_org_settings]}</UseOrgSettings>
88
+ <AdminPasswordEnabled>#{opts[:admin_password_enabled]}</AdminPasswordEnabled>
89
+ <AdminPasswordAuto>#{opts[:admin_password_auto]}</AdminPasswordAuto>
90
+ <ResetPasswordRequired>#{opts[:reset_password_required]}</ResetPasswordRequired>
91
+ <CustomizationScript>#{CGI::escapeHTML(opts[:customization_script]).gsub(/\r/, "&#13;")}</CustomizationScript>
92
+ <ComputerName>#{opts[:computer_name]}</ComputerName>
93
+ END
94
+ end
95
+
96
+ def tail
97
+ <<-END
98
+ </GuestCustomizationSection>
99
+ END
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,186 @@
1
+ module Fog
2
+ module Generators
3
+ module Compute
4
+ module VcloudDirector
5
+ # This is the data structure it accepts, this is the output of
6
+ # #get_vm_disks:
7
+ #
8
+ # {:disks=>
9
+ # [{:address=>0,
10
+ # :description=>"SCSI Controller",
11
+ # :name=>"SCSI Controller 0",
12
+ # :id=>2,
13
+ # :resource_sub_type=>"VirtualSCSI",
14
+ # :resource_type=>6},
15
+ # {:address_on_parent=>0,
16
+ # :description=>"Hard disk",
17
+ # :name=>"Hard disk 1",
18
+ # :id=>2000,
19
+ # :parent=>2,
20
+ # :resource_type=>17,
21
+ # :capacity=>16384,
22
+ # :bus_sub_type=>"VirtualSCSI",
23
+ # :bus_type=>6},
24
+ # {:address=>0,
25
+ # :description=>"IDE Controller",
26
+ # :name=>"IDE Controller 0",
27
+ # :id=>3,
28
+ # :resource_type=>5}]}
29
+ #
30
+ # This is what it generates:
31
+ #
32
+ # <vcloud:RasdItemsList xmlns:vcloud="http://www.vmware.com/vcloud/v1.5"
33
+ # xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"
34
+ # type="application/vnd.vmware.vcloud.rasdItemsList+xml">
35
+ # <vcloud:Item>
36
+ # <rasd:Address>0</rasd:Address>
37
+ # <rasd:Description>SCSI Controller</rasd:Description>
38
+ # <rasd:ElementName>SCSI Controller 0</rasd:ElementName>
39
+ # <rasd:InstanceID>2</rasd:InstanceID>
40
+ # <rasd:ResourceSubType>VirtualSCSI</rasd:ResourceSubType>
41
+ # <rasd:ResourceType>6</rasd:ResourceType>
42
+ # </vcloud:Item>
43
+ # <vcloud:Item>
44
+ # <rasd:AddressOnParent>0</rasd:AddressOnParent>
45
+ # <rasd:Description>Hard disk</rasd:Description>
46
+ # <rasd:ElementName>Hard disk 1</rasd:ElementName>
47
+ # <rasd:HostResource vcloud:capacity="16384" vcloud:busSubType="VirtualSCSI" vcloud:busType="6"></rasd:HostResource>
48
+ # <rasd:InstanceID>2000</rasd:InstanceID>
49
+ # <rasd:Parent>2</rasd:Parent>
50
+ # <rasd:ResourceType>17</rasd:ResourceType>
51
+ # </vcloud:Item>
52
+ # <vcloud:Item>
53
+ # <rasd:Address>0</rasd:Address>
54
+ # <rasd:Description>IDE Controller</rasd:Description>
55
+ # <rasd:ElementName>IDE Controller 0</rasd:ElementName>
56
+ # <rasd:InstanceID>3</rasd:InstanceID>
57
+ # <rasd:ResourceType>5</rasd:ResourceType>
58
+ # </vcloud:Item>
59
+ # </vcloud:RasdItemsList>
60
+ #
61
+ # @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/types/RasdItemsListType.html
62
+ class Disks
63
+ def initialize(items=[])
64
+ @items = items[:disks]
65
+ end
66
+
67
+ def modify_hard_disk_size(disk_number, new_size)
68
+ found = false
69
+ @items.each do |item|
70
+ if item[:resource_type] == 17
71
+ if item[:name] == "Hard disk #{disk_number}"
72
+ found = true
73
+ raise "Hard disk size can't be reduced" if item[:capacity].to_i > new_size.to_i
74
+ item[:capacity] = new_size
75
+ end
76
+ end
77
+ end
78
+ raise "Hard disk #{disk_number} not found" unless found
79
+ true
80
+ end
81
+
82
+ def add_hard_disk(size)
83
+ new_hard_disk = last_hard_disk.dup
84
+ new_hard_disk[:capacity] = size
85
+ new_hard_disk[:name] = increase_hard_disk_name(new_hard_disk[:name])
86
+ new_hard_disk[:address_on_parent] += 1
87
+ new_hard_disk[:id] += 1
88
+ @items << new_hard_disk
89
+ end
90
+
91
+ def delete_hard_disk(disk_number)
92
+ @items.delete_if {|item| item[:resource_type] == 17 && item[:name] =~ /#{disk_number}$/ }
93
+ end
94
+
95
+ def disks
96
+ { :disks => @items }
97
+ end
98
+
99
+ def generate_xml
100
+ output = ""
101
+ output << header
102
+ @items.each do |item|
103
+ output << case item[:resource_type]
104
+ when 6
105
+ scsi_controller(item)
106
+ when 17
107
+ hard_disk_item(item)
108
+ when 5
109
+ ide_controller_item(item)
110
+ end
111
+ end
112
+ output << tail
113
+ output
114
+ end
115
+
116
+ def header
117
+ <<-END
118
+ <vcloud:RasdItemsList xmlns:vcloud="http://www.vmware.com/vcloud/v1.5"
119
+ xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"
120
+ type="application/vnd.vmware.vcloud.rasdItemsList+xml">
121
+ END
122
+ end
123
+
124
+ def tail
125
+ <<-END
126
+ </vcloud:RasdItemsList>
127
+ END
128
+ end
129
+
130
+ def hard_disk_item(opts={})
131
+ <<-END
132
+ <vcloud:Item>
133
+ <rasd:AddressOnParent>#{opts[:address_on_parent]}</rasd:AddressOnParent>
134
+ <rasd:Description>#{opts[:description]}</rasd:Description>
135
+ <rasd:ElementName>#{opts[:name]}</rasd:ElementName>
136
+ <rasd:HostResource vcloud:capacity=\"#{opts[:capacity]}\" vcloud:busSubType=\"#{opts[:bus_sub_type]}\" vcloud:busType=\"#{opts[:bus_type]}\"></rasd:HostResource>
137
+ <rasd:InstanceID>#{opts[:id]}</rasd:InstanceID>
138
+ <rasd:Parent>#{opts[:parent]}</rasd:Parent>
139
+ <rasd:ResourceType>17</rasd:ResourceType>
140
+ </vcloud:Item>
141
+ END
142
+ end
143
+
144
+ def ide_controller_item(opts={})
145
+ <<-END
146
+ <vcloud:Item>
147
+ <rasd:Address>#{opts[:address]}</rasd:Address>
148
+ <rasd:Description>#{opts[:description]}</rasd:Description>
149
+ <rasd:ElementName>#{opts[:name]}</rasd:ElementName>
150
+ <rasd:InstanceID>#{opts[:id]}</rasd:InstanceID>
151
+ <rasd:ResourceType>5</rasd:ResourceType>
152
+ </vcloud:Item>
153
+ END
154
+ end
155
+
156
+ def scsi_controller(opts={})
157
+ <<-END
158
+ <vcloud:Item>
159
+ <rasd:Address>#{opts[:address]}</rasd:Address>
160
+ <rasd:Description>#{opts[:description]}</rasd:Description>
161
+ <rasd:ElementName>#{opts[:name]}</rasd:ElementName>
162
+ <rasd:InstanceID>#{opts[:id]}</rasd:InstanceID>
163
+ <rasd:ResourceSubType>#{opts[:resource_sub_type]}</rasd:ResourceSubType>
164
+ <rasd:ResourceType>6</rasd:ResourceType>
165
+ </vcloud:Item>
166
+ END
167
+ end
168
+
169
+ # helpers
170
+
171
+ def last_hard_disk
172
+ hard_disks = @items.select{|item| item[:resource_type] == 17}
173
+ names = hard_disks.map{|item| item[:name] }
174
+ only_numbers = names.map{|b| b.scan(/\d+/).first.to_i} # extract numbers
175
+ last_number = only_numbers.sort.last # get the last number
176
+ hard_disks.find{|hard_disk| hard_disk[:name] =~ /#{last_number}$/ }
177
+ end
178
+
179
+ def increase_hard_disk_name(hard_disk_name)
180
+ hard_disk_name.gsub(/(\d+)$/) { $1.to_i + 1 }
181
+ end
182
+ end
183
+ end
184
+ end
185
+ end
186
+ end