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,292 @@
1
+ require "nokogiri"
2
+
3
+ module VCloudSdk
4
+ module Xml
5
+
6
+ class WrapperFactory
7
+ @@xml_dictionary = {}
8
+ class << self
9
+ def wrap_document(xml, ns = nil, namespace_defintions = nil, *args)
10
+ doc = Nokogiri::XML(xml)
11
+ type_name = doc.root.name
12
+ node_class = find_wrapper_class(type_name)
13
+ node_class.new(doc, ns, namespace_defintions, *args)
14
+ end
15
+
16
+ def wrap_node(node, ns, namespace_defintions = nil, *args)
17
+ type_name = node.node_name
18
+ node_class = find_wrapper_class(type_name)
19
+ node_class.new(node, ns, namespace_defintions, *args)
20
+ end
21
+
22
+ def wrap_nodes(nodes, ns, namespace_defintions)
23
+ nodes.collect { |node| WrapperFactory.wrap_node(node, ns,
24
+ namespace_defintions) }
25
+ end
26
+
27
+ # TODO: We might run into a bug later if there are ever XML node types
28
+ # of the same name but different namespace
29
+ def find_wrapper_class(type_name)
30
+ # for Ruby 1.9, we would need pass false in as the 2nd parameter
31
+ if Xml.constants.find { |c| c.to_sym == type_name.to_sym }
32
+ Xml.const_get(type_name.to_sym)
33
+ else
34
+ Wrapper
35
+ end
36
+ end
37
+
38
+ def create_instance(type_name, ns = nil, namespace_defintions = nil,
39
+ *args)
40
+ xml = @@xml_dictionary[type_name]
41
+ if (xml)
42
+ wrap_document(xml, ns, namespace_defintions, *args)
43
+ else
44
+ raise Bosh::Clouds::CpiError,
45
+ "XML type #{type_name} not found in xml_templates dir."
46
+ end
47
+ end
48
+
49
+ # Load all the XML files
50
+ Dir[File.dirname(__FILE__) + "/xml_templates/*.xml"].each do |f|
51
+ @@xml_dictionary[File.basename(f, ".xml")] =
52
+ File.open(File.expand_path(f)).read
53
+ end
54
+ end
55
+ end
56
+
57
+ class Wrapper
58
+ # Because we are wrapping individual nodes in a wrapper and turning them
59
+ # into XML docs, we need to preserve the namespace information with each
60
+ # node
61
+ def initialize(xml, ns = nil, ns_definitions = nil)
62
+ if xml.is_a?(Nokogiri::XML::Document)
63
+ @doc = xml
64
+ @root = @doc.root
65
+ else
66
+ @root = xml
67
+ end
68
+ if ns
69
+ @ns = ns
70
+ else
71
+ @ns = @root.namespace
72
+ end
73
+
74
+ # Use (server) supplied prefixes defaulting to the preset ones for
75
+ # those not specified.
76
+ @doc_namespaces = ns_definitions.nil? ? Array.new :
77
+ Array.new(ns_definitions)
78
+ if @root.namespace_definitions
79
+ @doc_namespaces.concat(@root.namespace_definitions)
80
+ end
81
+ end
82
+
83
+ def doc_namespaces
84
+ @doc_namespaces
85
+ end
86
+
87
+ def xpath(*args)
88
+ WrapperFactory::wrap_nodes(@root.xpath(*args), @ns, @doc_namespaces)
89
+ end
90
+
91
+ def href
92
+ @root["href"]
93
+ end
94
+
95
+ def name
96
+ @root["name"]
97
+ end
98
+
99
+ def urn
100
+ @root["id"]
101
+ end
102
+
103
+ def type
104
+ @root["type"]
105
+ end
106
+
107
+ def attribute_with_ns(attr, ns)
108
+ @root.attribute_with_ns(attr, ns)
109
+ end
110
+
111
+ def create_xpath_query(type_name, attrs = nil, only_immediate = false,
112
+ namespace = VCLOUD_NAMESPACE)
113
+ qualified_name = create_qualified_name(type_name, namespace)
114
+ depth_prefix = only_immediate ? nil : ".//"
115
+ if attrs && attrs.length > 0
116
+ attrs_list = []
117
+ attrs.each do |k,v|
118
+ attrs_list.push(%Q[@#{k}="#{v}"])
119
+ end
120
+
121
+ "#{depth_prefix}#{qualified_name}[#{attrs_list.join(" and ")}]"
122
+ else
123
+ "#{depth_prefix}#{qualified_name}"
124
+ end
125
+ end
126
+
127
+ def create_qualified_name(name, href)
128
+ namespace_wanted = nil
129
+ ns_wanted_no_prefix = nil
130
+ # Do it this way so the namespaces are searched in the order they are
131
+ # added. The first one is the one closest to the node, while the ones
132
+ # at the document root are the last.
133
+ @doc_namespaces.each do |ns|
134
+ if ns.href == href
135
+ if ns.prefix.nil?
136
+ ns_wanted_no_prefix = ns;
137
+ else
138
+ namespace_wanted = ns
139
+ break
140
+ end
141
+ end
142
+ end
143
+ namespace_wanted = ns_wanted_no_prefix unless namespace_wanted
144
+ raise Bosh::Clouds::CpiError, "Namespace #{href} not found." unless namespace_wanted
145
+ ns_prefix = namespace_wanted.prefix.nil? ? "xmlns" :
146
+ namespace_wanted.prefix
147
+ "#{ns_prefix}:#{name}"
148
+ end
149
+
150
+ def get_nodes(type_name, attrs = nil, only_immediate = false,
151
+ namespace = VCLOUD_NAMESPACE)
152
+ xpath(create_xpath_query(type_name, attrs, only_immediate, namespace))
153
+ end
154
+
155
+ def [](attr)
156
+ @root[attr]
157
+ end
158
+
159
+ def []=(attr, value)
160
+ @root[attr] = value
161
+ end
162
+
163
+ def content
164
+ @root.content
165
+ end
166
+
167
+ def content=(value)
168
+ @root.content = value
169
+ end
170
+
171
+ def ==(other)
172
+ @root.to_s == other.node.to_s
173
+ end
174
+
175
+ def to_s
176
+ add_namespaces.to_xml.each_line.inject("") {
177
+ |xml, line| xml.concat(line.sub(/^\s+$/, "")) }
178
+ end
179
+
180
+ def add_child(child, namespace_prefix = nil, namespace_href = nil,
181
+ parent = @root)
182
+ if child.is_a? Wrapper
183
+ parent.add_child(child.node)
184
+ elsif child.is_a? String
185
+ node = Nokogiri::XML::Node.new(child, parent)
186
+ if (namespace_prefix.nil? ^ namespace_href.nil?)
187
+ raise Bosh::Clouds::CpiError,
188
+ "Namespace prefix must both be nil or defined together."
189
+ end
190
+ # This is a little more cumbersome but Nokogiri has problems
191
+ # figuring out the right namespace prefix otherwise
192
+ if namespace_prefix
193
+ ns = node.add_namespace_definition(namespace_prefix,
194
+ namespace_href)
195
+ node.namespace = ns
196
+ end
197
+ parent.add_child(node)
198
+ else
199
+ raise Bosh::Clouds::CpiError, "Cannot add child. Unknown object passed in."
200
+ end
201
+ end
202
+
203
+ # Creates a child node but does not add it to the document. Used when
204
+ # a new child node has to be in a specific location or order.
205
+ def create_child(tag)
206
+ Nokogiri::XML::Node.new(tag, @root)
207
+ end
208
+
209
+ protected
210
+
211
+ def node
212
+ @root
213
+ end
214
+
215
+ def namespace
216
+ @ns
217
+ end
218
+
219
+ def namespace_definitions
220
+ @doc_namespaces
221
+ end
222
+
223
+ def fix_if_invalid(link, rel, type, href)
224
+ if link.nil? || link.href.to_s.nil?
225
+ link = Xml::WrapperFactory.create_instance("Link")
226
+ link.rel = rel
227
+ link.type = type
228
+ link.href = href
229
+ end
230
+ link
231
+ end
232
+
233
+ private
234
+
235
+ def add_namespaces
236
+ clone = @root.clone
237
+
238
+ # This is a workaround for a Nokogiri bug. If you add a namespace
239
+ # with a nil for prefix, i.e. the namespace following xmlns, Nokogiri
240
+ # will remove the original namespace and assume you are setting a new
241
+ # namespace for the node.
242
+ default_ns = clone.namespace
243
+
244
+ @doc_namespaces.each do |ns|
245
+ clone.add_namespace_definition(ns.prefix, ns.href)
246
+ end
247
+ clone.namespace = default_ns
248
+ clone
249
+ end
250
+ end
251
+
252
+ end
253
+ end
254
+
255
+ require_relative "wrapper_classes/item"
256
+ require_relative "wrapper_classes/admin_catalog"
257
+ require_relative "wrapper_classes/admin_org"
258
+ require_relative "wrapper_classes/catalog"
259
+ require_relative "wrapper_classes/catalog_item"
260
+ require_relative "wrapper_classes/disk"
261
+ require_relative "wrapper_classes/disk_attach_or_detach_params"
262
+ require_relative "wrapper_classes/disk_create_params"
263
+ require_relative "wrapper_classes/entity"
264
+ require_relative "wrapper_classes/file"
265
+ require_relative "wrapper_classes/hard_disk_item_wrapper"
266
+ require_relative "wrapper_classes/instantiate_vapp_template_params"
267
+ require_relative "wrapper_classes/ip_scope"
268
+ require_relative "wrapper_classes/link_wrapper"
269
+ require_relative "wrapper_classes/media"
270
+ require_relative "wrapper_classes/media_insert_or_eject_params"
271
+ require_relative "wrapper_classes/metadata_value"
272
+ require_relative "wrapper_classes/network"
273
+ require_relative "wrapper_classes/network_config"
274
+ require_relative "wrapper_classes/network_config_section"
275
+ require_relative "wrapper_classes/network_connection"
276
+ require_relative "wrapper_classes/network_connection_section"
277
+ require_relative "wrapper_classes/nic_item_wrapper"
278
+ require_relative "wrapper_classes/org"
279
+ require_relative "wrapper_classes/org_network"
280
+ require_relative "wrapper_classes/org_vdc_network"
281
+ require_relative "wrapper_classes/recompose_vapp_wrapper"
282
+ require_relative "wrapper_classes/session"
283
+ require_relative "wrapper_classes/supported_versions"
284
+ require_relative "wrapper_classes/task"
285
+ require_relative "wrapper_classes/upload_vapp_template_params"
286
+ require_relative "wrapper_classes/vapp"
287
+ require_relative "wrapper_classes/vapp_template"
288
+ require_relative "wrapper_classes/vcloud"
289
+ require_relative "wrapper_classes/vdc"
290
+ require_relative "wrapper_classes/vdc_storage_profile"
291
+ require_relative "wrapper_classes/virtual_hardware_section"
292
+ require_relative "wrapper_classes/vm"
@@ -0,0 +1,20 @@
1
+ module VCloudSdk
2
+ module Xml
3
+
4
+ class AdminCatalog < Wrapper
5
+ def add_item_link
6
+ get_nodes("Link", {"type"=>ADMIN_MEDIA_TYPE[:CATALOG_ITEM],
7
+ "rel"=>"add"}).first
8
+ end
9
+
10
+ def catalog_items(name = nil)
11
+ if name
12
+ get_nodes("CatalogItem", {"name" => name})
13
+ else
14
+ get_nodes("CatalogItem")
15
+ end
16
+ end
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,15 @@
1
+ module VCloudSdk
2
+ module Xml
3
+
4
+ class AdminOrg < Wrapper
5
+ def vdc(name)
6
+ get_nodes("Vdc", {"name"=>name}).first
7
+ end
8
+
9
+ def catalog(name)
10
+ get_nodes("CatalogReference", {"name"=>name}).first
11
+ end
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,20 @@
1
+ module VCloudSdk
2
+ module Xml
3
+
4
+ class Catalog < Wrapper
5
+ def add_item_link
6
+ get_nodes("Link", {"type" => MEDIA_TYPE[:CATALOG_ITEM],
7
+ "rel"=>"add"}).first
8
+ end
9
+
10
+ def catalog_items(name = nil)
11
+ if name
12
+ get_nodes("CatalogItem", {"name" => name})
13
+ else
14
+ get_nodes("CatalogItem")
15
+ end
16
+ end
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,27 @@
1
+ module VCloudSdk
2
+ module Xml
3
+
4
+ class CatalogItem < Wrapper
5
+ def name=(name)
6
+ @root["name"] = name
7
+ end
8
+
9
+ def remove_link
10
+ get_nodes("Link", {"rel" => "remove"}, true).first
11
+ end
12
+
13
+ def entity=(entity)
14
+ entity_node = get_nodes("Entity").first
15
+ entity_node["name"] = entity.name
16
+ entity_node["id"] = entity.urn
17
+ entity_node["href"] = entity.href
18
+ entity_node["type"] = entity.type
19
+ end
20
+
21
+ def entity
22
+ get_nodes("Entity").first
23
+ end
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,42 @@
1
+ module VCloudSdk
2
+ module Xml
3
+
4
+ class Disk < Wrapper
5
+ def bus_type=(value)
6
+ @root["busType"] = value.to_s
7
+ end
8
+
9
+ def bus_sub_type=(value)
10
+ @root["busSubType"] = value.to_s
11
+ end
12
+
13
+ def remove_link(force = false)
14
+ link = get_nodes("Link", {"rel" => "remove"}, true).first
15
+ return link unless force
16
+ fix_if_invalid(link, "remove", MEDIA_TYPE[:DISK], "#{href}")
17
+ end
18
+
19
+ def name=(name)
20
+ @root["name"] = name.to_s
21
+ end
22
+
23
+ def size_mb
24
+ @root["size"].to_i/1024/1024
25
+ end
26
+
27
+ def running_tasks
28
+ tasks.find_all {|t| RUNNING.include?(t.status)}
29
+ end
30
+
31
+ def tasks
32
+ get_nodes("Task")
33
+ end
34
+
35
+ private
36
+
37
+ RUNNING = [TASK_STATUS[:RUNNING], TASK_STATUS[:QUEUED],
38
+ TASK_STATUS[:PRE_RUNNING]]
39
+ end
40
+
41
+ end
42
+ end
@@ -0,0 +1,12 @@
1
+ module VCloudSdk
2
+ module Xml
3
+
4
+ class DiskAttachOrDetachParams < Wrapper
5
+ def disk_href=(value)
6
+ disk = get_nodes("Disk").first
7
+ disk["href"] = value.to_s
8
+ end
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,47 @@
1
+ module VCloudSdk
2
+ module Xml
3
+
4
+ class DiskCreateParams < Wrapper
5
+ def bus_type=(value)
6
+ disk["busType"] = value.to_s
7
+ end
8
+
9
+ def bus_sub_type=(value)
10
+ disk["busSubType"] = value.to_s
11
+ end
12
+
13
+ def name=(name)
14
+ disk["name"] = name.to_s
15
+ end
16
+
17
+ def size_bytes=(value)
18
+ disk["size"] = value.to_s
19
+ end
20
+
21
+ def add_locality(local)
22
+ if !@local_exists.nil? && @local_exists
23
+ raise "Cannot add locality more than once to DiskCreateParams"
24
+ end
25
+ @local_exists = true
26
+ node = create_child("Locality")
27
+ node["href"] = local.href
28
+ # Bug in create independent disk API. It needs the UUID part of the
29
+ # ID instead of the entire ID like other REST API calls.
30
+ node["id"] = extract_uuid(local.urn)
31
+ node["type"] = MEDIA_TYPE[:VM]
32
+ disk.node.after(node)
33
+ end
34
+
35
+ private
36
+
37
+ def disk
38
+ get_nodes("Disk").first
39
+ end
40
+
41
+ def extract_uuid(id)
42
+ id.split(":").first
43
+ end
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,11 @@
1
+ module VCloudSdk
2
+ module Xml
3
+
4
+ class Entity < Wrapper
5
+ def link
6
+ get_nodes("Link").first
7
+ end
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module VCloudSdk
2
+ module Xml
3
+
4
+ class File < Wrapper
5
+ def upload_link
6
+ get_nodes("Link", {"rel"=>"upload:default"}).first
7
+ end
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,56 @@
1
+ module VCloudSdk
2
+ module Xml
3
+
4
+ class HardDiskItemWrapper < Item
5
+ def hash
6
+ [disk_id, instance_id, bus_type, bus_sub_type].hash
7
+ end
8
+
9
+ def eql?(other)
10
+ disk_id == other.disk_id && instance_id == other.instance_id &&
11
+ bus_type == other.bus_type && bus_sub_type == other.bus_sub_type
12
+ end
13
+
14
+ def initialize(item)
15
+ super(item.node, item.namespace, item.namespace_definitions)
16
+ end
17
+
18
+ def capacity_mb
19
+ v = host_resource.attribute_with_ns(HOST_RESOURCE_ATTRIBUTE[:CAPACITY], VCLOUD_NAMESPACE)
20
+ v && v.value
21
+ end
22
+
23
+ def disk_href
24
+ v = host_resource.attribute_with_ns(HOST_RESOURCE_ATTRIBUTE[:DISK], VCLOUD_NAMESPACE)
25
+ v && v.value
26
+ end
27
+
28
+ def disk_id
29
+ get_rasd_content(RASD_TYPES[:ADDRESS_ON_PARENT])
30
+ end
31
+
32
+ def instance_id
33
+ get_rasd_content(RASD_TYPES[:INSTANCE_ID])
34
+ end
35
+
36
+ def bus_sub_type
37
+ v = host_resource.attribute_with_ns(HOST_RESOURCE_ATTRIBUTE[:BUS_SUB_TYPE], VCLOUD_NAMESPACE)
38
+ v && v.value
39
+ end
40
+
41
+ def bus_type
42
+ v = host_resource.attribute_with_ns(HOST_RESOURCE_ATTRIBUTE[:BUS_TYPE], VCLOUD_NAMESPACE)
43
+ v && v.value
44
+ end
45
+
46
+ def parent_instance_id
47
+ get_rasd_content(RASD_TYPES[:PARENT])
48
+ end
49
+
50
+ def host_resource
51
+ get_rasd(RASD_TYPES[:HOST_RESOURCE])
52
+ end
53
+ end
54
+
55
+ end
56
+ end
@@ -0,0 +1,71 @@
1
+ module VCloudSdk
2
+ module Xml
3
+
4
+ class InstantiateVAppTemplateParams < Wrapper
5
+ def name
6
+ @root["name"]
7
+ end
8
+
9
+ def description
10
+ get_nodes("Description").first
11
+ end
12
+
13
+ def all_eulas_accepted=(value)
14
+ eulas_node = get_nodes("AllEULAsAccepted").first
15
+ eulas_node.content = value
16
+ end
17
+
18
+ def name=(name)
19
+ @root["name"] = name
20
+ end
21
+
22
+ def description=(desc)
23
+ description.content = desc
24
+ end
25
+
26
+ def linked_clone=(value)
27
+ @root["linkedClone"] = value.to_s
28
+ end
29
+
30
+ def source=(src)
31
+ source_node = get_nodes("Source").first
32
+ source_node["href"] = src["href"]
33
+ source_node["id"] = src["id"]
34
+ source_node["type"] = src["type"]
35
+ source_node["id"] = src["id"]
36
+ end
37
+
38
+ def set_locality=(locality)
39
+ return unless locality
40
+
41
+ raise "vApp locality already set." if @local_exists
42
+ @local_exists = true
43
+
44
+ locality.each do |k,v|
45
+ node_sp = create_child("SourcedVmInstantiationParams")
46
+ is_source_delete.node.after(node_sp)
47
+
48
+ node_sv = add_child("Source", nil, nil, node_sp)
49
+ node_sv["type"] = k.type
50
+ node_sv["name"] = k.name
51
+ node_sv["href"] = k.href
52
+
53
+ node_lp = create_child("LocalityParams")
54
+ node_sv.after(node_lp)
55
+
56
+ node_re = add_child("ResourceEntity", nil, nil, node_lp)
57
+ node_re["type"] = v.type
58
+ node_re["name"] = v.name
59
+ node_re["href"] = v.href
60
+ end
61
+ end
62
+
63
+ private
64
+
65
+ def is_source_delete
66
+ get_nodes("IsSourceDelete").first
67
+ end
68
+ end
69
+
70
+ end
71
+ end
@@ -0,0 +1,55 @@
1
+ module VCloudSdk
2
+ module Xml
3
+
4
+ class IpScope < Wrapper
5
+ def is_inherited?
6
+ get_nodes("IsInherited").first.content
7
+ end
8
+
9
+ def is_inherited=(value)
10
+ get_nodes("IsInherited").first.content = value
11
+ end
12
+
13
+ def gateway
14
+ get_nodes("Gateway").first.content
15
+ end
16
+
17
+ def gateway=(value)
18
+ get_nodes("Gateway").first.content = value
19
+ end
20
+
21
+ def netmask
22
+ get_nodes("Netmask").first.content
23
+ end
24
+
25
+ def netmask=(value)
26
+ get_nodes("Netmask").first.content = value
27
+ end
28
+
29
+ def start_address
30
+ nodes = get_nodes("StartAddress")
31
+ return nil unless nodes
32
+ node = nodes.first
33
+ return nil unless node
34
+ return node.content
35
+ end
36
+
37
+ def start_address=(value)
38
+ get_nodes("StartAddress").first.content = value
39
+ end
40
+
41
+ def end_address
42
+ nodes = get_nodes("EndAddress")
43
+ return nil unless nodes
44
+ node = nodes.first
45
+ return nil unless node
46
+ return node.content
47
+ end
48
+
49
+ def end_address=(value)
50
+ get_nodes("EndAddress").first.content = value
51
+ end
52
+ end
53
+
54
+ end
55
+ end