bosh_vcloud_cpi 0.4.9 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (276) hide show
  1. data/README.md +69 -0
  2. data/lib/cloud/vcloud/cache.rb +20 -0
  3. data/lib/cloud/vcloud/cloud.rb +253 -535
  4. data/lib/cloud/vcloud/errors.rb +9 -0
  5. data/lib/cloud/vcloud/file_uploader.rb +39 -0
  6. data/lib/cloud/vcloud/steps/add_catalog_item.rb +28 -0
  7. data/lib/cloud/vcloud/steps/add_networks.rb +40 -0
  8. data/lib/cloud/vcloud/steps/attach_detach_disk.rb +15 -0
  9. data/lib/cloud/vcloud/steps/create_disk.rb +29 -0
  10. data/lib/cloud/vcloud/steps/create_media.rb +41 -0
  11. data/lib/cloud/vcloud/steps/create_template.rb +27 -0
  12. data/lib/cloud/vcloud/steps/create_update_agent_env.rb +66 -0
  13. data/lib/cloud/vcloud/steps/delete.rb +12 -0
  14. data/lib/cloud/vcloud/steps/delete_catalog_media.rb +23 -0
  15. data/lib/cloud/vcloud/steps/delete_unused_networks.rb +20 -0
  16. data/lib/cloud/vcloud/steps/discard_suspended_state.rb +15 -0
  17. data/lib/cloud/vcloud/steps/eject_catalog_media.rb +29 -0
  18. data/lib/cloud/vcloud/steps/insert_catalog_media.rb +26 -0
  19. data/lib/cloud/vcloud/steps/instantiate.rb +59 -0
  20. data/lib/cloud/vcloud/steps/load_agent_env.rb +14 -0
  21. data/lib/cloud/vcloud/steps/poweroff.rb +21 -0
  22. data/lib/cloud/vcloud/steps/poweron.rb +17 -0
  23. data/lib/cloud/vcloud/steps/reboot.rb +13 -0
  24. data/lib/cloud/vcloud/steps/recompose.rb +19 -0
  25. data/lib/cloud/vcloud/steps/reconfigure_vm.rb +35 -0
  26. data/lib/cloud/vcloud/steps/save_agent_env.rb +43 -0
  27. data/lib/cloud/vcloud/steps/stemcell_info.rb +20 -0
  28. data/lib/cloud/vcloud/steps/undeploy.rb +19 -0
  29. data/lib/cloud/vcloud/steps/upload_media_files.rb +18 -0
  30. data/lib/cloud/vcloud/steps/upload_template_files.rb +29 -0
  31. data/lib/cloud/vcloud/steps.rb +100 -0
  32. data/lib/cloud/vcloud/vcd_client.rb +284 -0
  33. data/lib/cloud/vcloud/version.rb +1 -1
  34. data/lib/cloud/vcloud/xml/constants.rb +428 -0
  35. data/lib/cloud/vcloud/xml/wrapper.rb +292 -0
  36. data/lib/cloud/vcloud/xml/wrapper_classes/admin_catalog.rb +20 -0
  37. data/lib/cloud/vcloud/xml/wrapper_classes/admin_org.rb +15 -0
  38. data/lib/cloud/vcloud/xml/wrapper_classes/catalog.rb +20 -0
  39. data/lib/cloud/vcloud/xml/wrapper_classes/catalog_item.rb +27 -0
  40. data/lib/cloud/vcloud/xml/wrapper_classes/disk.rb +42 -0
  41. data/lib/cloud/vcloud/xml/wrapper_classes/disk_attach_or_detach_params.rb +12 -0
  42. data/lib/cloud/vcloud/xml/wrapper_classes/disk_create_params.rb +47 -0
  43. data/lib/cloud/vcloud/xml/wrapper_classes/entity.rb +11 -0
  44. data/lib/cloud/vcloud/xml/wrapper_classes/file.rb +11 -0
  45. data/lib/cloud/vcloud/xml/wrapper_classes/hard_disk_item_wrapper.rb +56 -0
  46. data/lib/cloud/vcloud/xml/wrapper_classes/instantiate_vapp_template_params.rb +71 -0
  47. data/lib/cloud/vcloud/xml/wrapper_classes/ip_scope.rb +55 -0
  48. data/lib/cloud/vcloud/xml/wrapper_classes/item.rb +32 -0
  49. data/lib/cloud/vcloud/xml/wrapper_classes/link_wrapper.rb +39 -0
  50. data/lib/cloud/vcloud/xml/wrapper_classes/media.rb +57 -0
  51. data/lib/cloud/vcloud/xml/wrapper_classes/media_insert_or_eject_params.rb +17 -0
  52. data/lib/cloud/vcloud/xml/wrapper_classes/metadata_value.rb +15 -0
  53. data/lib/cloud/vcloud/xml/wrapper_classes/network.rb +15 -0
  54. data/lib/cloud/vcloud/xml/wrapper_classes/network_config.rb +27 -0
  55. data/lib/cloud/vcloud/xml/wrapper_classes/network_config_section.rb +25 -0
  56. data/lib/cloud/vcloud/xml/wrapper_classes/network_connection.rb +71 -0
  57. data/lib/cloud/vcloud/xml/wrapper_classes/network_connection_section.rb +67 -0
  58. data/lib/cloud/vcloud/xml/wrapper_classes/nic_item_wrapper.rb +89 -0
  59. data/lib/cloud/vcloud/xml/wrapper_classes/org.rb +21 -0
  60. data/lib/cloud/vcloud/xml/wrapper_classes/org_network.rb +19 -0
  61. data/lib/cloud/vcloud/xml/wrapper_classes/org_vdc_network.rb +11 -0
  62. data/lib/cloud/vcloud/xml/wrapper_classes/recompose_vapp_wrapper.rb +51 -0
  63. data/lib/cloud/vcloud/xml/wrapper_classes/session.rb +24 -0
  64. data/lib/cloud/vcloud/xml/wrapper_classes/supported_versions.rb +19 -0
  65. data/lib/cloud/vcloud/xml/wrapper_classes/task.rb +32 -0
  66. data/lib/cloud/vcloud/xml/wrapper_classes/upload_vapp_template_params.rb +11 -0
  67. data/lib/cloud/vcloud/xml/wrapper_classes/vapp.rb +77 -0
  68. data/lib/cloud/vcloud/xml/wrapper_classes/vapp_template.rb +17 -0
  69. data/lib/cloud/vcloud/xml/wrapper_classes/vcloud.rb +15 -0
  70. data/lib/cloud/vcloud/xml/wrapper_classes/vdc.rb +59 -0
  71. data/lib/cloud/vcloud/xml/wrapper_classes/vdc_storage_profile.rb +15 -0
  72. data/lib/cloud/vcloud/xml/wrapper_classes/virtual_hardware_section.rb +68 -0
  73. data/lib/cloud/vcloud/xml/wrapper_classes/vm.rb +212 -0
  74. data/lib/cloud/vcloud/xml/xml_templates/AdminAllocatedExtIpRecord.xml +1 -0
  75. data/lib/cloud/vcloud/xml/xml_templates/AdminCatalog.xml +1 -0
  76. data/lib/cloud/vcloud/xml/xml_templates/AdminCatalogItemRecord.xml +1 -0
  77. data/lib/cloud/vcloud/xml/xml_templates/AdminCatalogRecord.xml +1 -0
  78. data/lib/cloud/vcloud/xml/xml_templates/AdminGroupRecord.xml +1 -0
  79. data/lib/cloud/vcloud/xml/xml_templates/AdminMediaRecord.xml +1 -0
  80. data/lib/cloud/vcloud/xml/xml_templates/AdminOrg.xml +1 -0
  81. data/lib/cloud/vcloud/xml/xml_templates/AdminOrgNetworkRecord.xml +1 -0
  82. data/lib/cloud/vcloud/xml/xml_templates/AdminShadowVmRecord.xml +1 -0
  83. data/lib/cloud/vcloud/xml/xml_templates/AdminTaskRecord.xml +1 -0
  84. data/lib/cloud/vcloud/xml/xml_templates/AdminUserRecord.xml +1 -0
  85. data/lib/cloud/vcloud/xml/xml_templates/AdminVAppNetworkRecord.xml +1 -0
  86. data/lib/cloud/vcloud/xml/xml_templates/AdminVAppRecord.xml +1 -0
  87. data/lib/cloud/vcloud/xml/xml_templates/AdminVAppReference.xml +1 -0
  88. data/lib/cloud/vcloud/xml/xml_templates/AdminVAppReferences.xml +1 -0
  89. data/lib/cloud/vcloud/xml/xml_templates/AdminVAppTemplateRecord.xml +1 -0
  90. data/lib/cloud/vcloud/xml/xml_templates/AdminVdc.xml +1 -0
  91. data/lib/cloud/vcloud/xml/xml_templates/AdminVdcRecord.xml +1 -0
  92. data/lib/cloud/vcloud/xml/xml_templates/AdminVdcReference.xml +1 -0
  93. data/lib/cloud/vcloud/xml/xml_templates/AdminVdcReferences.xml +1 -0
  94. data/lib/cloud/vcloud/xml/xml_templates/AdminVmRecord.xml +1 -0
  95. data/lib/cloud/vcloud/xml/xml_templates/AllEULAsAccepted.xml +1 -0
  96. data/lib/cloud/vcloud/xml/xml_templates/AllocatedExtIpRecord.xml +1 -0
  97. data/lib/cloud/vcloud/xml/xml_templates/BlockingTaskRecord.xml +1 -0
  98. data/lib/cloud/vcloud/xml/xml_templates/BlockingTaskReference.xml +1 -0
  99. data/lib/cloud/vcloud/xml/xml_templates/BlockingTaskReferences.xml +1 -0
  100. data/lib/cloud/vcloud/xml/xml_templates/CaptureVAppParams.xml +1 -0
  101. data/lib/cloud/vcloud/xml/xml_templates/Catalog.xml +1 -0
  102. data/lib/cloud/vcloud/xml/xml_templates/CatalogItem.xml +1 -0
  103. data/lib/cloud/vcloud/xml/xml_templates/CatalogItemRecord.xml +1 -0
  104. data/lib/cloud/vcloud/xml/xml_templates/CatalogItemReference.xml +1 -0
  105. data/lib/cloud/vcloud/xml/xml_templates/CatalogItemReferences.xml +1 -0
  106. data/lib/cloud/vcloud/xml/xml_templates/CatalogRecord.xml +1 -0
  107. data/lib/cloud/vcloud/xml/xml_templates/CatalogReference.xml +1 -0
  108. data/lib/cloud/vcloud/xml/xml_templates/CatalogReferences.xml +1 -0
  109. data/lib/cloud/vcloud/xml/xml_templates/CellRecord.xml +1 -0
  110. data/lib/cloud/vcloud/xml/xml_templates/CloneMediaParams.xml +1 -0
  111. data/lib/cloud/vcloud/xml/xml_templates/CloneVAppParams.xml +1 -0
  112. data/lib/cloud/vcloud/xml/xml_templates/CloneVAppTemplateParams.xml +1 -0
  113. data/lib/cloud/vcloud/xml/xml_templates/ComposeVAppParams.xml +17 -0
  114. data/lib/cloud/vcloud/xml/xml_templates/ControlAccessParams.xml +1 -0
  115. data/lib/cloud/vcloud/xml/xml_templates/CustomizationSection.xml +1 -0
  116. data/lib/cloud/vcloud/xml/xml_templates/DatastoreProviderVdcRelationRecord.xml +1 -0
  117. data/lib/cloud/vcloud/xml/xml_templates/DatastoreRecord.xml +1 -0
  118. data/lib/cloud/vcloud/xml/xml_templates/DatastoreReference.xml +1 -0
  119. data/lib/cloud/vcloud/xml/xml_templates/DatastoreReferences.xml +1 -0
  120. data/lib/cloud/vcloud/xml/xml_templates/DeployVAppParams.xml +1 -0
  121. data/lib/cloud/vcloud/xml/xml_templates/DhcpService.xml +1 -0
  122. data/lib/cloud/vcloud/xml/xml_templates/DiskAttachOrDetachParams.xml +5 -0
  123. data/lib/cloud/vcloud/xml/xml_templates/DiskCreateParams.xml +9 -0
  124. data/lib/cloud/vcloud/xml/xml_templates/DvSwitchRecord.xml +1 -0
  125. data/lib/cloud/vcloud/xml/xml_templates/Entity.xml +1 -0
  126. data/lib/cloud/vcloud/xml/xml_templates/Error.xml +1 -0
  127. data/lib/cloud/vcloud/xml/xml_templates/EventRecord.xml +1 -0
  128. data/lib/cloud/vcloud/xml/xml_templates/ExternalNetwork.xml +1 -0
  129. data/lib/cloud/vcloud/xml/xml_templates/File.xml +1 -0
  130. data/lib/cloud/vcloud/xml/xml_templates/FirewallService.xml +1 -0
  131. data/lib/cloud/vcloud/xml/xml_templates/GeneralOrgSettings.xml +1 -0
  132. data/lib/cloud/vcloud/xml/xml_templates/Group.xml +1 -0
  133. data/lib/cloud/vcloud/xml/xml_templates/GroupRecord.xml +1 -0
  134. data/lib/cloud/vcloud/xml/xml_templates/GroupReference.xml +1 -0
  135. data/lib/cloud/vcloud/xml/xml_templates/GroupReferences.xml +1 -0
  136. data/lib/cloud/vcloud/xml/xml_templates/GuestCustomizationSection.xml +1 -0
  137. data/lib/cloud/vcloud/xml/xml_templates/HostRecord.xml +1 -0
  138. data/lib/cloud/vcloud/xml/xml_templates/HostReference.xml +1 -0
  139. data/lib/cloud/vcloud/xml/xml_templates/HostReferences.xml +1 -0
  140. data/lib/cloud/vcloud/xml/xml_templates/InstantiateOvfParams.xml +1 -0
  141. data/lib/cloud/vcloud/xml/xml_templates/InstantiateVAppTemplateParams.xml +1 -0
  142. data/lib/cloud/vcloud/xml/xml_templates/IpScope.xml +12 -0
  143. data/lib/cloud/vcloud/xml/xml_templates/IpsecVpnLocalPeer.xml +1 -0
  144. data/lib/cloud/vcloud/xml/xml_templates/IpsecVpnPeer.xml +1 -0
  145. data/lib/cloud/vcloud/xml/xml_templates/IpsecVpnRemotePeer.xml +1 -0
  146. data/lib/cloud/vcloud/xml/xml_templates/IpsecVpnService.xml +1 -0
  147. data/lib/cloud/vcloud/xml/xml_templates/IpsecVpnThirdPartyPeer.xml +1 -0
  148. data/lib/cloud/vcloud/xml/xml_templates/Item.xml +3 -0
  149. data/lib/cloud/vcloud/xml/xml_templates/ItemVcd.xml +5 -0
  150. data/lib/cloud/vcloud/xml/xml_templates/LeaseSettingsSection.xml +1 -0
  151. data/lib/cloud/vcloud/xml/xml_templates/Link.xml +1 -0
  152. data/lib/cloud/vcloud/xml/xml_templates/Media.xml +5 -0
  153. data/lib/cloud/vcloud/xml/xml_templates/MediaInsertOrEjectParams.xml +4 -0
  154. data/lib/cloud/vcloud/xml/xml_templates/MediaRecord.xml +1 -0
  155. data/lib/cloud/vcloud/xml/xml_templates/MediaReference.xml +1 -0
  156. data/lib/cloud/vcloud/xml/xml_templates/MediaReferences.xml +1 -0
  157. data/lib/cloud/vcloud/xml/xml_templates/Metadata.xml +5 -0
  158. data/lib/cloud/vcloud/xml/xml_templates/MetadataEntry.xml +7 -0
  159. data/lib/cloud/vcloud/xml/xml_templates/MetadataValue.xml +8 -0
  160. data/lib/cloud/vcloud/xml/xml_templates/NatService.xml +1 -0
  161. data/lib/cloud/vcloud/xml/xml_templates/Network.xml +4 -0
  162. data/lib/cloud/vcloud/xml/xml_templates/NetworkAssignment.xml +1 -0
  163. data/lib/cloud/vcloud/xml/xml_templates/NetworkConfig.xml +21 -0
  164. data/lib/cloud/vcloud/xml/xml_templates/NetworkConfigSection.xml +1 -0
  165. data/lib/cloud/vcloud/xml/xml_templates/NetworkConnection.xml +11 -0
  166. data/lib/cloud/vcloud/xml/xml_templates/NetworkConnectionSection.xml +1 -0
  167. data/lib/cloud/vcloud/xml/xml_templates/NetworkPoolRecord.xml +1 -0
  168. data/lib/cloud/vcloud/xml/xml_templates/NetworkPoolReference.xml +1 -0
  169. data/lib/cloud/vcloud/xml/xml_templates/NetworkPoolReferences.xml +1 -0
  170. data/lib/cloud/vcloud/xml/xml_templates/NetworkRecord.xml +1 -0
  171. data/lib/cloud/vcloud/xml/xml_templates/NetworkReference.xml +1 -0
  172. data/lib/cloud/vcloud/xml/xml_templates/NetworkReferences.xml +1 -0
  173. data/lib/cloud/vcloud/xml/xml_templates/NetworkService.xml +1 -0
  174. data/lib/cloud/vcloud/xml/xml_templates/Org.xml +1 -0
  175. data/lib/cloud/vcloud/xml/xml_templates/OrgEmailSettings.xml +1 -0
  176. data/lib/cloud/vcloud/xml/xml_templates/OrgList.xml +1 -0
  177. data/lib/cloud/vcloud/xml/xml_templates/OrgNetwork.xml +1 -0
  178. data/lib/cloud/vcloud/xml/xml_templates/OrgNetworkRecord.xml +1 -0
  179. data/lib/cloud/vcloud/xml/xml_templates/OrgNetworkReference.xml +1 -0
  180. data/lib/cloud/vcloud/xml/xml_templates/OrgNetworkReferences.xml +1 -0
  181. data/lib/cloud/vcloud/xml/xml_templates/OrgPasswordPolicySettings.xml +1 -0
  182. data/lib/cloud/vcloud/xml/xml_templates/OrgRecord.xml +1 -0
  183. data/lib/cloud/vcloud/xml/xml_templates/OrgReference.xml +1 -0
  184. data/lib/cloud/vcloud/xml/xml_templates/OrgReferences.xml +1 -0
  185. data/lib/cloud/vcloud/xml/xml_templates/OrgSettings.xml +1 -0
  186. data/lib/cloud/vcloud/xml/xml_templates/OrgVAppTemplateLeaseSettings.xml +1 -0
  187. data/lib/cloud/vcloud/xml/xml_templates/OrgVdcNetwork.xml +1 -0
  188. data/lib/cloud/vcloud/xml/xml_templates/OrgVdcRecord.xml +1 -0
  189. data/lib/cloud/vcloud/xml/xml_templates/OrgVdcReference.xml +1 -0
  190. data/lib/cloud/vcloud/xml/xml_templates/OrgVdcReferences.xml +1 -0
  191. data/lib/cloud/vcloud/xml/xml_templates/OrgVdcResourcePoolRelationRecord.xml +1 -0
  192. data/lib/cloud/vcloud/xml/xml_templates/Owner.xml +1 -0
  193. data/lib/cloud/vcloud/xml/xml_templates/PortgroupRecord.xml +1 -0
  194. data/lib/cloud/vcloud/xml/xml_templates/ProductSectionList.xml +1 -0
  195. data/lib/cloud/vcloud/xml/xml_templates/ProviderVdc.xml +1 -0
  196. data/lib/cloud/vcloud/xml/xml_templates/ProviderVdcResourcePoolRelationRecord.xml +1 -0
  197. data/lib/cloud/vcloud/xml/xml_templates/PublishCatalogParams.xml +1 -0
  198. data/lib/cloud/vcloud/xml/xml_templates/QueryList.xml +1 -0
  199. data/lib/cloud/vcloud/xml/xml_templates/QueryResultRecords.xml +1 -0
  200. data/lib/cloud/vcloud/xml/xml_templates/RasdItemsList.xml +1 -0
  201. data/lib/cloud/vcloud/xml/xml_templates/RecomposeVAppParams.xml +17 -0
  202. data/lib/cloud/vcloud/xml/xml_templates/Record.xml +1 -0
  203. data/lib/cloud/vcloud/xml/xml_templates/Reference.xml +1 -0
  204. data/lib/cloud/vcloud/xml/xml_templates/References.xml +1 -0
  205. data/lib/cloud/vcloud/xml/xml_templates/RelocateParams.xml +1 -0
  206. data/lib/cloud/vcloud/xml/xml_templates/ResourceEntity.xml +1 -0
  207. data/lib/cloud/vcloud/xml/xml_templates/ResourcePoolRecord.xml +1 -0
  208. data/lib/cloud/vcloud/xml/xml_templates/Right.xml +1 -0
  209. data/lib/cloud/vcloud/xml/xml_templates/RightRecord.xml +1 -0
  210. data/lib/cloud/vcloud/xml/xml_templates/RightReference.xml +1 -0
  211. data/lib/cloud/vcloud/xml/xml_templates/RightReferences.xml +1 -0
  212. data/lib/cloud/vcloud/xml/xml_templates/Role.xml +1 -0
  213. data/lib/cloud/vcloud/xml/xml_templates/RoleRecord.xml +1 -0
  214. data/lib/cloud/vcloud/xml/xml_templates/RoleReference.xml +1 -0
  215. data/lib/cloud/vcloud/xml/xml_templates/RoleReferences.xml +1 -0
  216. data/lib/cloud/vcloud/xml/xml_templates/RuntimeInfoSection.xml +1 -0
  217. data/lib/cloud/vcloud/xml/xml_templates/ScreenTicket.xml +1 -0
  218. data/lib/cloud/vcloud/xml/xml_templates/Session.xml +1 -0
  219. data/lib/cloud/vcloud/xml/xml_templates/ShadowVMReferences.xml +1 -0
  220. data/lib/cloud/vcloud/xml/xml_templates/StaticRoutingService.xml +1 -0
  221. data/lib/cloud/vcloud/xml/xml_templates/StrandedUserRecord.xml +1 -0
  222. data/lib/cloud/vcloud/xml/xml_templates/Task.xml +0 -0
  223. data/lib/cloud/vcloud/xml/xml_templates/TaskRecord.xml +1 -0
  224. data/lib/cloud/vcloud/xml/xml_templates/TaskReference.xml +1 -0
  225. data/lib/cloud/vcloud/xml/xml_templates/TaskReferences.xml +1 -0
  226. data/lib/cloud/vcloud/xml/xml_templates/TasksList.xml +1 -0
  227. data/lib/cloud/vcloud/xml/xml_templates/UndeployVAppParams.xml +1 -0
  228. data/lib/cloud/vcloud/xml/xml_templates/UploadVAppTemplateParams.xml +1 -0
  229. data/lib/cloud/vcloud/xml/xml_templates/User.xml +1 -0
  230. data/lib/cloud/vcloud/xml/xml_templates/UserRecord.xml +1 -0
  231. data/lib/cloud/vcloud/xml/xml_templates/UserReference.xml +1 -0
  232. data/lib/cloud/vcloud/xml/xml_templates/UserReferences.xml +1 -0
  233. data/lib/cloud/vcloud/xml/xml_templates/VApp.xml +1 -0
  234. data/lib/cloud/vcloud/xml/xml_templates/VAppLeaseSettings.xml +1 -0
  235. data/lib/cloud/vcloud/xml/xml_templates/VAppNetwork.xml +1 -0
  236. data/lib/cloud/vcloud/xml/xml_templates/VAppNetworkRecord.xml +1 -0
  237. data/lib/cloud/vcloud/xml/xml_templates/VAppNetworkReference.xml +1 -0
  238. data/lib/cloud/vcloud/xml/xml_templates/VAppNetworkReferences.xml +1 -0
  239. data/lib/cloud/vcloud/xml/xml_templates/VAppOrgNetworkRelationRecord.xml +1 -0
  240. data/lib/cloud/vcloud/xml/xml_templates/VAppOrgNetworkRelationReference.xml +1 -0
  241. data/lib/cloud/vcloud/xml/xml_templates/VAppOrgNetworkRelationReferences.xml +1 -0
  242. data/lib/cloud/vcloud/xml/xml_templates/VAppRecord.xml +1 -0
  243. data/lib/cloud/vcloud/xml/xml_templates/VAppReference.xml +1 -0
  244. data/lib/cloud/vcloud/xml/xml_templates/VAppReferences.xml +1 -0
  245. data/lib/cloud/vcloud/xml/xml_templates/VAppTemplate.xml +1 -0
  246. data/lib/cloud/vcloud/xml/xml_templates/VAppTemplateRecord.xml +1 -0
  247. data/lib/cloud/vcloud/xml/xml_templates/VAppTemplateReference.xml +1 -0
  248. data/lib/cloud/vcloud/xml/xml_templates/VAppTemplateReferences.xml +1 -0
  249. data/lib/cloud/vcloud/xml/xml_templates/VCloud.xml +1 -0
  250. data/lib/cloud/vcloud/xml/xml_templates/VMRecord.xml +1 -0
  251. data/lib/cloud/vcloud/xml/xml_templates/VMReference.xml +1 -0
  252. data/lib/cloud/vcloud/xml/xml_templates/VMReferences.xml +1 -0
  253. data/lib/cloud/vcloud/xml/xml_templates/VMWProviderVdcRecord.xml +1 -0
  254. data/lib/cloud/vcloud/xml/xml_templates/VMWProviderVdcReference.xml +1 -0
  255. data/lib/cloud/vcloud/xml/xml_templates/VMWProviderVdcReferences.xml +1 -0
  256. data/lib/cloud/vcloud/xml/xml_templates/Vdc.xml +1 -0
  257. data/lib/cloud/vcloud/xml/xml_templates/VdcReferences.xml +1 -0
  258. data/lib/cloud/vcloud/xml/xml_templates/VdcStorageProfile.xml +1 -0
  259. data/lib/cloud/vcloud/xml/xml_templates/VirtualCenterRecord.xml +1 -0
  260. data/lib/cloud/vcloud/xml/xml_templates/VirtualCenterReference.xml +1 -0
  261. data/lib/cloud/vcloud/xml/xml_templates/VirtualCenterReferences.xml +1 -0
  262. data/lib/cloud/vcloud/xml/xml_templates/Vm.xml +1 -0
  263. data/lib/cloud/vcloud/xml/xml_templates/VmPendingQuestion.xml +1 -0
  264. data/lib/cloud/vcloud/xml/xml_templates/VmQuestionAnswer.xml +1 -0
  265. data/lib/cloud/vcloud/xml/xml_templates/generate_dictionary.rb +8 -0
  266. data/lib/cloud/vcloud.rb +3 -7
  267. metadata +384 -88
  268. data/README +0 -26
  269. data/Rakefile +0 -50
  270. data/lib/cloud/vcloud/const.rb +0 -27
  271. data/lib/cloud/vcloud/util.rb +0 -23
  272. data/spec/assets/test-deployment-manifest.yml +0 -183
  273. data/spec/assets/test-director-config.yml +0 -73
  274. data/spec/assets/valid_stemcell.tgz +0 -0
  275. data/spec/spec_helper.rb +0 -135
  276. data/spec/unit/cloud_spec.rb +0 -506
