ruby_vcloud_sdk 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -0
- data/Rakefile +50 -0
- data/lib/ruby_vcloud_sdk.rb +19 -0
- data/lib/ruby_vcloud_sdk/client.rb +899 -0
- data/lib/ruby_vcloud_sdk/config.rb +17 -0
- data/lib/ruby_vcloud_sdk/connection/connection.rb +163 -0
- data/lib/ruby_vcloud_sdk/connection/file_uploader.rb +43 -0
- data/lib/ruby_vcloud_sdk/errors.rb +21 -0
- data/lib/ruby_vcloud_sdk/ovf_directory.rb +45 -0
- data/lib/ruby_vcloud_sdk/util.rb +21 -0
- data/lib/ruby_vcloud_sdk/version.rb +3 -0
- data/lib/ruby_vcloud_sdk/xml/constants.rb +427 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper.rb +242 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes.rb +3 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/admin_catalog.rb +20 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/admin_org.rb +15 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/catalog_item.rb +27 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/disk.rb +40 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/disk_attach_or_detach_params.rb +12 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/disk_create_params.rb +47 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/entity.rb +11 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/file.rb +11 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/hard_disk_item_wrapper.rb +50 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/instantiate_vapp_template_params.rb +71 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/ip_scope.rb +55 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/item.rb +32 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/media.rb +53 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/media_insert_or_eject_params.rb +17 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/metadata_value.rb +15 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/network.rb +15 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/network_config.rb +27 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/network_config_section.rb +25 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/network_connection.rb +71 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/network_connection_section.rb +67 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/nic_item_wrapper.rb +91 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/org_network.rb +19 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/org_vdc_network.rb +11 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/session.rb +17 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/task.rb +32 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/upload_vapp_template_params.rb +11 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/vapp.rb +55 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/vapp_template.rb +19 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/vcloud.rb +15 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/vdc.rb +54 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/vdc_storage_profile.rb +15 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/virtual_hardware_section.rb +68 -0
- data/lib/ruby_vcloud_sdk/xml/wrapper_classes/vm.rb +179 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/AdminAllocatedExtIpRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/AdminCatalog.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/AdminCatalogItemRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/AdminCatalogRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/AdminGroupRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/AdminMediaRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/AdminOrg.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/AdminOrgNetworkRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/AdminShadowVmRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/AdminTaskRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/AdminUserRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/AdminVAppNetworkRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/AdminVAppRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/AdminVAppReference.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/AdminVAppReferences.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/AdminVAppTemplateRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/AdminVdc.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/AdminVdcRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/AdminVdcReference.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/AdminVdcReferences.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/AdminVmRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/AllEULAsAccepted.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/AllocatedExtIpRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/BlockingTaskRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/BlockingTaskReference.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/BlockingTaskReferences.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/CaptureVAppParams.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/Catalog.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/CatalogItem.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/CatalogItemRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/CatalogItemReference.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/CatalogItemReferences.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/CatalogRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/CatalogReference.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/CatalogReferences.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/CellRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/CloneMediaParams.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/CloneVAppParams.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/CloneVAppTemplateParams.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/ComposeVAppParams.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/ControlAccessParams.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/CustomizationSection.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/DatastoreProviderVdcRelationRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/DatastoreRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/DatastoreReference.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/DatastoreReferences.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/DeployVAppParams.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/DhcpService.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/DiskAttachOrDetachParams.xml +5 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/DiskCreateParams.xml +9 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/DvSwitchRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/Entity.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/Error.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/EventRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/ExternalNetwork.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/File.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/FirewallService.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/GeneralOrgSettings.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/Group.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/GroupRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/GroupReference.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/GroupReferences.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/GuestCustomizationSection.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/HostRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/HostReference.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/HostReferences.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/InstantiateOvfParams.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/InstantiateVAppTemplateParams.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/IpScope.xml +12 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/IpsecVpnLocalPeer.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/IpsecVpnPeer.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/IpsecVpnRemotePeer.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/IpsecVpnService.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/IpsecVpnThirdPartyPeer.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/Item.xml +3 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/ItemVcd.xml +5 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/LeaseSettingsSection.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/Link.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/Media.xml +6 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/MediaInsertOrEjectParams.xml +4 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/MediaRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/MediaReference.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/MediaReferences.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/Metadata.xml +5 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/MetadataEntry.xml +7 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/MetadataValue.xml +8 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/NatService.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/Network.xml +4 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/NetworkAssignment.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/NetworkConfig.xml +21 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/NetworkConfigSection.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/NetworkConnection.xml +11 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/NetworkConnectionSection.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/NetworkPoolRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/NetworkPoolReference.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/NetworkPoolReferences.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/NetworkRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/NetworkReference.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/NetworkReferences.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/NetworkService.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/Org.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/OrgEmailSettings.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/OrgList.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/OrgNetwork.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/OrgNetworkRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/OrgNetworkReference.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/OrgNetworkReferences.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/OrgPasswordPolicySettings.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/OrgRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/OrgReference.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/OrgReferences.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/OrgSettings.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/OrgVAppTemplateLeaseSettings.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/OrgVdcNetwork.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/OrgVdcRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/OrgVdcReference.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/OrgVdcReferences.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/OrgVdcResourcePoolRelationRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/Owner.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/PortgroupRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/ProductSectionList.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/ProviderVdc.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/ProviderVdcResourcePoolRelationRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/PublishCatalogParams.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/QueryList.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/QueryResultRecords.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/RasdItemsList.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/RecomposeVAppParams.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/Record.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/Reference.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/References.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/RelocateParams.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/ResourceEntity.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/ResourcePoolRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/Right.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/RightRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/RightReference.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/RightReferences.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/Role.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/RoleRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/RoleReference.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/RoleReferences.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/RuntimeInfoSection.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/ScreenTicket.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/Session.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/ShadowVMReferences.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/StaticRoutingService.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/StrandedUserRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/Task.xml +0 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/TaskRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/TaskReference.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/TaskReferences.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/TasksList.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/UndeployVAppParams.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/UploadVAppTemplateParams.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/User.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/UserRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/UserReference.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/UserReferences.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VApp.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VAppLeaseSettings.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VAppNetwork.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VAppNetworkRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VAppNetworkReference.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VAppNetworkReferences.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VAppOrgNetworkRelationRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VAppOrgNetworkRelationReference.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VAppOrgNetworkRelationReferences.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VAppRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VAppReference.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VAppReferences.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VAppTemplate.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VAppTemplateRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VAppTemplateReference.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VAppTemplateReferences.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VCloud.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VMRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VMReference.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VMReferences.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VMWProviderVdcRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VMWProviderVdcReference.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VMWProviderVdcReferences.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/Vdc.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VdcReferences.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VdcStorageProfile.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VirtualCenterRecord.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VirtualCenterReference.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VirtualCenterReferences.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/Vm.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VmPendingQuestion.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/VmQuestionAnswer.xml +1 -0
- data/lib/ruby_vcloud_sdk/xml/xml_templates/generate_dictionary.rb +8 -0
- data/spec/assets/admin_org_response.xml +75 -0
- data/spec/assets/catalog_add_item_response.xml +8 -0
- data/spec/assets/catalog_add_vapp_request.xml +5 -0
- data/spec/assets/catalog_item_added_response.xml +19 -0
- data/spec/assets/catalog_response.xml +19 -0
- data/spec/assets/existing_media_busy_response.xml +19 -0
- data/spec/assets/existing_media_catalog_item.xml +8 -0
- data/spec/assets/existing_media_delete_task_done.xml +6 -0
- data/spec/assets/existing_media_done_response.xml +11 -0
- data/spec/assets/existing_vapp_resolver_response.xml +3 -0
- data/spec/assets/existing_vapp_template_catalog_resolver_response.xml +3 -0
- data/spec/assets/existing_vapp_template_instantiate_response.xml +20 -0
- data/spec/assets/existing_vapp_template_instantiate_task_error_response.xml +7 -0
- data/spec/assets/existing_vapp_template_instantiate_task_start_response.xml +7 -0
- data/spec/assets/existing_vapp_template_instantiate_task_success_response.xml +7 -0
- data/spec/assets/existing_vapp_template_item_response.xml +8 -0
- data/spec/assets/existing_vapp_template_ready_response.xml +79 -0
- data/spec/assets/finalize_upload_task_done_response.xml +7 -0
- data/spec/assets/finalize_upload_task_response.xml +7 -0
- data/spec/assets/indy_disk_attach_request.xml +3 -0
- data/spec/assets/indy_disk_attach_task.xml +6 -0
- data/spec/assets/indy_disk_attach_task_error.xml +6 -0
- data/spec/assets/indy_disk_create_error.xml +1 -0
- data/spec/assets/indy_disk_create_request.xml +4 -0
- data/spec/assets/indy_disk_create_response.xml +19 -0
- data/spec/assets/indy_disk_delete_task.xml +6 -0
- data/spec/assets/indy_disk_detach_request.xml +3 -0
- data/spec/assets/indy_disk_detach_task.xml +6 -0
- data/spec/assets/indy_disk_response.xml +11 -0
- data/spec/assets/instantiated_suspended_vapp_response.xml +209 -0
- data/spec/assets/instantiated_vapp_delelete_done_task.xml +5 -0
- data/spec/assets/instantiated_vapp_delelete_running_task.xml +6 -0
- data/spec/assets/instantiated_vapp_network_config_add_network_request.xml +36 -0
- data/spec/assets/instantiated_vapp_network_config_modify_network_task_success.xml +6 -0
- data/spec/assets/instantiated_vapp_network_config_remove_network_request.xml +6 -0
- data/spec/assets/instantiated_vapp_network_config_section_response.xml +17 -0
- data/spec/assets/instantiated_vapp_off_response.xml +206 -0
- data/spec/assets/instantiated_vapp_on_response.xml +205 -0
- data/spec/assets/instantiated_vapp_power_task_running.xml +6 -0
- data/spec/assets/instantiated_vapp_power_task_success.xml +6 -0
- data/spec/assets/instantiated_vapp_response.xml +205 -0
- data/spec/assets/instantiated_vm_change_task_running.xml +6 -0
- data/spec/assets/instantiated_vm_change_task_success.xml +6 -0
- data/spec/assets/instantiated_vm_cpu_response.xml +11 -0
- data/spec/assets/instantiated_vm_insert_media_task_done.xml +6 -0
- data/spec/assets/instantiated_vm_memory_response.xml +11 -0
- data/spec/assets/instantiated_vm_modify_task_running.xml +6 -0
- data/spec/assets/instantiated_vm_modify_task_success.xml +5 -0
- data/spec/assets/instantiated_vm_network_section_response.xml +11 -0
- data/spec/assets/instantiated_vm_response.xml +149 -0
- data/spec/assets/media_add_to_catalog_request.xml +5 -0
- data/spec/assets/media_add_to_catalog_response.xml +8 -0
- data/spec/assets/media_delete_task_done.xml +6 -0
- data/spec/assets/media_upload_pending_response.xml +13 -0
- data/spec/assets/media_upload_request.xml +2 -0
- data/spec/assets/metadata_set_request.xml +3 -0
- data/spec/assets/metadata_set_task_done.xml +6 -0
- data/spec/assets/org_network_response.xml +22 -0
- data/spec/assets/reconfigure_vm_request.xml +133 -0
- data/spec/assets/reconfigure_vm_task.xml +8 -0
- data/spec/assets/session.xml +7 -0
- data/spec/assets/test-config.yml +38 -0
- data/spec/assets/undeploy_params.xml +1 -0
- data/spec/assets/vapp_template_catalog_resolver_response.xml +3 -0
- data/spec/assets/vapp_template_delelete_done_task.xml +5 -0
- data/spec/assets/vapp_template_delelete_running_task.xml +6 -0
- data/spec/assets/vapp_template_instantiate_request.xml +8 -0
- data/spec/assets/vapp_template_instantiate_with_locality_request.xml +14 -0
- data/spec/assets/vapp_template_no_disk_response.xml +27 -0
- data/spec/assets/vapp_template_ready_response.xml +79 -0
- data/spec/assets/vapp_template_upload_complete.xml +28 -0
- data/spec/assets/vapp_template_upload_failed.xml +28 -0
- data/spec/assets/vapp_template_upload_request.xml +4 -0
- data/spec/assets/vapp_template_upload_response.xml +25 -0
- data/spec/assets/vcloud_response.xml +56 -0
- data/spec/assets/vdc_response.xml +57 -0
- data/spec/spec_helper.rb +107 -0
- data/spec/unit/client_response.rb +700 -0
- data/spec/unit/client_spec.rb +1152 -0
- metadata +498 -0
@@ -0,0 +1,1152 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "client_response"
|
3
|
+
require "stringio"
|
4
|
+
require "logger"
|
5
|
+
require "nokogiri/diff"
|
6
|
+
|
7
|
+
module VCloudSdk
|
8
|
+
vcd = VCloudSdk::Test::vcd_settings
|
9
|
+
logger = Config.logger
|
10
|
+
|
11
|
+
Config.configure({"logger" => logger,
|
12
|
+
"rest_logger" =>VCloudSdk::Test::rest_logger(logger),
|
13
|
+
"rest_throttle" => vcd["control"]["rest_throttle"]})
|
14
|
+
|
15
|
+
describe Client, :min, :all do
|
16
|
+
let(:url) { vcd["url"] }
|
17
|
+
let(:username) { vcd["user"] }
|
18
|
+
let(:password) { vcd["password"] }
|
19
|
+
let(:control) { vcd["control"] }
|
20
|
+
let(:entities) { vcd["entities"] }
|
21
|
+
let(:auth_cookies) { {"vcloud-token" => vcd["testing"]["cookies"]} }
|
22
|
+
|
23
|
+
def mock_rest_connection
|
24
|
+
@upload_file_state = "success"
|
25
|
+
current_vapp_state = "nothing"
|
26
|
+
finalize_vapp_task_state = "running"
|
27
|
+
delete_vapp_template_task_state = "running"
|
28
|
+
delete_vapp_task_state = "running"
|
29
|
+
change_vm_task_state = "running"
|
30
|
+
catalog_state = "not_added"
|
31
|
+
template_instantiate_state = "running"
|
32
|
+
vapp_power_state = "off"
|
33
|
+
existing_media_state = "busy"
|
34
|
+
metadata_value = ""
|
35
|
+
metadata_xml = ""
|
36
|
+
rest_client = mock("Rest Client")
|
37
|
+
response_mapping = {
|
38
|
+
:get => {
|
39
|
+
Test::Response::ADMIN_VCLOUD_LINK => lambda {
|
40
|
+
|url, headers| Test::Response::VCLOUD_RESPONSE },
|
41
|
+
Test::Response::ADMIN_ORG_LINK => lambda {
|
42
|
+
|url, headers| Test::Response::ADMIN_ORG_RESPONSE },
|
43
|
+
Test::Response::VDC_LINK => lambda {
|
44
|
+
|url, headers| Test::Response::VDC_RESPONSE },
|
45
|
+
Test::Response::CATALOG_LINK => lambda { |url, headers|
|
46
|
+
case (catalog_state)
|
47
|
+
when "not_added"
|
48
|
+
Test::Response::CATALOG_RESPONSE
|
49
|
+
when "added"
|
50
|
+
Test::Response::CATALOG_ITEM_ADDED_RESPONSE
|
51
|
+
end
|
52
|
+
},
|
53
|
+
Test::Response::CATALOG_ITEM_VAPP_LINK => lambda {
|
54
|
+
|url, headers| Test::Response::CATALOG_ADD_ITEM_RESPONSE
|
55
|
+
},
|
56
|
+
Test::Response::VAPP_TEMPLATE_LINK => lambda { |url, headers|
|
57
|
+
case (current_vapp_state)
|
58
|
+
when "ovf_uploaded"
|
59
|
+
Test::Response::VAPP_TEMPLATE_NO_DISKS_RESPONSE
|
60
|
+
when "nothing"
|
61
|
+
Test::Response::VAPP_TEMPLATE_UPLOAD_OVF_WAITING_RESPONSE
|
62
|
+
when "disks_uploaded"
|
63
|
+
Test::Response::VAPP_TEMPLATE_UPLOAD_COMPLETE
|
64
|
+
when "disks_upload_failed"
|
65
|
+
Test::Response::VAPP_TEMPLATE_UPLOAD_FAILED
|
66
|
+
when "finalized"
|
67
|
+
Test::Response::VAPP_TEMPLATE_READY_RESPONSE
|
68
|
+
end
|
69
|
+
},
|
70
|
+
Test::Response::FINALIZE_UPLOAD_TASK_LINK => lambda {
|
71
|
+
|url, headers|
|
72
|
+
case (finalize_vapp_task_state)
|
73
|
+
when "running"
|
74
|
+
finalize_vapp_task_state = "success"
|
75
|
+
current_vapp_state = "finalized"
|
76
|
+
Test::Response::FINALIZE_UPLOAD_TASK_RESPONSE
|
77
|
+
when "success"
|
78
|
+
Test::Response::FINALIZE_UPLOAD_TASK_DONE_RESPONSE
|
79
|
+
end
|
80
|
+
},
|
81
|
+
Test::Response::VAPP_TEMPLATE_DELETE_TASK_LINK => lambda {
|
82
|
+
|url, headers|
|
83
|
+
case (delete_vapp_template_task_state)
|
84
|
+
when "running"
|
85
|
+
delete_vapp_template_task_state = "success"
|
86
|
+
Test::Response::VAPP_TEMPLATE_DELETE_RUNNING_TASK
|
87
|
+
when "success"
|
88
|
+
Test::Response::VAPP_TEMPLATE_DELETE_DONE_TASK
|
89
|
+
end
|
90
|
+
},
|
91
|
+
Test::Response::EXISTING_VAPP_TEMPLATE_CATALOG_ITEM_LINK =>
|
92
|
+
lambda { |url, headers|
|
93
|
+
Test::Response::EXISTING_VAPP_TEMPLATE_CATALOG_ITEM_RESPONSE
|
94
|
+
},
|
95
|
+
Test::Response::EXISTING_VAPP_TEMPLATE_LINK => lambda {
|
96
|
+
|url, headers|
|
97
|
+
Test::Response::EXISTING_VAPP_TEMPLATE_READY_RESPONSE
|
98
|
+
},
|
99
|
+
Test::Response::EXISTING_VAPP_TEMPLATE_INSTANTIATE_TASK_LINK =>
|
100
|
+
lambda { |url, headers|
|
101
|
+
case (template_instantiate_state)
|
102
|
+
when "running"
|
103
|
+
template_instantiate_state = "success"
|
104
|
+
Test::Response::
|
105
|
+
EXISTING_VAPP_TEMPLATE_INSTANTIATE_TASK_START_RESPONSE
|
106
|
+
when "success"
|
107
|
+
Test::Response::
|
108
|
+
EXISTING_VAPP_TEMPLATE_INSTANTIATE_TASK_SUCCESS_RESPONSE
|
109
|
+
end
|
110
|
+
},
|
111
|
+
Test::Response::INSTANTIATED_VAPP_LINK => lambda {
|
112
|
+
|url, headers|
|
113
|
+
case(vapp_power_state)
|
114
|
+
when "off"
|
115
|
+
Test::Response::INSTANTIAED_VAPP_RESPONSE
|
116
|
+
when "on"
|
117
|
+
Test::Response::INSTANTIAED_VAPP_ON_RESPONSE
|
118
|
+
when "powered-off"
|
119
|
+
Test::Response::INSTANTIAED_VAPP_POWERED_OFF_RESPONSE
|
120
|
+
when "suspended"
|
121
|
+
Test::Response::INSTANTIATED_SUSPENDED_VAPP_RESPONSE
|
122
|
+
end
|
123
|
+
},
|
124
|
+
Test::Response::INSTANTIATED_VAPP_DELETE_TASK_LINK => lambda {
|
125
|
+
|url, headers|
|
126
|
+
case (delete_vapp_task_state)
|
127
|
+
when "running"
|
128
|
+
delete_vapp_task_state = "success"
|
129
|
+
Test::Response::INSTANTIATED_VAPP_DELETE_RUNNING_TASK
|
130
|
+
when "success"
|
131
|
+
Test::Response::INSTANTIATED_VAPP_DELETE_DONE_TASK
|
132
|
+
end
|
133
|
+
},
|
134
|
+
Test::Response::INSTANTIATED_VM_LINK => lambda { |url, headers|
|
135
|
+
Test::Response::INSTANTIATED_VM_RESPONSE
|
136
|
+
},
|
137
|
+
Test::Response::INSTANTIATED_VM_CPU_LINK => lambda {
|
138
|
+
|url, headers| Test::Response::INSTANTIATED_VM_CPU_RESPONSE
|
139
|
+
},
|
140
|
+
Test::Response::INSTANTIATED_VM_MEMORY_LINK => lambda {
|
141
|
+
|url, headers| Test::Response::INSTANTIATED_VM_MEMORY_RESPONSE
|
142
|
+
},
|
143
|
+
Test::Response::INSTANTIATED_VM_MODIFY_TASK_LINK => lambda {
|
144
|
+
|url, headers|
|
145
|
+
case(change_vm_task_state)
|
146
|
+
when "running"
|
147
|
+
change_vm_task_state = "success"
|
148
|
+
Test::Response::INSTANTIATED_VM_MODIFY_TASK_RUNNING
|
149
|
+
when "success"
|
150
|
+
Test::Response::INSTANTIATED_VM_MODIFY_TASK_SUCCESS
|
151
|
+
end
|
152
|
+
},
|
153
|
+
Test::Response::EXISTING_VAPP_LINK => lambda { |url, headers|
|
154
|
+
Test::Response::INSTANTIAED_VAPP_RESPONSE
|
155
|
+
},
|
156
|
+
Test::Response::INSTANTIATED_VAPP_POWER_ON_TASK_LINK => lambda {
|
157
|
+
|url, headers|
|
158
|
+
Test::Response::INSTANTED_VAPP_POWER_TASK_SUCCESS
|
159
|
+
},
|
160
|
+
Test::Response::ORG_NETWORK_LINK => lambda { |url, headers|
|
161
|
+
Test::Response::ORG_NETWORK_RESPONSE
|
162
|
+
},
|
163
|
+
Test::Response::INSTANTIATED_VAPP_NETWORK_CONFIG_SECTION_LINK =>
|
164
|
+
lambda { |url, headers|
|
165
|
+
Test::Response::
|
166
|
+
INSTANTIATED_VAPP_NETWORK_CONFIG_SECTION_RESPONSE
|
167
|
+
},
|
168
|
+
Test::Response::
|
169
|
+
INSTANTIATED_VAPP_NETWORK_CONFIG_ADD_NETWORK_TASK_LINK =>
|
170
|
+
lambda { |url, headers|
|
171
|
+
Test::Response::
|
172
|
+
INSTANTIATED_VAPP_NETWORK_CONFIG_MODIFY_NETWORK_TASK_SUCCESS
|
173
|
+
},
|
174
|
+
Test::Response::INSTANTIATED_VM_NETWORK_SECTION_LINK => lambda {
|
175
|
+
|url, headers|
|
176
|
+
Test::Response::INSTANTIATED_VM_NETWORK_SECTION_RESPONSE
|
177
|
+
},
|
178
|
+
Test::Response::MEDIA_LINK => lambda { |url, headers|
|
179
|
+
Test::Response::MEDIA_UPLOAD_PENDING_RESPONSE
|
180
|
+
},
|
181
|
+
Test::Response::EXISTING_MEDIA_CATALOG_ITEM_LINK => lambda {
|
182
|
+
|url, headers| Test::Response::EXISTING_MEDIA_CATALOG_ITEM
|
183
|
+
},
|
184
|
+
Test::Response::EXISTING_MEDIA_LINK => lambda { |url, headers|
|
185
|
+
case(existing_media_state)
|
186
|
+
when "busy"
|
187
|
+
existing_media_state = "done"
|
188
|
+
Test::Response::EXISTING_MEDIA_BUSY_RESPONSE
|
189
|
+
when "done"
|
190
|
+
Test::Response::EXISTING_MEDIA_DONE_RESPONSE
|
191
|
+
end
|
192
|
+
},
|
193
|
+
Test::Response::METADATA_SET_LINK => lambda { |url, headers|
|
194
|
+
metadata_xml
|
195
|
+
},
|
196
|
+
Test::Response::INDY_DISK_URL => lambda { |url, headers|
|
197
|
+
Test::Response::INDY_DISK_RESPONSE
|
198
|
+
},
|
199
|
+
Test::Response::EXISTING_VAPP_RESOLVER_URL => lambda {
|
200
|
+
|url,headers| Test::Response::EXISTING_VAPP_RESOLVER_RESPONSE
|
201
|
+
},
|
202
|
+
Test::Response::EXISTING_VAPP_TEMPLATE_CATALOG_RESOLVER_URL =>
|
203
|
+
lambda { |url,headers|
|
204
|
+
Test::Response::
|
205
|
+
EXISTING_VAPP_TEMPLATE_CATALOG_RESOLVER_RESPONSE
|
206
|
+
},
|
207
|
+
Test::Response::VAPP_TEMPLATE_CATALOG_RESOLVER_URL => lambda {
|
208
|
+
|url,headers|
|
209
|
+
Test::Response::VAPP_TEMPLATE_CATALOG_RESOLVER_RESPONSE
|
210
|
+
}
|
211
|
+
},
|
212
|
+
:post => {
|
213
|
+
Test::Response::LOGIN_LINK => lambda { |url, data, headers|
|
214
|
+
session_object = Test::Response::SESSION
|
215
|
+
|
216
|
+
def session_object.cookies
|
217
|
+
{"vcloud-token" =>
|
218
|
+
VCloudSdk::Test::vcd_settings["testing"]["cookies"]}
|
219
|
+
end
|
220
|
+
|
221
|
+
session_object
|
222
|
+
},
|
223
|
+
Test::Response::VDC_VAPP_UPLOAD_LINK => lambda {
|
224
|
+
|url, data, headers|
|
225
|
+
current_vapp_state = "nothing"
|
226
|
+
Test::Response::VAPP_TEMPLATE_UPLOAD_OVF_WAITING_RESPONSE
|
227
|
+
},
|
228
|
+
Test::Response::CATALOG_ADD_ITEM_LINK => lambda {
|
229
|
+
|url, data, headers|
|
230
|
+
case(Xml::WrapperFactory.wrap_document(data))
|
231
|
+
when Xml::WrapperFactory.wrap_document(
|
232
|
+
Test::Response::CATALOG_ADD_VAPP_REQUEST)
|
233
|
+
catalog_state = "added"
|
234
|
+
Test::Response::CATALOG_ADD_ITEM_RESPONSE
|
235
|
+
when Xml::WrapperFactory.wrap_document(
|
236
|
+
Test::Response::MEDIA_ADD_TO_CATALOG_REQUEST)
|
237
|
+
catalog_state = "added"
|
238
|
+
Test::Response::MEDIA_ADD_TO_CATALOG_RESPONSE
|
239
|
+
else
|
240
|
+
Config.logger.error("Response mapping not found for " +
|
241
|
+
"POST and #{url} and #{data}")
|
242
|
+
raise "Response mapping not found."
|
243
|
+
end
|
244
|
+
},
|
245
|
+
Test::Response::VAPP_TEMPLATE_INSTANTIATE_LINK => lambda {
|
246
|
+
|url, data, headers|
|
247
|
+
Test::Response::EXISTING_VAPP_TEMPLATE_INSTANTIATE_RESPONSE
|
248
|
+
},
|
249
|
+
Test::Response::RECONFIGURE_VM_LINK => lambda {
|
250
|
+
|url, data, headers|
|
251
|
+
Test::Response::RECONFIGURE_VM_TASK
|
252
|
+
},
|
253
|
+
Test::Response::INSTANTIATED_VAPP_POWER_ON_LINK => lambda {
|
254
|
+
|url, data, headers|
|
255
|
+
vapp_power_state = "on"
|
256
|
+
Test::Response::INSTANTED_VAPP_POWER_TASK_RUNNING
|
257
|
+
},
|
258
|
+
Test::Response::INSTANTIATED_VAPP_POWER_OFF_LINK => lambda {
|
259
|
+
|url, data, headers|
|
260
|
+
vapp_power_state = "powered-off"
|
261
|
+
Test::Response::INSTANTED_VAPP_POWER_TASK_RUNNING
|
262
|
+
},
|
263
|
+
Test::Response::INSTANTIATED_VAPP_POWER_REBOOT_LINK => lambda {
|
264
|
+
|url, data, headers|
|
265
|
+
vapp_power_state = "on"
|
266
|
+
Test::Response::INSTANTED_VAPP_POWER_TASK_RUNNING
|
267
|
+
},
|
268
|
+
Test::Response::INSTANTIATED_VAPP_UNDEPLOY_LINK => lambda {
|
269
|
+
|url, data, headers|
|
270
|
+
vapp_power_state = "off"
|
271
|
+
Test::Response::INSTANTED_VAPP_POWER_TASK_RUNNING
|
272
|
+
},
|
273
|
+
Test::Response::INSTANTIATED_VAPP_DISCARD_STATE_LINK => lambda {
|
274
|
+
|url, data, headers|
|
275
|
+
vapp_power_state = "off"
|
276
|
+
Test::Response::INSTANTED_VAPP_POWER_TASK_RUNNING
|
277
|
+
},
|
278
|
+
Test::Response::MEDIA_UPLOAD_LINK => lambda {
|
279
|
+
|url, data, headers|
|
280
|
+
Test::Response::MEDIA_UPLOAD_PENDING_RESPONSE
|
281
|
+
},
|
282
|
+
Test::Response::INSTANTIATED_VM_INSERT_MEDIA_LINK => lambda {
|
283
|
+
|url, data, headers|
|
284
|
+
Test::Response::INSTANTIATED_VM_INSERT_MEDIA_TASK_DONE
|
285
|
+
},
|
286
|
+
Test::Response::VDC_INDY_DISKS_LINK => lambda {
|
287
|
+
|url, data, headers|
|
288
|
+
Test::Response::INDY_DISK_CREATE_RESPONSE
|
289
|
+
},
|
290
|
+
Test::Response::INSTANTIATED_VM_ATTACH_DISK_LINK => lambda {
|
291
|
+
|url, data, headers|
|
292
|
+
Test::Response::INDY_DISK_ATTACH_TASK
|
293
|
+
}
|
294
|
+
},
|
295
|
+
:put => {
|
296
|
+
Test::Response::VAPP_TEMPLATE_UPLOAD_OVF_LINK => lambda {
|
297
|
+
|url, data, headers|
|
298
|
+
current_vapp_state = "ovf_uploaded"
|
299
|
+
""
|
300
|
+
},
|
301
|
+
Test::Response::INSTANTIATED_VM_CPU_LINK => lambda {
|
302
|
+
|url, data, headers|
|
303
|
+
change_vm_task_state = "running"
|
304
|
+
Test::Response::INSTANTIATED_VM_MODIFY_TASK_RUNNING
|
305
|
+
},
|
306
|
+
Test::Response::INSTANTIATED_VM_MEMORY_LINK => lambda {
|
307
|
+
|url, data, headers|
|
308
|
+
change_vm_task_state = "running"
|
309
|
+
Test::Response::INSTANTIATED_VM_MODIFY_TASK_RUNNING
|
310
|
+
},
|
311
|
+
Test::Response::INSTANTIATED_VM_LINK => lambda {
|
312
|
+
|url, data, headers|
|
313
|
+
change_vm_task_state = "running"
|
314
|
+
Test::Response::INSTANTIATED_VM_MODIFY_TASK_RUNNING
|
315
|
+
},
|
316
|
+
Test::Response::INSTANTIATED_VM_HARDWARE_SECTION_LINK =>
|
317
|
+
lambda { |url, data, headers|
|
318
|
+
change_vm_task_state = "running"
|
319
|
+
Test::Response::INSTANTIATED_VM_MODIFY_TASK_RUNNING
|
320
|
+
},
|
321
|
+
Test::Response::INSTANTIATED_VAPP_NETWORK_CONFIG_SECTION_LINK =>
|
322
|
+
lambda { |url, data, headers|
|
323
|
+
Test::Response::
|
324
|
+
INSTANTIATED_VAPP_NETWORK_CONFIG_MODIFY_NETWORK_TASK_SUCCESS
|
325
|
+
},
|
326
|
+
Test::Response::INSTANTIATED_VM_NETWORK_SECTION_LINK => lambda {
|
327
|
+
|url, data, headers|
|
328
|
+
change_vm_task_state = "running"
|
329
|
+
Test::Response::INSTANTIATED_VM_MODIFY_TASK_RUNNING
|
330
|
+
},
|
331
|
+
Test::Response::METADATA_SET_LINK => lambda {
|
332
|
+
|url, data, headers|
|
333
|
+
received = Xml::WrapperFactory.wrap_document(data)
|
334
|
+
metadata_value = received.value
|
335
|
+
metadata_xml = data
|
336
|
+
Test::Response::METADATA_SET_TASK_DONE
|
337
|
+
}
|
338
|
+
},
|
339
|
+
:delete => {
|
340
|
+
Test::Response::VAPP_TEMPLATE_LINK => lambda { |url, headers|
|
341
|
+
Test::Response::VAPP_TEMPLATE_DELETE_RUNNING_TASK
|
342
|
+
},
|
343
|
+
Test::Response::INSTANTIATED_VAPP_LINK => lambda {
|
344
|
+
|url, headers|
|
345
|
+
Test::Response::INSTANTIATED_VAPP_DELETE_RUNNING_TASK
|
346
|
+
},
|
347
|
+
Test::Response::CATALOG_ITEM_VAPP_LINK => lambda {
|
348
|
+
|url, headers|
|
349
|
+
nil
|
350
|
+
},
|
351
|
+
Test::Response::EXISTING_MEDIA_LINK => lambda { |url, headers|
|
352
|
+
Test::Response::EXISTING_MEDIA_DELETE_TASK_DONE
|
353
|
+
},
|
354
|
+
Test::Response::EXISTING_MEDIA_CATALOG_ITEM_LINK => lambda {
|
355
|
+
|url, headers|
|
356
|
+
nil
|
357
|
+
},
|
358
|
+
Test::Response::MEDIA_LINK => lambda { |url, headers|
|
359
|
+
Test::Response::MEDIA_DELETE_TASK_DONE
|
360
|
+
},
|
361
|
+
Test::Response::INDY_DISK_URL => lambda { |url, headers|
|
362
|
+
Test::Response::INDY_DISK_DELETE_TASK
|
363
|
+
},
|
364
|
+
}
|
365
|
+
}
|
366
|
+
|
367
|
+
#Working around Ruby 1.8"s lack of define_singleton_method
|
368
|
+
metaclass = class << response_mapping;
|
369
|
+
self;
|
370
|
+
end
|
371
|
+
|
372
|
+
metaclass.send :define_method, :get_mapping do |http_method, url|
|
373
|
+
mapping = self[http_method][url]
|
374
|
+
if mapping.nil?
|
375
|
+
Config.logger.error("Response mapping not found for " +
|
376
|
+
"#{http_method} and #{url}")
|
377
|
+
# string substitution doesn"t work here for some reason
|
378
|
+
raise "Response mapping not found."
|
379
|
+
else
|
380
|
+
mapping
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
384
|
+
rest_client.stub(:get) do |headers|
|
385
|
+
response_mapping.get_mapping(:get, build_url).call(build_url, headers)
|
386
|
+
end
|
387
|
+
rest_client.stub(:post) do |data, headers|
|
388
|
+
response_mapping.get_mapping(:post, build_url).call(build_url, data,
|
389
|
+
headers)
|
390
|
+
end
|
391
|
+
rest_client.stub(:put) do |data, headers|
|
392
|
+
response_mapping.get_mapping(:put, build_url).call(build_url, data,
|
393
|
+
headers)
|
394
|
+
end
|
395
|
+
rest_client.stub(:delete) do |headers|
|
396
|
+
response_mapping.get_mapping(:delete, build_url).call(build_url,
|
397
|
+
headers)
|
398
|
+
end
|
399
|
+
rest_client.stub(:vapp_state=) do |value|
|
400
|
+
current_vapp_state = value
|
401
|
+
end
|
402
|
+
rest_client.stub(:vapp_state) do
|
403
|
+
current_vapp_state
|
404
|
+
end
|
405
|
+
rest_client.stub(:response_mapping) do
|
406
|
+
response_mapping
|
407
|
+
end
|
408
|
+
rest_client.stub(:vapp_power_state=) do |value|
|
409
|
+
vapp_power_state = value
|
410
|
+
end
|
411
|
+
rest_client.stub(:[]) do |value|
|
412
|
+
@resource = value
|
413
|
+
@rest_connection
|
414
|
+
end
|
415
|
+
|
416
|
+
rest_client
|
417
|
+
end
|
418
|
+
|
419
|
+
def build_url
|
420
|
+
url + @resource
|
421
|
+
end
|
422
|
+
|
423
|
+
def nested(url)
|
424
|
+
URI.parse(url).path
|
425
|
+
end
|
426
|
+
|
427
|
+
class MockRestClient
|
428
|
+
class << self
|
429
|
+
attr_accessor :log
|
430
|
+
end
|
431
|
+
end
|
432
|
+
|
433
|
+
def create_mock_client
|
434
|
+
@rest_connection = mock_rest_connection()
|
435
|
+
file_uploader = mock("File Uploader")
|
436
|
+
file_uploader.stub(:upload) do
|
437
|
+
@rest_connection.vapp_state = @upload_file_state == "success" ?
|
438
|
+
"disks_uploaded" : "disks_upload_failed"
|
439
|
+
end
|
440
|
+
conn = Connection::Connection.new(url, entities["organization"],
|
441
|
+
control["time_limit_sec"]["http_request"], MockRestClient,
|
442
|
+
@rest_connection, file_uploader)
|
443
|
+
conn.stub(:file_uploader) do
|
444
|
+
file_uploader
|
445
|
+
end
|
446
|
+
conn.stub(:rest_connection) do
|
447
|
+
@rest_connection
|
448
|
+
end
|
449
|
+
conn
|
450
|
+
end
|
451
|
+
|
452
|
+
def create_mock_ovf_directory(string_io)
|
453
|
+
directory = mock("Directory")
|
454
|
+
# Actual content of the OVF is irrelevant as long as the client gives
|
455
|
+
# back the same one given to it
|
456
|
+
ovf_string = "ovf_string"
|
457
|
+
ovf_string_io = StringIO.new(ovf_string)
|
458
|
+
directory.stub(:ovf_file_path) { "ovf_file" }
|
459
|
+
directory.stub(:ovf_file) {
|
460
|
+
ovf_string_io
|
461
|
+
}
|
462
|
+
directory.stub(:vmdk_file_path) do |file_name|
|
463
|
+
file_name
|
464
|
+
end
|
465
|
+
directory.stub(:vmdk_file) do |file_name|
|
466
|
+
string_io
|
467
|
+
end
|
468
|
+
directory
|
469
|
+
end
|
470
|
+
|
471
|
+
def create_mock_media_file()
|
472
|
+
media_string = Test::Response::MEDIA_CONTENT
|
473
|
+
string_io = StringIO.new(media_string)
|
474
|
+
string_io.stub(:path) { "bogus/bogus.iso" }
|
475
|
+
string_io.stub(:stat) {
|
476
|
+
o = Object.new
|
477
|
+
o.stub(:size) { media_string.length }
|
478
|
+
o
|
479
|
+
}
|
480
|
+
string_io
|
481
|
+
end
|
482
|
+
|
483
|
+
|
484
|
+
describe "VCD Adapter client", :positive, :min, :all do
|
485
|
+
it "logs into organization with usename and password and get the " +
|
486
|
+
"organization VDC" do
|
487
|
+
conn = mock("Connection")
|
488
|
+
root_session = Xml::WrapperFactory.wrap_document(
|
489
|
+
Test::Response::SESSION)
|
490
|
+
vcloud_response = Xml::WrapperFactory.wrap_document(
|
491
|
+
Test::Response::VCLOUD_RESPONSE)
|
492
|
+
admin_org_response = Xml::WrapperFactory.wrap_document(
|
493
|
+
Test::Response::ADMIN_ORG_RESPONSE)
|
494
|
+
vdc_response = Xml::WrapperFactory.wrap_document(
|
495
|
+
Test::Response::VDC_RESPONSE)
|
496
|
+
conn.should_receive(:connect).with(username, password).and_return(
|
497
|
+
root_session)
|
498
|
+
conn.should_receive(:get).with(root_session.admin_root).and_return(
|
499
|
+
vcloud_response)
|
500
|
+
conn.should_receive(:get).with(vcloud_response.organization(
|
501
|
+
entities["organization"])).and_return(admin_org_response)
|
502
|
+
Client.new(nil, username, password, entities, control, conn)
|
503
|
+
end
|
504
|
+
end
|
505
|
+
|
506
|
+
describe "VCD Adapter client", :upload, :all do
|
507
|
+
it "uploads an OVF to the OVDC", :positive do
|
508
|
+
vmdk_string = "vmdk"
|
509
|
+
vmdk_string_io = StringIO.new(vmdk_string)
|
510
|
+
directory = create_mock_ovf_directory(vmdk_string_io)
|
511
|
+
|
512
|
+
conn = create_mock_client
|
513
|
+
|
514
|
+
vapp_name = Test::Response::VAPP_TEMPLATE_NAME
|
515
|
+
|
516
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
517
|
+
|
518
|
+
conn.file_uploader.should_receive(:upload).with(
|
519
|
+
Test::Response::VAPP_TEMPLATE_DISK_UPLOAD_1, vmdk_string_io,
|
520
|
+
auth_cookies)
|
521
|
+
catalog_item = client.upload_vapp_template(vapp_name, directory)
|
522
|
+
# Since the wrapper classes are used to hide away the raw XML,
|
523
|
+
# compare the wrapped versions
|
524
|
+
catalog_item.should eq(Xml::WrapperFactory.wrap_document(
|
525
|
+
Test::Response::CATALOG_ADD_ITEM_RESPONSE))
|
526
|
+
end
|
527
|
+
|
528
|
+
it "reports an exception upon error in transferring an OVF file",
|
529
|
+
:negative do
|
530
|
+
vmdk_string = "vmdk"
|
531
|
+
vmdk_string_io = StringIO.new(vmdk_string)
|
532
|
+
directory = create_mock_ovf_directory(vmdk_string_io)
|
533
|
+
|
534
|
+
conn = create_mock_client
|
535
|
+
@upload_file_state = "failed"
|
536
|
+
vapp_name = Test::Response::VAPP_TEMPLATE_NAME
|
537
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
538
|
+
|
539
|
+
conn.file_uploader.should_receive(:upload).with(
|
540
|
+
Test::Response::VAPP_TEMPLATE_DISK_UPLOAD_1, vmdk_string_io,
|
541
|
+
auth_cookies)
|
542
|
+
expect {
|
543
|
+
client.upload_vapp_template(vapp_name, directory)
|
544
|
+
}.to raise_exception("Error uploading vApp template")
|
545
|
+
@upload_file_state = "success"
|
546
|
+
end
|
547
|
+
|
548
|
+
it "deletes the vApp template if there's an error uploading it to " +
|
549
|
+
"the catalog", :negative do
|
550
|
+
vmdk_string = "vmdk"
|
551
|
+
vmdk_string_io = StringIO.new(vmdk_string)
|
552
|
+
directory = create_mock_ovf_directory(vmdk_string_io)
|
553
|
+
|
554
|
+
conn = create_mock_client
|
555
|
+
conn.rest_connection.response_mapping[:post][
|
556
|
+
Test::Response::CATALOG_ADD_ITEM_LINK] =
|
557
|
+
lambda { |url, data, headers|
|
558
|
+
raise ApiError, "Bogus add to catalog error"
|
559
|
+
}
|
560
|
+
vapp_name = Test::Response::VAPP_TEMPLATE_NAME
|
561
|
+
conn.rest_connection.should_receive(:[]).with(
|
562
|
+
nested(Test::Response::VAPP_TEMPLATE_LINK))
|
563
|
+
conn.rest_connection.should_receive(:delete).with(anything())
|
564
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
565
|
+
expect {
|
566
|
+
client.upload_vapp_template(vapp_name, directory)
|
567
|
+
}.to raise_exception("Bogus add to catalog error")
|
568
|
+
end
|
569
|
+
|
570
|
+
end
|
571
|
+
|
572
|
+
describe "VCD Adapter client", :delete, :all do
|
573
|
+
it "deletes a vApp template from the catalog", :positive do
|
574
|
+
vmdk_string = "vmdk"
|
575
|
+
vmdk_string_io = StringIO.new(vmdk_string)
|
576
|
+
directory = create_mock_ovf_directory(vmdk_string_io)
|
577
|
+
|
578
|
+
conn = create_mock_client
|
579
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
580
|
+
vapp_name = Test::Response::VAPP_TEMPLATE_NAME
|
581
|
+
conn.rest_connection.should_receive(:[]).with(
|
582
|
+
nested(Test::Response::VAPP_TEMPLATE_LINK))
|
583
|
+
conn.rest_connection.should_receive(:delete).with(anything())
|
584
|
+
catalog_item = client.upload_vapp_template(vapp_name, directory)
|
585
|
+
client.delete_catalog_vapp(catalog_item.urn)
|
586
|
+
end
|
587
|
+
|
588
|
+
it "no exception for delete catalog vapp if the vApp does not exist",
|
589
|
+
:negative do
|
590
|
+
conn = create_mock_client
|
591
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
592
|
+
client.delete_catalog_vapp("bogus")
|
593
|
+
end
|
594
|
+
|
595
|
+
it "raise exception for upload media to catalog if the catalog does " +
|
596
|
+
"not exist", :negative do
|
597
|
+
conn = create_mock_client
|
598
|
+
ent_clone = entities.clone
|
599
|
+
ent_clone["media_catalog"] = "bogus"
|
600
|
+
media_file = create_mock_media_file()
|
601
|
+
client = Client.new(nil, username, password, ent_clone, control, conn)
|
602
|
+
media_name = Test::Response::MEDIA_NAME
|
603
|
+
|
604
|
+
conn.file_uploader.stub(:upload) do |href, data, headers|
|
605
|
+
href.should eq(Test::Response::MEDIA_ISO_LINK)
|
606
|
+
data.read.should eq(Test::Response::MEDIA_CONTENT)
|
607
|
+
end
|
608
|
+
conn.rest_connection.should_receive(:[]).with(
|
609
|
+
nested(Test::Response::MEDIA_LINK))
|
610
|
+
conn.rest_connection.should_receive(:delete).with(anything())
|
611
|
+
expect {
|
612
|
+
client.upload_catalog_media(media_name, media_file)
|
613
|
+
}.to raise_exception(/.+ catalog .+ not found\./)
|
614
|
+
end
|
615
|
+
|
616
|
+
it "should not raise if underlying vApp no longer exists when " +
|
617
|
+
"deleting a vApp from the catalog", :negative do
|
618
|
+
conn = create_mock_client
|
619
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
620
|
+
conn.rest_connection.response_mapping[:delete][
|
621
|
+
Test::Response::VAPP_TEMPLATE_LINK] = lambda { |urls, headers|
|
622
|
+
raise RestClient::ResourceNotFound
|
623
|
+
}
|
624
|
+
client.delete_catalog_vapp(Test::Response::VAPP_TEMPLATE_NAME)
|
625
|
+
end
|
626
|
+
end
|
627
|
+
|
628
|
+
describe "VCD Adapter client", :instantiate_template, :all do
|
629
|
+
it "instantiates a vApp from the catalog", :positive do
|
630
|
+
conn = create_mock_client
|
631
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
632
|
+
catalog_vapp_id = Test::Response::EXISTING_VAPP_TEMPLATE_CATALOG_URN
|
633
|
+
vapp_name = Test::Response::VAPP_NAME
|
634
|
+
conn.rest_connection.should_receive(:[]).with(
|
635
|
+
nested(Test::Response::VAPP_TEMPLATE_INSTANTIATE_LINK))
|
636
|
+
conn.rest_connection.should_receive(:post).with(
|
637
|
+
Test::Response::EXISTING_VAPP_TEMPLATE_INSTANTIATE_REQUEST,
|
638
|
+
anything())
|
639
|
+
client.instantiate_vapp_template(catalog_vapp_id, vapp_name)
|
640
|
+
end
|
641
|
+
|
642
|
+
it "instantiates with locality a vApp from the catalog", :positive do
|
643
|
+
conn = create_mock_client
|
644
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
645
|
+
catalog_vapp_id = Test::Response::EXISTING_VAPP_TEMPLATE_CATALOG_URN
|
646
|
+
vapp_name = Test::Response::VAPP_NAME
|
647
|
+
conn.rest_connection.should_receive(:[]).with(
|
648
|
+
nested(Test::Response::VAPP_TEMPLATE_INSTANTIATE_LINK))
|
649
|
+
conn.rest_connection.should_receive(:post).with(
|
650
|
+
Test::Response::
|
651
|
+
EXISTING_VAPP_TEMPLATE_INSTANTIATE_WITH_LOCALITY_REQUEST,
|
652
|
+
anything())
|
653
|
+
client.instantiate_vapp_template(catalog_vapp_id, vapp_name, "desc",
|
654
|
+
[ Test::Response::INDY_DISK_URL ])
|
655
|
+
end
|
656
|
+
|
657
|
+
it "instantiates raises an exception if the task fails", :negative do
|
658
|
+
conn = create_mock_client
|
659
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
660
|
+
catalog_vapp_id = Test::Response::EXISTING_VAPP_TEMPLATE_CATALOG_URN
|
661
|
+
vapp_name = Test::Response::VAPP_NAME
|
662
|
+
conn.rest_connection.response_mapping[:get][
|
663
|
+
Test::Response::EXISTING_VAPP_TEMPLATE_INSTANTIATE_TASK_LINK] =
|
664
|
+
lambda { |url, headers|
|
665
|
+
Test::Response::
|
666
|
+
EXISTING_VAPP_TEMPLATE_INSTANTIATE_TASK_ERROR_RESPONSE
|
667
|
+
}
|
668
|
+
conn.rest_connection.should_receive(:[]).with(
|
669
|
+
nested(Test::Response::INSTANTIATED_VAPP_LINK))
|
670
|
+
conn.rest_connection.should_receive(:delete).with(anything())
|
671
|
+
expect {
|
672
|
+
client.instantiate_vapp_template(catalog_vapp_id, vapp_name)
|
673
|
+
}.to raise_exception(/.+Creating Virtual.+did not complete success.+/)
|
674
|
+
end
|
675
|
+
|
676
|
+
end
|
677
|
+
|
678
|
+
describe "VCD Adapter client", :modify_vm, :all do
|
679
|
+
it "reconfigures a VM", :positive do
|
680
|
+
conn = create_mock_client
|
681
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
682
|
+
catalog_vapp_id = Test::Response::EXISTING_VAPP_TEMPLATE_CATALOG_URN
|
683
|
+
vapp_name = Test::Response::VAPP_NAME
|
684
|
+
conn.rest_connection.should_receive(:[]).with(
|
685
|
+
nested(Test::Response::RECONFIGURE_VM_LINK))
|
686
|
+
conn.rest_connection.should_receive(:post).with(
|
687
|
+
Test::Response::RECONFIGURE_VM_REQUEST, anything())
|
688
|
+
vapp = client.instantiate_vapp_template(catalog_vapp_id, vapp_name)
|
689
|
+
vm = vapp.vms.first
|
690
|
+
client.reconfigure_vm(vm) do |v|
|
691
|
+
vm.name = Test::Response::CHANGED_VM_NAME
|
692
|
+
vm.description = Test::Response::CHANGED_VM_DESCRIPTION
|
693
|
+
v.change_cpu_count(Test::Response::CHANGED_VM_CPU)
|
694
|
+
v.change_memory(Test::Response::CHANGED_VM_MEMORY)
|
695
|
+
v.add_hard_disk(Test::Response::CHANGED_VM_DISK)
|
696
|
+
v.delete_nic(*vm.hardware_section.nics)
|
697
|
+
end
|
698
|
+
end
|
699
|
+
|
700
|
+
it "gets information on HD", :positive do
|
701
|
+
conn = create_mock_client
|
702
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
703
|
+
vapp = client.get_vapp(Test::Response::EXISTING_VAPP_URN)
|
704
|
+
vm = vapp.vms.first
|
705
|
+
vm.hardware_section.hard_disks.each do |h|
|
706
|
+
h.capacity_mb.should_not be_nil
|
707
|
+
h.disk_id.should_not be_nil
|
708
|
+
h.bus_sub_type.should_not be_nil
|
709
|
+
h.bus_type.should_not be_nil
|
710
|
+
end
|
711
|
+
|
712
|
+
vm.hardware_section.nics.each do |n|
|
713
|
+
n.mac_address.should_not be_nil
|
714
|
+
end
|
715
|
+
|
716
|
+
end
|
717
|
+
|
718
|
+
end
|
719
|
+
|
720
|
+
describe "VCD Adapter client", :power_vapp, :all do
|
721
|
+
it "finds and powers on a vApp and powers it off" , :positive do
|
722
|
+
conn = create_mock_client
|
723
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
724
|
+
|
725
|
+
conn.rest_connection.should_receive(:[]).with(
|
726
|
+
nested(Test::Response::INSTANTIATED_VAPP_POWER_ON_LINK))
|
727
|
+
conn.rest_connection.should_receive(:post).with(
|
728
|
+
anything(), anything())
|
729
|
+
conn.rest_connection.should_receive(:[]).with(
|
730
|
+
nested(Test::Response::INSTANTIATED_VAPP_POWER_OFF_LINK))
|
731
|
+
conn.rest_connection.should_receive(:post).with(
|
732
|
+
anything(), anything())
|
733
|
+
vapp = client.get_vapp(Test::Response::EXISTING_VAPP_URN)
|
734
|
+
client.power_on_vapp(vapp)
|
735
|
+
client.power_off_vapp(vapp, false)
|
736
|
+
end
|
737
|
+
|
738
|
+
it "finds and powers on a powered-on vApp" , :negative do
|
739
|
+
conn = create_mock_client
|
740
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
741
|
+
|
742
|
+
vapp = client.get_vapp(Test::Response::EXISTING_VAPP_URN)
|
743
|
+
client.power_on_vapp(vapp)
|
744
|
+
conn.rest_connection.should_not_receive(:[]).with(
|
745
|
+
nested(Test::Response::INSTANTIATED_VAPP_POWER_ON_LINK))
|
746
|
+
conn.rest_connection.should_not_receive(:post).with(
|
747
|
+
anything(), anything())
|
748
|
+
client.power_on_vapp(vapp)
|
749
|
+
end
|
750
|
+
|
751
|
+
it "finds and powers off a powered-off vApp" , :negative do
|
752
|
+
conn = create_mock_client
|
753
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
754
|
+
|
755
|
+
vapp = client.get_vapp(Test::Response::EXISTING_VAPP_URN)
|
756
|
+
client.power_off_vapp(vapp, false)
|
757
|
+
conn.rest_connection.should_not_receive(:[]).with(
|
758
|
+
nested(Test::Response::INSTANTIATED_VAPP_POWER_OFF_LINK))
|
759
|
+
conn.rest_connection.should_not_receive(:post).with(
|
760
|
+
anything(), anything())
|
761
|
+
client.power_off_vapp(vapp, false)
|
762
|
+
end
|
763
|
+
|
764
|
+
it "finds and powers on a vApp and undeploys it" , :positive do
|
765
|
+
conn = create_mock_client
|
766
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
767
|
+
|
768
|
+
conn.rest_connection.should_receive(:[]).with(
|
769
|
+
nested(Test::Response::INSTANTIATED_VAPP_POWER_ON_LINK))
|
770
|
+
conn.rest_connection.should_receive(:post).with(
|
771
|
+
anything(), anything())
|
772
|
+
conn.rest_connection.should_receive(:[]).with(
|
773
|
+
nested(Test::Response::INSTANTIATED_VAPP_UNDEPLOY_LINK))
|
774
|
+
conn.rest_connection.should_receive(:post).with(
|
775
|
+
anything(), anything())
|
776
|
+
vapp = client.get_vapp(Test::Response::EXISTING_VAPP_URN)
|
777
|
+
client.power_on_vapp(vapp)
|
778
|
+
client.power_off_vapp(vapp)
|
779
|
+
end
|
780
|
+
|
781
|
+
it "finds and undeploys an undeployed vapp" , :negative do
|
782
|
+
conn = create_mock_client
|
783
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
784
|
+
|
785
|
+
vapp = client.get_vapp(Test::Response::EXISTING_VAPP_URN)
|
786
|
+
client.power_off_vapp(vapp)
|
787
|
+
conn.rest_connection.should_not_receive(:[]).with(
|
788
|
+
nested(Test::Response::INSTANTIATED_VAPP_UNDEPLOY_LINK))
|
789
|
+
conn.rest_connection.should_not_receive(:post).with(
|
790
|
+
anything(), anything())
|
791
|
+
client.power_off_vapp(vapp)
|
792
|
+
end
|
793
|
+
|
794
|
+
it "finds and undeploys a powered-off vapp" , :positive do
|
795
|
+
conn = create_mock_client
|
796
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
797
|
+
|
798
|
+
vapp = client.get_vapp(Test::Response::EXISTING_VAPP_URN)
|
799
|
+
client.power_on_vapp(vapp)
|
800
|
+
client.power_off_vapp(vapp, false)
|
801
|
+
conn.rest_connection.should_receive(:[]).with(
|
802
|
+
nested(Test::Response::INSTANTIATED_VAPP_UNDEPLOY_LINK))
|
803
|
+
conn.rest_connection.should_receive(:post).with(
|
804
|
+
Test::Response::UNDEPLOY_PARAMS, anything())
|
805
|
+
client.power_off_vapp(vapp)
|
806
|
+
end
|
807
|
+
|
808
|
+
it "discards state of a suspended vapp" , :positive do
|
809
|
+
conn = create_mock_client
|
810
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
811
|
+
|
812
|
+
conn.rest_connection.response_mapping[:get][
|
813
|
+
Test::Response::EXISTING_VAPP_LINK] = lambda { |url, headers|
|
814
|
+
Test::Response::INSTANTIATED_SUSPENDED_VAPP_RESPONSE }
|
815
|
+
conn.rest_connection.vapp_power_state = "suspended"
|
816
|
+
|
817
|
+
vapp = client.get_vapp(Test::Response::EXISTING_VAPP_URN)
|
818
|
+
conn.rest_connection.should_receive(:[]).with(
|
819
|
+
nested(Test::Response::INSTANTIATED_VAPP_DISCARD_STATE_LINK))
|
820
|
+
conn.rest_connection.should_receive(:post).with(
|
821
|
+
anything(), anything())
|
822
|
+
|
823
|
+
client.discard_suspended_state_vapp(vapp)
|
824
|
+
end
|
825
|
+
|
826
|
+
it "finds and powers on a vApp and reboots it" , :positive do
|
827
|
+
conn = create_mock_client
|
828
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
829
|
+
|
830
|
+
conn.rest_connection.should_receive(:[]).with(
|
831
|
+
nested(Test::Response::INSTANTIATED_VAPP_POWER_ON_LINK))
|
832
|
+
conn.rest_connection.should_receive(:post).with(
|
833
|
+
anything(), anything())
|
834
|
+
conn.rest_connection.should_receive(:[]).with(
|
835
|
+
nested(Test::Response::INSTANTIATED_VAPP_POWER_REBOOT_LINK))
|
836
|
+
conn.rest_connection.should_receive(:post).with(
|
837
|
+
anything(), anything())
|
838
|
+
vapp = client.get_vapp(Test::Response::EXISTING_VAPP_URN)
|
839
|
+
client.power_on_vapp(vapp)
|
840
|
+
client.reboot_vapp(vapp)
|
841
|
+
end
|
842
|
+
|
843
|
+
it "reboot of a powered-off vApp raises an exception" , :positive do
|
844
|
+
conn = create_mock_client
|
845
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
846
|
+
|
847
|
+
vapp = client.get_vapp(Test::Response::EXISTING_VAPP_URN)
|
848
|
+
expect {
|
849
|
+
client.reboot_vapp(vapp)
|
850
|
+
}.to raise_exception(VappPoweredOffError)
|
851
|
+
end
|
852
|
+
|
853
|
+
it "reboot of a suspended vApp raises an exception" , :positive do
|
854
|
+
conn = create_mock_client
|
855
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
856
|
+
conn.rest_connection.vapp_power_state = "suspended"
|
857
|
+
|
858
|
+
vapp = client.get_vapp(Test::Response::EXISTING_VAPP_URN)
|
859
|
+
expect {
|
860
|
+
client.reboot_vapp(vapp)
|
861
|
+
}.to raise_exception(VappSuspendedError)
|
862
|
+
end
|
863
|
+
end
|
864
|
+
|
865
|
+
describe "VCD Adapter client", :delete_vapp, :all do
|
866
|
+
it "finds a vApp and deletes it without undeploying", :positive do
|
867
|
+
conn = create_mock_client
|
868
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
869
|
+
|
870
|
+
vapp = client.get_vapp(Test::Response::EXISTING_VAPP_URN)
|
871
|
+
conn.rest_connection.should_not_receive(:[]).with(
|
872
|
+
nested(Test::Response::INSTANTIATED_VAPP_UNDEPLOY_LINK))
|
873
|
+
conn.rest_connection.should_not_receive(:post).with(
|
874
|
+
anything(), anything())
|
875
|
+
conn.rest_connection.should_receive(:[]).with(
|
876
|
+
nested(Test::Response::INSTANTIATED_VAPP_LINK))
|
877
|
+
conn.rest_connection.should_receive(:delete).with(anything())
|
878
|
+
client.delete_vapp(vapp)
|
879
|
+
end
|
880
|
+
|
881
|
+
it "finds and powers on a vApp and fails on delete vApp", :negative do
|
882
|
+
conn = create_mock_client
|
883
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
884
|
+
|
885
|
+
vapp = client.get_vapp(Test::Response::EXISTING_VAPP_URN)
|
886
|
+
client.power_on_vapp(vapp)
|
887
|
+
conn.rest_connection.should_receive(:[]).once.with(
|
888
|
+
nested(Test::Response::INSTANTIATED_VAPP_LINK))
|
889
|
+
conn.rest_connection.should_not_receive(:delete).with(anything())
|
890
|
+
expect {
|
891
|
+
client.delete_vapp(vapp)
|
892
|
+
}.to raise_exception(/vApp .+ powered on, power-off before deleting./)
|
893
|
+
end
|
894
|
+
end
|
895
|
+
|
896
|
+
describe "VCD Adapter client", :add_vapp_network, :all do
|
897
|
+
it "finds a network and vapp and adds the network to the vApp",
|
898
|
+
:positive do
|
899
|
+
conn = create_mock_client
|
900
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
901
|
+
|
902
|
+
network_name = Test::Response::ORG_NETWORK_NAME
|
903
|
+
vapp = client.get_vapp(Test::Response::EXISTING_VAPP_URN)
|
904
|
+
network = client.get_ovdc.available_networks.find {
|
905
|
+
|n| n["name"] == network_name }
|
906
|
+
conn.rest_connection.should_receive(:[]).with(nested(
|
907
|
+
Test::Response::INSTANTIATED_VAPP_NETWORK_CONFIG_SECTION_LINK))
|
908
|
+
conn.rest_connection.should_receive(:put).with(Test::Response::
|
909
|
+
INSTANTIATED_VAPP_NETWORK_CONFIG_ADD_NETWORK_REQUEST,
|
910
|
+
anything())
|
911
|
+
client.add_network(vapp, network)
|
912
|
+
end
|
913
|
+
|
914
|
+
it "removes all networks", :positive do
|
915
|
+
conn = create_mock_client
|
916
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
917
|
+
|
918
|
+
conn.rest_connection.response_mapping[:put][
|
919
|
+
Test::Response::INSTANTIATED_VAPP_NETWORK_CONFIG_SECTION_LINK] =
|
920
|
+
lambda { |url, data, headers|
|
921
|
+
expected = Xml::WrapperFactory.wrap_document(
|
922
|
+
Test::Response::
|
923
|
+
INSTANTIATED_VAPP_NETWORK_CONFIG_REMOVE_NETWORK_REQUEST)
|
924
|
+
received = Xml::WrapperFactory.wrap_document(data)
|
925
|
+
received.should eq(expected)
|
926
|
+
Test::Response::
|
927
|
+
INSTANTIATED_VAPP_NETWORK_CONFIG_MODIFY_NETWORK_TASK_SUCCESS
|
928
|
+
}
|
929
|
+
vapp = client.get_vapp(Test::Response::EXISTING_VAPP_URN)
|
930
|
+
client.delete_networks(vapp)
|
931
|
+
end
|
932
|
+
end
|
933
|
+
|
934
|
+
describe "VCD Adapter client", :add_remove_insert_media, :all do
|
935
|
+
it "uploads media to VDC and adds it to the catalog", :positive do
|
936
|
+
conn = create_mock_client
|
937
|
+
media_file = create_mock_media_file()
|
938
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
939
|
+
media_name = Test::Response::MEDIA_NAME
|
940
|
+
|
941
|
+
conn.file_uploader.stub(:upload) do |href, data, headers|
|
942
|
+
href.should eq(Test::Response::MEDIA_ISO_LINK)
|
943
|
+
data.read.should eq(Test::Response::MEDIA_CONTENT)
|
944
|
+
end
|
945
|
+
|
946
|
+
conn.rest_connection.should_receive(:[]).with(
|
947
|
+
nested(Test::Response::CATALOG_ADD_ITEM_LINK))
|
948
|
+
conn.rest_connection.should_receive(:post).with(
|
949
|
+
Test::Response::MEDIA_ADD_TO_CATALOG_REQUEST, anything())
|
950
|
+
|
951
|
+
client.upload_catalog_media(media_name, media_file)
|
952
|
+
|
953
|
+
end
|
954
|
+
|
955
|
+
it "deletes a media from catalog and the VDC", :positive do
|
956
|
+
conn = create_mock_client
|
957
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
958
|
+
media_name = Test::Response::EXISTING_MEDIA_NAME
|
959
|
+
|
960
|
+
conn.rest_connection.should_receive(:[]).with(
|
961
|
+
nested(Test::Response::EXISTING_MEDIA_LINK))
|
962
|
+
conn.rest_connection.should_receive(:delete).with(anything())
|
963
|
+
conn.rest_connection.should_receive(:[]).with(
|
964
|
+
nested(Test::Response::EXISTING_MEDIA_CATALOG_ITEM_LINK))
|
965
|
+
conn.rest_connection.should_receive(:delete).with(anything())
|
966
|
+
client.delete_catalog_media(media_name)
|
967
|
+
|
968
|
+
end
|
969
|
+
|
970
|
+
it "uploads media to VDC, fails to add to catalog, and rolls back",
|
971
|
+
:negative do
|
972
|
+
conn = create_mock_client
|
973
|
+
media_file = create_mock_media_file()
|
974
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
975
|
+
media_name = Test::Response::MEDIA_NAME
|
976
|
+
|
977
|
+
conn.rest_connection.response_mapping[:post][
|
978
|
+
Test::Response::CATALOG_ADD_ITEM_LINK] = lambda {
|
979
|
+
|url, data, headers|
|
980
|
+
raise ApiError, "bogus error"
|
981
|
+
}
|
982
|
+
|
983
|
+
conn.rest_connection.should_receive(:[]).with(
|
984
|
+
nested(Test::Response::MEDIA_LINK))
|
985
|
+
conn.rest_connection.should_receive(:delete).with(anything())
|
986
|
+
expect {
|
987
|
+
client.upload_catalog_media(media_name, media_file)
|
988
|
+
}.to raise_exception(/bogus error/)
|
989
|
+
|
990
|
+
end
|
991
|
+
|
992
|
+
it "inserts a media into a VM", :positive do
|
993
|
+
conn = create_mock_client
|
994
|
+
|
995
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
996
|
+
media_name = Test::Response::EXISTING_MEDIA_NAME
|
997
|
+
|
998
|
+
catalog_vapp_id = Test::Response::EXISTING_VAPP_TEMPLATE_CATALOG_URN
|
999
|
+
vapp_name = Test::Response::VAPP_NAME
|
1000
|
+
|
1001
|
+
vapp = client.instantiate_vapp_template(catalog_vapp_id, vapp_name)
|
1002
|
+
vm = vapp.vms.first
|
1003
|
+
client.insert_catalog_media(vm, media_name)
|
1004
|
+
|
1005
|
+
end
|
1006
|
+
|
1007
|
+
end
|
1008
|
+
|
1009
|
+
describe "VCD Adapter client", :metadata, :all do
|
1010
|
+
it "sets and gets metadata on a VM", :positive do
|
1011
|
+
conn = create_mock_client
|
1012
|
+
|
1013
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
1014
|
+
|
1015
|
+
metadata_key = Test::Response::METADATA_KEY
|
1016
|
+
metadata_value = Test::Response::METADATA_VALUE
|
1017
|
+
vapp = client.get_vapp(Test::Response::EXISTING_VAPP_URN)
|
1018
|
+
vm = vapp.vms.first
|
1019
|
+
client.set_metadata(vm, metadata_key, metadata_value)
|
1020
|
+
value = client.get_metadata(vm, metadata_key)
|
1021
|
+
value.should eq metadata_value
|
1022
|
+
end
|
1023
|
+
|
1024
|
+
end
|
1025
|
+
|
1026
|
+
describe "VCD Adapter client", :indy_disk, :all do
|
1027
|
+
it "creates an indepdent disk", :positive do
|
1028
|
+
disk_name = Test::Response::INDY_DISK_NAME
|
1029
|
+
disk_size = Test::Response::INDY_DISK_SIZE
|
1030
|
+
|
1031
|
+
conn = create_mock_client
|
1032
|
+
|
1033
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
1034
|
+
|
1035
|
+
conn.rest_connection.should_receive(:[]).with(
|
1036
|
+
nested(Test::Response::VDC_INDY_DISKS_LINK))
|
1037
|
+
conn.rest_connection.should_receive(:post).with(
|
1038
|
+
Test::Response::INDY_DISK_CREATE_REQUEST, anything())
|
1039
|
+
|
1040
|
+
client.create_disk(disk_name, disk_size)
|
1041
|
+
|
1042
|
+
end
|
1043
|
+
|
1044
|
+
it "creates an indepdent disk but hits an error", :negative do
|
1045
|
+
disk_name = Test::Response::INDY_DISK_NAME
|
1046
|
+
disk_size = Test::Response::INDY_DISK_SIZE
|
1047
|
+
|
1048
|
+
conn = create_mock_client
|
1049
|
+
|
1050
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
1051
|
+
|
1052
|
+
conn.rest_connection.response_mapping[:post][
|
1053
|
+
Test::Response::VDC_INDY_DISKS_LINK] = lambda {
|
1054
|
+
|href, data, headers|
|
1055
|
+
Test::Response::INDY_DISK_CREATE_ERROR
|
1056
|
+
}
|
1057
|
+
expect {
|
1058
|
+
client.create_disk(disk_name, disk_size)
|
1059
|
+
}.to raise_exception(ApiRequestError)
|
1060
|
+
|
1061
|
+
end
|
1062
|
+
|
1063
|
+
it "attaches an indepdent disk to a VM and then detaches", :positive do
|
1064
|
+
disk_name = Test::Response::INDY_DISK_NAME
|
1065
|
+
|
1066
|
+
conn = create_mock_client
|
1067
|
+
|
1068
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
1069
|
+
|
1070
|
+
catalog_vapp_id = Test::Response::EXISTING_VAPP_TEMPLATE_CATALOG_URN
|
1071
|
+
vapp_name = Test::Response::VAPP_NAME
|
1072
|
+
|
1073
|
+
vapp = client.instantiate_vapp_template(catalog_vapp_id, vapp_name)
|
1074
|
+
vm = vapp.vms.first
|
1075
|
+
|
1076
|
+
vdc = client.get_ovdc()
|
1077
|
+
disk = vdc.disks(disk_name).first
|
1078
|
+
|
1079
|
+
conn.rest_connection.response_mapping[:post][
|
1080
|
+
Test::Response::INSTANTIATED_VM_ATTACH_DISK_LINK] = lambda {
|
1081
|
+
|href, data, headers|
|
1082
|
+
data_xml = Nokogiri::XML(data)
|
1083
|
+
expected_xml = Nokogiri::XML(
|
1084
|
+
Test::Response::INDY_DISK_ATTACH_REQUEST)
|
1085
|
+
equality = VCloudSdk::Test::compare_xml(data_xml, expected_xml)
|
1086
|
+
equality.should == true
|
1087
|
+
Test::Response::INDY_DISK_ATTACH_TASK
|
1088
|
+
}
|
1089
|
+
|
1090
|
+
client.attach_disk(disk, vm)
|
1091
|
+
|
1092
|
+
conn.rest_connection.response_mapping[:post][
|
1093
|
+
Test::Response::INSTANTIATED_VM_DETACH_DISK_LINK] = lambda {
|
1094
|
+
|href, data, headers|
|
1095
|
+
data_xml = Nokogiri::XML(data)
|
1096
|
+
expected_xml = Nokogiri::XML(
|
1097
|
+
Test::Response::INDY_DISK_DETACH_REQUEST)
|
1098
|
+
equality = VCloudSdk::Test::compare_xml(data_xml, expected_xml)
|
1099
|
+
equality.should == true
|
1100
|
+
Test::Response::INDY_DISK_DETACH_TASK
|
1101
|
+
}
|
1102
|
+
|
1103
|
+
client.detach_disk(disk, vm)
|
1104
|
+
|
1105
|
+
|
1106
|
+
end
|
1107
|
+
|
1108
|
+
it "attaches an indepdent disk to a VM but has an error", :negative do
|
1109
|
+
disk_name = Test::Response::INDY_DISK_NAME
|
1110
|
+
|
1111
|
+
conn = create_mock_client
|
1112
|
+
|
1113
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
1114
|
+
|
1115
|
+
catalog_vapp_id = Test::Response::EXISTING_VAPP_TEMPLATE_CATALOG_URN
|
1116
|
+
vapp_name = Test::Response::VAPP_NAME
|
1117
|
+
|
1118
|
+
vapp = client.instantiate_vapp_template(catalog_vapp_id, vapp_name)
|
1119
|
+
vm = vapp.vms.first
|
1120
|
+
|
1121
|
+
vdc = client.get_ovdc()
|
1122
|
+
disk = vdc.disks(disk_name).first
|
1123
|
+
|
1124
|
+
conn.rest_connection.response_mapping[:post][
|
1125
|
+
Test::Response::INSTANTIATED_VM_ATTACH_DISK_LINK] = lambda {
|
1126
|
+
|href, data, headers|
|
1127
|
+
Test::Response::INDY_DISK_ATTACH_TASK_ERROR
|
1128
|
+
}
|
1129
|
+
|
1130
|
+
expect {
|
1131
|
+
client.attach_disk(disk, vm)
|
1132
|
+
}.to raise_exception(/.+ Attaching Disk .+ complete successfully\./)
|
1133
|
+
|
1134
|
+
end
|
1135
|
+
|
1136
|
+
it "deletes an independent disk", :positive do
|
1137
|
+
disk_name = Test::Response::INDY_DISK_NAME
|
1138
|
+
|
1139
|
+
conn = create_mock_client
|
1140
|
+
client = Client.new(nil, username, password, entities, control, conn)
|
1141
|
+
vdc = client.get_ovdc()
|
1142
|
+
disk = vdc.disks(disk_name).first
|
1143
|
+
conn.rest_connection.should_receive(:[]).with(
|
1144
|
+
nested(Test::Response::INDY_DISK_URL))
|
1145
|
+
conn.rest_connection.should_receive(:delete).with(anything())
|
1146
|
+
client.delete_disk(disk)
|
1147
|
+
end
|
1148
|
+
|
1149
|
+
end
|
1150
|
+
|
1151
|
+
end
|
1152
|
+
end
|