@@ -0,0 +1,9 @@
1
+ require 'cloud/errors'
2
+
3
+ module VCloudCloud
4
+ class ObjectNotFoundError < StandardError
5
+ end
6
+
7
+ class TimeoutError < StandardError
8
+ end
9
+ end
@@ -0,0 +1,39 @@
1
+ module VCloudCloud
2
+ class FileUploader
3
+ class << self
4
+ def upload(href, size, stream, options = {})
5
+ request = create_request(href, size, stream, options)
6
+ net = create_connection(href)
7
+ net.start do |http|
8
+ response = http.request(request) { |http_response| http_response.read_body }
9
+ raise "Error Response: #{response.code} #{response.body}" if response.code.to_i >= 400
10
+ response
11
+ end
12
+ end
13
+
14
+ private
15
+
16
+ def create_request(href, size, stream, options = {})
17
+ http_method = options[:method] || :Put
18
+ headers = {}
19
+ headers['Content-Type'] = options[:content_type] if options[:content_type]
20
+ headers['X-VCloud-Authorization'] = options[:authorization] if options[:authorization]
21
+ headers['Cookie'] = options[:cookie].map { |k, v| "#{k.to_s}=#{CGI::unescape(v)}" }.sort.join(';') if options[:cookie]
22
+ headers['Content-Length'] = size.to_s
23
+ headers['Transfer-Encoding'] = 'chunked'
24
+ request_type = Net::HTTP.const_get(http_method)
25
+ request = request_type.new(href, headers)
26
+ request.body_stream = stream
27
+ request
28
+ end
29
+
30
+ def create_connection(href)
31
+ uri = URI::parse(href)
32
+ net = Net::HTTP.new(uri.host, uri.port)
33
+ net.use_ssl = uri.is_a?(URI::HTTPS)
34
+ net.verify_mode = OpenSSL::SSL::VERIFY_NONE if net.use_ssl?
35
+ net
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,28 @@
1
+ module VCloudCloud
2
+ module Steps
3
+ class AddCatalogItem < Step
4
+ def perform(catalog_type, item, &block)
5
+ catalog = client.catalog catalog_type
6
+
7
+ catalog_item = VCloudSdk::Xml::WrapperFactory.create_instance 'CatalogItem'
8
+ catalog_item.name = item.name
9
+ catalog_item.entity = item
10
+ result = client.invoke :post,
11
+ catalog.add_item_link,
12
+ :payload => catalog_item,
13
+ :headers => { :content_type => VCloudSdk::Xml::MEDIA_TYPE[:CATALOG_ITEM] }
14
+
15
+ state[:catalog_item] = result
16
+ end
17
+
18
+ def rollback
19
+ catalog_item = state[:catalog_item]
20
+ return unless catalog_item
21
+
22
+ client.invoke :delete, catalog_item
23
+ # remove the item from state
24
+ state.delete :catalog_item
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,40 @@
1
+ module VCloudCloud
2
+ module Steps
3
+ class AddNetworks < Step
4
+ def perform(networks, &block)
5
+ vapp = client.reload state[:vapp]
6
+ org_networks = client.vdc.available_networks
7
+ networks.each do |name|
8
+ @logger.debug "NETWORK ADD #{name}"
9
+ # find the corresponding accessible network object in org
10
+ org_net = org_networks.find { |n| n.name == name }
11
+ raise "Network #{name} not accesible to VDC #{client.vdc.name}" unless org_net
12
+ # clone the configuration
13
+ config = VCloudSdk::Xml::WrapperFactory.create_instance 'NetworkConfig'
14
+ copy_network_settings client.reload(org_net), config, org_net.name, VCloudSdk::Xml::FENCE_MODES[:BRIDGED]
15
+ vapp.network_config_section.add_network_config config
16
+ client.invoke_and_wait :put, vapp.network_config_section,
17
+ :payload => vapp.network_config_section,
18
+ :headers => { :content_type => VCloudSdk::Xml::MEDIA_TYPE[:NETWORK_CONFIG_SECTION] }
19
+ end
20
+ state[:vapp] = client.reload vapp
21
+ end
22
+
23
+ private
24
+
25
+ def copy_network_settings(network, network_config, vapp_net_name, fence_mode)
26
+ config_ip_scope = network_config.ip_scope
27
+ net_ip_scope = network.ip_scope
28
+ config_ip_scope.is_inherited = net_ip_scope.is_inherited?
29
+ config_ip_scope.gateway= net_ip_scope.gateway
30
+ config_ip_scope.netmask = net_ip_scope.netmask
31
+ config_ip_scope.start_address = net_ip_scope.start_address if net_ip_scope.start_address
32
+ config_ip_scope.end_address = net_ip_scope.end_address if net_ip_scope.end_address
33
+ network_config.fence_mode = fence_mode
34
+ network_config.parent_network['name'] = network.name
35
+ network_config.parent_network['href'] = network.href
36
+ network_config['networkName'] = vapp_net_name
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,15 @@
1
+ module VCloudCloud
2
+ module Steps
3
+ class AttachDetachDisk < Step
4
+ def perform(action, &block)
5
+ params = VCloudSdk::Xml::WrapperFactory.create_instance 'DiskAttachOrDetachParams'
6
+ params.disk_href = state[:disk].href
7
+ client.invoke_and_wait :post, state[:vm].send("#{action.to_s}_disk_link".to_sym),
8
+ :payload => params,
9
+ :headers => { :content_type => VCloudSdk::Xml::MEDIA_TYPE[:DISK_ATTACH_DETACH_PARAMS] }
10
+ state[:vm] = client.reload state[:vm]
11
+ state[:disk] = client.reload state[:disk]
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,29 @@
1
+ module VCloudCloud
2
+ module Steps
3
+ class CreateDisk < Step
4
+ def perform(name, size_mb, vm, &block)
5
+ params = VCloudSdk::Xml::WrapperFactory.create_instance 'DiskCreateParams'
6
+ params.name = name
7
+ params.size_bytes = size_mb << 20 # VCD expects bytes
8
+ params.bus_type = VCloudSdk::Xml::HARDWARE_TYPE[:SCSI_CONTROLLER]
9
+ params.bus_sub_type = VCloudSdk::Xml::BUS_SUB_TYPE[:LSILOGIC]
10
+ params.add_locality vm if vm
11
+ disk = client.invoke :post, client.vdc.add_disk_link,
12
+ :payload => params,
13
+ :headers => { :content_type => VCloudSdk::Xml::MEDIA_TYPE[:DISK_CREATE_PARAMS] }
14
+ state[:disk] = client.wait_entity disk
15
+ end
16
+
17
+ def rollback
18
+ disk = state[:disk]
19
+ if disk
20
+ link = disk.remove_link
21
+ client.invoke_and_wait :delete, link if link
22
+
23
+ # remove the item from state
24
+ state.delete :disk
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,41 @@
1
+ module VCloudCloud
2
+ module Steps
3
+ class CreateMedia < Step
4
+ def perform(name, iso, image_type, storage_profile, &block)
5
+ # get the file properties
6
+ media_file = File.new iso, 'rb'
7
+
8
+ # create the media item
9
+ params = VCloudSdk::Xml::WrapperFactory.create_instance 'Media'
10
+ params.name = name
11
+ params.size = media_file.stat.size
12
+ params.image_type = image_type
13
+ params.storage_profile = storage_profile
14
+ media = client.invoke :post, client.vdc.upload_media_link, :payload => params
15
+
16
+ # cache the newly created item
17
+ state[:media] = media
18
+ end
19
+
20
+ def rollback
21
+ # get the time to delete
22
+ media = state[:media]
23
+
24
+ client.timed_loop do
25
+ media = client.reload media
26
+ if media.running_tasks.empty?
27
+ # delete the item
28
+ client.invoke_and_wait :delete, media.delete_link
29
+ break
30
+ else
31
+ # need to wait for pending tasks to complete
32
+ media = client.wait_entity media
33
+ end
34
+ end
35
+
36
+ # remove the item from the state
37
+ state.delete :media
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,27 @@
1
+ module VCloudCloud
2
+ module Steps
3
+ class CreateTemplate < Step
4
+ def perform(name, &block)
5
+ params = VCloudSdk::Xml::WrapperFactory.create_instance 'UploadVAppTemplateParams'
6
+ params.name = name
7
+ template = client.invoke :post, client.vdc.upload_link, :payload => params
8
+
9
+ # commit states
10
+ state[:vapp_template] = template
11
+ end
12
+
13
+ def rollback
14
+ template = state[:vapp_template]
15
+ if template
16
+ if template.cancel_link
17
+ client.invoke :post, template.cancel_link
18
+ template = client.reload template
19
+ end
20
+ if template.remove_link
21
+ client.invoke_and_wait :delete, template.remove_link
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,66 @@
1
+ module VCloudCloud
2
+ module Steps
3
+ class CreateOrUpdateAgentEnv < Step
4
+ def perform(networks, environment, agent_properties, &block)
5
+ vm = state[:vm] = client.reload state[:vm]
6
+
7
+ system_disk = state[:disks][0]
8
+ ephemeral_disk = CreateOrUpdateAgentEnv.get_newly_added_disk vm, state[:disks]
9
+ state[:env] = {
10
+ 'vm' => { 'name' => vm.name, 'id' => vm.urn },
11
+ 'agent_id' => vm.name,
12
+ 'disks' => {
13
+ 'system' => system_disk.disk_id,
14
+ 'ephemeral' => ephemeral_disk.disk_id,
15
+ 'persistent' => {}
16
+ },
17
+ 'networks' => CreateOrUpdateAgentEnv.generate_network_env(vm.hardware_section.nics, networks),
18
+ 'env' => environment || {}
19
+ }.merge! agent_properties
20
+ end
21
+
22
+ private
23
+
24
+ def self.get_newly_added_disk(vm, previous_disks_list)
25
+ disks = vm.hardware_section.hard_disks
26
+ newly_added = disks - previous_disks_list
27
+ if newly_added.size != 1
28
+ raise "Expecting #{previous_disks_list.size + 1} disks, found #{disks.size}"
29
+ end
30
+ newly_added[0]
31
+ end
32
+
33
+ def self.generate_network_env(nics, networks)
34
+ nic_net = {}
35
+ nics.each do |nic|
36
+ nic_net[nic.network] = nic
37
+ end
38
+
39
+ network_env = {}
40
+ networks.each do |network_name, network|
41
+ network_entry = network.dup
42
+ v_network_name = network['cloud_properties']['name']
43
+ nic = nic_net[v_network_name]
44
+ next if nic.nil?
45
+ network_entry['mac'] = nic.mac_address
46
+ network_env[network_name] = network_entry
47
+ end
48
+ network_env
49
+ end
50
+
51
+ public
52
+
53
+ def self.update_network_env(env, vm, networks)
54
+ env['networks'] = generate_network_env vm.hardware_section.nics, networks
55
+ end
56
+
57
+ def self.update_persistent_disk(env, vm, disk_id, previous_disks_list)
58
+ env['disks'] ||= {}
59
+ env['disks']['persistent'] ||= {}
60
+
61
+ persistent_disk = get_newly_added_disk(vm, previous_disks_list)
62
+ env['disks']['persistent'][disk_id] = persistent_disk.disk_id
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,12 @@
1
+ module VCloudCloud
2
+ module Steps
3
+ class Delete < Step
4
+ def perform(entity, force = false, &block)
5
+ entity = client.reload entity
6
+ link = entity.remove_link force
7
+ raise "#{entity.name} can't be removed" unless link
8
+ client.invoke_and_wait :delete, link
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,23 @@
1
+ module VCloudCloud
2
+ module Steps
3
+ class DeleteCatalogMedia < Step
4
+ def perform(name, &block)
5
+ catalog_media = client.catalog_item :media, name, VCloudSdk::Xml::MEDIA_TYPE[:MEDIA]
6
+ # return if doesn't exist
7
+ return unless catalog_media
8
+ media = client.resolve_link catalog_media.entity
9
+ @logger.info "DELETEMEDIA #{media.name}"
10
+ client.timed_loop do
11
+ media = client.reload media
12
+ if media.running_tasks.empty?
13
+ client.invoke_and_wait :delete, media.delete_link
14
+ client.invoke :delete, catalog_media
15
+ return
16
+ else
17
+ media = client.wait_entity media
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,20 @@
1
+ module VCloudCloud
2
+ module Steps
3
+ class DeleteUnusedNetworks < Step
4
+ def perform(network_names_in_use, &block)
5
+ vapp = client.reload state[:vapp]
6
+ networks = vapp.network_config_section.network_configs.map { |n| n.network_name }
7
+ unused = networks - network_names_in_use
8
+ if unused && !unused.empty?
9
+ unused.uniq.each do |n|
10
+ vapp.network_config_section.delete_network_config n
11
+ end
12
+ client.invoke_and_wait :put, vapp.network_config_section,
13
+ :payload => vapp.network_config_section,
14
+ :headers => { :content_type => VCloudSdk::Xml::MEDIA_TYPE[:NETWORK_CONFIG_SECTION] }
15
+ state[:vapp] = client.reload vapp
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,15 @@
1
+ module VCloudCloud
2
+ module Steps
3
+ class DiscardSuspendedState < Step
4
+ def perform(ref, &block)
5
+ entity = client.reload state[ref]
6
+ if entity['status'] != VCloudSdk::Xml::RESOURCE_ENTITY_STATUS[:SUSPENDED].to_s
7
+ @logger.debug "#{entity.name} not suspended"
8
+ return
9
+ end
10
+ client.invoke_and_wait :post, entity.discard_state
11
+ state[ref] = client.reload entity
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,29 @@
1
+ module VCloudCloud
2
+ module Steps
3
+ class EjectCatalogMedia < Step
4
+ def perform(name, &block)
5
+ catalog_media = client.catalog_item :media, name, VCloudSdk::Xml::MEDIA_TYPE[:MEDIA]
6
+ # return if doesn't exist
7
+ return unless catalog_media
8
+ media = client.resolve_link catalog_media.entity
9
+ params = VCloudSdk::Xml::WrapperFactory.create_instance 'MediaInsertOrEjectParams'
10
+ params.media_href = media.href
11
+ vm = state[:vm]
12
+ @logger.debug "EJECTMEDIA #{media.name} from VM #{vm.name}"
13
+ client.timed_loop do
14
+ media = client.reload media
15
+ vm = client.reload vm
16
+ if media.running_tasks.empty?
17
+ client.invoke_and_wait :post, vm.eject_media_link,
18
+ :payload => params,
19
+ :headers => { :content_type => VCloudSdk::Xml::MEDIA_TYPE[:MEDIA_INSERT_EJECT_PARAMS] }
20
+ break
21
+ else
22
+ media = client.wait_entity media
23
+ end
24
+ end
25
+ state[:vm] = client.reload vm
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,26 @@
1
+ module VCloudCloud
2
+ module Steps
3
+ class InsertCatalogMedia < Step
4
+ def perform(name, &block)
5
+ media, _ = client.media name
6
+ params = VCloudSdk::Xml::WrapperFactory.create_instance 'MediaInsertOrEjectParams'
7
+ params.media_href = media.href
8
+ vm = state[:vm]
9
+ @logger.debug "INSERTMEDIA #{media.name} into VM #{vm.name}"
10
+ client.timed_loop do
11
+ media = client.reload media
12
+ vm = client.reload vm
13
+ if media.running_tasks.empty?
14
+ client.invoke_and_wait :post, vm.insert_media_link,
15
+ :payload => params,
16
+ :headers => { :content_type => VCloudSdk::Xml::MEDIA_TYPE[:MEDIA_INSERT_EJECT_PARAMS] }
17
+ break
18
+ else
19
+ media = client.wait_entity media
20
+ end
21
+ end
22
+ state[:vm] = client.reload vm
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,59 @@
1
+ module VCloudCloud
2
+ module Steps
3
+ # Create a vApp from a vApp template
4
+ # Ref: http://pubs.vmware.com/vcd-51/index.jsp?topic=%2Fcom.vmware.vcloud.api.reference.doc_51%2Fdoc%2Foperations%2FPOST-InstantiateVAppTemplate.html
5
+ class Instantiate < Step
6
+ def perform(template_id, vapp_name, description, disk_locality, &block)
7
+ catalog_item = client.resolve_entity template_id
8
+ raise ObjectNotFoundError, "Invalid vApp template Id: #{template_id}" unless catalog_item
9
+ template = client.resolve_link catalog_item.entity
10
+
11
+ params = VCloudSdk::Xml::WrapperFactory.create_instance 'InstantiateVAppTemplateParams'
12
+ params.name = vapp_name
13
+ params.description = description
14
+ params.source = template
15
+ params.all_eulas_accepted = true
16
+ params.linked_clone = false
17
+ params.set_locality = locality_spec template, disk_locality
18
+
19
+ vapp = client.invoke :post, client.vdc.instantiate_vapp_template_link, :payload => params
20
+
21
+ state[:vapp] = client.wait_entity vapp
22
+ end
23
+
24
+ def rollback
25
+ vapp = state[:vapp]
26
+ if vapp
27
+ @logger.debug "Requesting vApp: #{vapp.name}"
28
+
29
+ # Note that when renaming vApp, the remove_link stays the same and points to
30
+ # the original vApp. To avoid potential inconsistency, fetch vApp from the server.
31
+ begin
32
+ client.flush_cache # flush cached vdc which contains vapp list
33
+ vapp = client.vapp_by_name vapp.name
34
+ link = vapp.remove_link true
35
+ client.invoke_and_wait :delete, link if link
36
+ rescue => ex
37
+ @logger.debug(ex) if @logger
38
+ end
39
+
40
+ # remove the item from state
41
+ state.delete :vapp
42
+ end
43
+ end
44
+
45
+ private
46
+
47
+ def locality_spec(template, disk_locality)
48
+ locality = {}
49
+ disk_locality.each do |disk|
50
+ next unless disk
51
+ template.vms.each do |vm|
52
+ locality[vm] = disk
53
+ end
54
+ end
55
+ locality
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,14 @@
1
+ require 'yajl'
2
+
3
+ module VCloudCloud
4
+ module Steps
5
+ class LoadAgentEnv < Step
6
+ def perform(&block)
7
+ vm = state[:vm] = client.reload state[:vm]
8
+ metadata_link = "#{vm.metadata_link.href}/#{state[:env_metadata_key]}"
9
+ metadata = client.invoke :get, metadata_link
10
+ state[:env] = Yajl.load(metadata.value || '{}')
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,21 @@
1
+ module VCloudCloud
2
+ module Steps
3
+ class PowerOff < Step
4
+ def perform(ref, discard_suspend_state = false, &block)
5
+ entity = client.reload state[ref]
6
+ if entity['status'] == VCloudSdk::Xml::RESOURCE_ENTITY_STATUS[:POWERED_OFF].to_s
7
+ @logger.debug "#{entity.name} already powered off"
8
+ return
9
+ end
10
+ if discard_suspend_state && entity['status'] == VCloudSdk::Xml::RESOURCE_ENTITY_STATUS[:SUSPENDED].to_s
11
+ client.invoke_and_wait :post, entity.discard_state
12
+ entity = state[ref] = client.reload entity
13
+ end
14
+ poweroff_link = entity.power_off_link
15
+ raise "#{entity.name} unable to power off" unless poweroff_link
16
+ client.invoke_and_wait :post, poweroff_link
17
+ state[ref] = client.reload entity
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ module VCloudCloud
2
+ module Steps
3
+ class PowerOn < Step
4
+ def perform(ref, &block)
5
+ entity = client.reload state[ref]
6
+ if entity['status'] == VCloudSdk::Xml::RESOURCE_ENTITY_STATUS[:POWERED_ON].to_s
7
+ @logger.debug "#{entity.name} already powered on"
8
+ return
9
+ end
10
+ poweron_link = entity.power_on_link
11
+ raise "#{entity.name} unable to power on" unless poweron_link
12
+ client.invoke_and_wait :post, poweron_link
13
+ state[ref] = client.reload entity
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ module VCloudCloud
2
+ module Steps
3
+ class Reboot < Step
4
+ def perform(ref, &block)
5
+ entity = client.reload state[ref]
6
+ reboot_link = entity.reboot_link
7
+ raise "#{entity.name} unable to reboot" unless reboot_link
8
+ client.invoke_and_wait :post, reboot_link
9
+ state[ref] = client.reload entity
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,19 @@
1
+ module VCloudCloud
2
+ module Steps
3
+ # Recompose a vApp to add or remove VMs.
4
+ # Ref: http://pubs.vmware.com/vcd-51/index.jsp#operations/POST-RecomposeVApp.html
5
+
6
+ class Recompose < Step
7
+ def perform(name, container_vapp, vm = nil, &block)
8
+ params = VCloudSdk::Xml::WrapperFactory.create_instance 'RecomposeVAppParams'
9
+ params.name = name
10
+ params.all_eulas_accepted = true
11
+ params.add_source_item vm.href if vm
12
+
13
+ # HACK: Workaround. recomposeLink is not available when vapp is running (so force construct the link)
14
+ recompose_vapp_link = container_vapp.recompose_vapp_link true
15
+ client.invoke_and_wait :post, recompose_vapp_link, :payload => params
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,35 @@
1
+ module VCloudCloud
2
+ module Steps
3
+ class ReconfigureVM < Step
4
+ def perform(name, description, resource_pool, networks, &block)
5
+ vapp = state[:vapp] = client.reload state[:vapp]
6
+ vm = state[:vm] = client.reload state[:vm]
7
+
8
+ vm.name = name unless name.nil?
9
+ vm.description = description unless description.nil?
10
+
11
+ unless resource_pool.nil?
12
+ vm.change_cpu_count Integer(resource_pool['cpu'])
13
+ vm.change_memory Integer(resource_pool['ram'])
14
+ vm.add_hard_disk Integer(resource_pool['disk'])
15
+ end
16
+
17
+ unless networks.nil?
18
+ vm.delete_nic *vm.hardware_section.nics
19
+
20
+ networks.values.each_with_index do |network, nic_index|
21
+ name = network['cloud_properties']['name']
22
+ vm.add_nic nic_index, name, VCloudSdk::Xml::IP_ADDRESSING_MODE[:MANUAL], network['ip']
23
+ vm.connect_nic nic_index, name, VCloudSdk::Xml::IP_ADDRESSING_MODE[:MANUAL], network['ip']
24
+ end
25
+ end
26
+
27
+ client.invoke_and_wait :post, vm.reconfigure_link,
28
+ :payload => vm,
29
+ :headers => { :content_type => VCloudSdk::Xml::MEDIA_TYPE[:VM] }
30
+
31
+ state[:vm] = client.reload vm
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,43 @@
1
+ require 'common/common'
2
+ require 'yajl'
3
+
4
+ module VCloudCloud
5
+ module Steps
6
+ class SaveAgentEnv < Step
7
+ def perform(&block)
8
+ vm = client.reload state[:vm]
9
+ metadata_link = "#{vm.metadata_link.href}/#{state[:env_metadata_key]}"
10
+
11
+ @logger.debug "AGENT_ENV #{vm.urn} #{state[:env].inspect}"
12
+
13
+ env_json = Yajl::Encoder.encode state[:env]
14
+ @logger.debug "ENV.ISO Content: #{env_json}"
15
+ tmpdir = state[:tmpdir] = Dir.mktmpdir
16
+ env_path = File.join tmpdir, 'env'
17
+ iso_path = File.join tmpdir, 'env.iso'
18
+ File.open(env_path, 'w') { |f| f.write env_json }
19
+ output = `#{genisoimage} -o #{iso_path} #{env_path} 2>&1`
20
+ @logger.debug "GENISOIMAGE #{output}"
21
+ raise "genisoimage: #{$?.exitstatus}: #{output}" unless $?.success?
22
+
23
+ metadata = VCloudSdk::Xml::WrapperFactory.create_instance 'MetadataValue'
24
+ metadata.value = env_json
25
+ client.invoke_and_wait :put, metadata_link,
26
+ :payload => metadata,
27
+ :headers => { :content_type => VCloudSdk::Xml::MEDIA_TYPE[:METADATA_ITEM_VALUE] }
28
+ state[:vm] = client.reload state[:vm]
29
+ state[:iso] = iso_path
30
+ end
31
+
32
+ def cleanup
33
+ FileUtils.remove_entry_secure state[:tmpdir] if state[:tmpdir]
34
+ end
35
+
36
+ private
37
+
38
+ def genisoimage # TODO: this should exist in bosh_common, eventually
39
+ @genisoimage ||= Bosh::Common.which(%w{genisoimage mkisofs})
40
+ end
41
+ end
42
+ end
43
+ end