fog-vcloud-director 0.1.10 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +2 -0
- data/.rubocop.yml +4 -240
- data/.rubocop_local.yml +1 -0
- data/.travis.yml +6 -10
- data/README.md +54 -51
- data/docs/examples-vapp-instantiate.md +2 -2
- data/docs/examples-vm-reconfigure.md +122 -0
- data/docs/vm-to-reconfigure.xml +373 -0
- data/fog-vcloud-director.gemspec +6 -3
- data/lib/fog/vcloud_director.rb +14 -1
- data/lib/fog/vcloud_director/compute.rb +45 -19
- data/lib/fog/vcloud_director/core.rb +3 -3
- data/lib/fog/vcloud_director/generators/compute/compose_common.rb +16 -3
- data/lib/fog/vcloud_director/generators/compute/compose_vapp.rb +3 -3
- data/lib/fog/vcloud_director/generators/compute/create_snapshot.rb +3 -3
- data/lib/fog/vcloud_director/generators/compute/customization.rb +3 -3
- data/lib/fog/vcloud_director/generators/compute/disks.rb +3 -3
- data/lib/fog/vcloud_director/generators/compute/edge_gateway_service_configuration.rb +3 -3
- data/lib/fog/vcloud_director/generators/compute/instantiate_vapp_template_params.rb +3 -3
- data/lib/fog/vcloud_director/generators/compute/metadata.rb +3 -3
- data/lib/fog/vcloud_director/generators/compute/org_vdc_network.rb +4 -4
- data/lib/fog/vcloud_director/generators/compute/recompose_vapp.rb +3 -3
- data/lib/fog/vcloud_director/generators/compute/reconfigure_vm.rb +189 -0
- data/lib/fog/vcloud_director/generators/compute/vapp.rb +3 -4
- data/lib/fog/vcloud_director/generators/compute/vm.rb +3 -3
- data/lib/fog/vcloud_director/generators/compute/vm_network.rb +3 -3
- data/lib/fog/vcloud_director/models/compute/catalog.rb +2 -4
- data/lib/fog/vcloud_director/models/compute/catalog_item.rb +2 -4
- data/lib/fog/vcloud_director/models/compute/catalog_items.rb +3 -4
- data/lib/fog/vcloud_director/models/compute/catalogs.rb +4 -5
- data/lib/fog/vcloud_director/models/compute/custom_field.rb +2 -4
- data/lib/fog/vcloud_director/models/compute/custom_fields.rb +3 -3
- data/lib/fog/vcloud_director/models/compute/disk.rb +5 -6
- data/lib/fog/vcloud_director/models/compute/disks.rb +4 -5
- data/lib/fog/vcloud_director/models/compute/media.rb +2 -4
- data/lib/fog/vcloud_director/models/compute/medias.rb +3 -4
- data/lib/fog/vcloud_director/models/compute/network.rb +2 -4
- data/lib/fog/vcloud_director/models/compute/networks.rb +3 -4
- data/lib/fog/vcloud_director/models/compute/organization.rb +2 -4
- data/lib/fog/vcloud_director/models/compute/organizations.rb +3 -4
- data/lib/fog/vcloud_director/models/compute/tag.rb +3 -4
- data/lib/fog/vcloud_director/models/compute/tags.rb +3 -4
- data/lib/fog/vcloud_director/models/compute/task.rb +2 -4
- data/lib/fog/vcloud_director/models/compute/tasks.rb +3 -4
- data/lib/fog/vcloud_director/models/compute/template_vm.rb +2 -3
- data/lib/fog/vcloud_director/models/compute/template_vms.rb +5 -6
- data/lib/fog/vcloud_director/models/compute/vapp.rb +36 -18
- data/lib/fog/vcloud_director/models/compute/vapp_template.rb +2 -4
- data/lib/fog/vcloud_director/models/compute/vapp_templates.rb +4 -5
- data/lib/fog/vcloud_director/models/compute/vapps.rb +3 -4
- data/lib/fog/vcloud_director/models/compute/vdc.rb +2 -4
- data/lib/fog/vcloud_director/models/compute/vdcs.rb +3 -4
- data/lib/fog/vcloud_director/models/compute/vm.rb +19 -39
- data/lib/fog/vcloud_director/models/compute/vm_customization.rb +2 -4
- data/lib/fog/vcloud_director/models/compute/vm_customizations.rb +3 -4
- data/lib/fog/vcloud_director/models/compute/vm_network.rb +2 -4
- data/lib/fog/vcloud_director/models/compute/vm_networks.rb +3 -4
- data/lib/fog/vcloud_director/models/compute/vms.rb +4 -5
- data/lib/fog/vcloud_director/parsers/compute/disks.rb +3 -3
- data/lib/fog/vcloud_director/parsers/compute/metadata.rb +3 -3
- data/lib/fog/vcloud_director/parsers/compute/network.rb +3 -3
- data/lib/fog/vcloud_director/parsers/compute/vapp.rb +93 -0
- data/lib/fog/vcloud_director/parsers/compute/vm.rb +6 -65
- data/lib/fog/vcloud_director/parsers/compute/vm_customization.rb +3 -3
- data/lib/fog/vcloud_director/parsers/compute/vm_network.rb +3 -3
- data/lib/fog/vcloud_director/parsers/compute/vm_parser_helper.rb +55 -3
- data/lib/fog/vcloud_director/parsers/compute/vms.rb +5 -26
- data/lib/fog/vcloud_director/parsers/compute/vms_by_metadata.rb +3 -3
- data/lib/fog/vcloud_director/query.rb +0 -1
- data/lib/fog/vcloud_director/requests/compute/delete_catalog_item.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/delete_catalog_item_metadata_item_metadata.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/delete_disk.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/delete_disk_metadata_item_metadata.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/delete_logout.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/delete_media.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/delete_media_metadata_item_metadata.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/delete_network.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/delete_shadow_vm.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/delete_vapp.rb +5 -5
- data/lib/fog/vcloud_director/requests/compute/delete_vapp_metadata_item_metadata.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/delete_vapp_template.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/delete_vapp_template_metadata_item_metadata.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_allocated_ip_addresses.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_catalog.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/get_catalog_item.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_catalog_item_metadata.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_catalog_item_metadata_item_metadata.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_catalog_metadata.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_catalog_metadata_item_metadata.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_catalogs_from_query.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_control_access_params_catalog.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_control_access_params_vapp.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_cpu_rasd_item.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_current_session.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_disk.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/get_disk_metadata.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_disk_metadata_item_metadata.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_disk_owner.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/get_disks_from_query.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_disks_rasd_items_list.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_edge_gateway.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/get_entity.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_execute_query.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_groups_from_query.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_guest_customization_system_section_vapp.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_guest_customization_system_section_vapp_template.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_href.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_lease_settings_section_vapp.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/get_lease_settings_section_vapp_template.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_media.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/get_media_drives_rasd_items_list.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_media_metadata.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_media_metadata_item_metadata.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_media_owner.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/get_medias_from_query.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_memory_rasd_item.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_metadata.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_network.rb +5 -5
- data/lib/fog/vcloud_director/requests/compute/get_network_cards_items_list.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_network_complete.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/get_network_config_section_vapp.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_network_config_section_vapp_template.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_network_connection_system_section_vapp.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_network_connection_system_section_vapp_template.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_network_metadata.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_network_metadata_item_metadata.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_network_section_vapp.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_network_section_vapp_template.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_operating_system_section.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_org_settings.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_org_vdc_gateways.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/get_organization.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/get_organization_metadata.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_organization_metadata_item_metadata.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_organizations.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_organizations_from_query.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_product_sections_vapp.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_product_sections_vapp_template.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_request.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_runtime_info_section_type.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_serial_ports_items_list.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_shadow_vm.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_snapshot_section.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_startup_section.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_supported_systems_info.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_supported_versions.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_task.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/get_task_list.rb +5 -5
- data/lib/fog/vcloud_director/requests/compute/get_template_vm.rb +4 -50
- data/lib/fog/vcloud_director/requests/compute/get_template_vms.rb +3 -16
- data/lib/fog/vcloud_director/requests/compute/get_thumbnail.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_users_from_query.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_vapp.rb +9 -8
- data/lib/fog/vcloud_director/requests/compute/get_vapp_metadata.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/get_vapp_metadata_item_metadata.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_vapp_ovf_descriptor.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_vapp_owner.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/get_vapp_template.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_vapp_template_customization_system_section.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_vapp_template_metadata.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_vapp_template_metadata_item_metadata.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_vapp_template_ovf_descriptor.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_vapp_template_owner.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_vapp_templates_from_query.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_vapps_in_lease_from_query.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_vcloud.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_vdc.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/get_vdc_metadata.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_vdc_metadata_item_metadata.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_vdc_storage_class.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/get_vdc_storage_class_metadata.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_vdc_storage_class_metadata_item_metadata.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_vdcs_from_query.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_virtual_hardware_section.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_vm.rb +3 -49
- data/lib/fog/vcloud_director/requests/compute/get_vm_capabilities.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_vm_compliance_results.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_vm_customization.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_vm_disks.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_vm_network.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_vm_pending_question.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/get_vms_by_metadata.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_vms_disk_attached_to.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/get_vms_in_lease_from_query.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/instantiate_vapp_template.rb +6 -6
- data/lib/fog/vcloud_director/requests/compute/post_acquire_mks_ticket.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/post_acquire_ticket.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/post_answer_vm_pending_question.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_attach_disk.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_cancel_task.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/post_capture_vapp.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_check_vm_compliance.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_clone_media.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/post_clone_vapp.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_clone_vapp_template.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_compose_vapp.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/post_configure_edge_gateway_services.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/post_consolidate_vm_vapp.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_consolidate_vm_vapp_template.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_create_catalog_item.rb +5 -5
- data/lib/fog/vcloud_director/requests/compute/post_create_org_vdc_network.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/post_create_snapshot.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/post_deploy_vapp.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_detach_disk.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_disable_nested_hv.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_disable_vapp_template_download.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_discard_vapp_state.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_eject_cd_rom.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_enable_nested_hv.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_enable_vapp_template_download.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_enter_maintenance_mode.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_exit_maintenance_mode.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_insert_cd_rom.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_install_vmware_tools.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_instantiate_vapp_template.rb +6 -6
- data/lib/fog/vcloud_director/requests/compute/post_login_session.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_power_off_vapp.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/post_power_on_vapp.rb +6 -6
- data/lib/fog/vcloud_director/requests/compute/post_reboot_vapp.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/post_recompose_vapp.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/post_reconfigure_vm.rb +6 -86
- data/lib/fog/vcloud_director/requests/compute/post_remove_all_snapshots.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_reset_vapp.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/post_revert_snapshot.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_shutdown_vapp.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/post_suspend_vapp.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/post_undeploy_vapp.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/post_update_catalog_item_metadata.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_update_disk_metadata.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_update_media_metadata.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/post_update_vapp_template_metadata.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_upgrade_hw_version.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/post_upload_disk.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/post_upload_media.rb +7 -7
- data/lib/fog/vcloud_director/requests/compute/post_upload_vapp_template.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/put_catalog_item_metadata_item_metadata.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/put_cpu.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/put_disk_metadata_item_metadata.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/put_disks.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/put_guest_customization_section_vapp.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/put_media_metadata_item_metadata.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/put_memory.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/put_metadata_value.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/put_network.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/put_network_connection_system_section_vapp.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/put_product_sections.rb +2 -2
- data/lib/fog/vcloud_director/requests/compute/put_vapp_metadata_item_metadata.rb +4 -4
- data/lib/fog/vcloud_director/requests/compute/put_vapp_name_and_description.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/put_vapp_template_metadata_item_metadata.rb +3 -3
- data/lib/fog/vcloud_director/requests/compute/put_vm.rb +5 -5
- data/lib/fog/vcloud_director/requests/compute/put_vm_capabilities.rb +2 -2
- data/lib/fog/vcloud_director/version.rb +1 -1
- data/spec/common_assertions.rb +42 -0
- data/spec/fixtures/empty_vm.xml +244 -0
- data/spec/fixtures/vm.xml +419 -0
- data/spec/secrets.yaml.templ +3 -0
- data/spec/spec_helper.rb +6 -6
- data/spec/vcloud_director/generators/compute/compose_common_spec.rb +3 -8
- data/spec/vcloud_director/generators/compute/compose_vapp_spec.rb +67 -0
- data/spec/vcloud_director/generators/compute/create_snapshot_spec.rb +4 -0
- data/spec/vcloud_director/generators/compute/customization_spec.rb +4 -0
- data/spec/vcloud_director/generators/compute/disks_spec.rb +4 -0
- data/spec/vcloud_director/generators/compute/edge_gateway_service_configuration_spec.rb +4 -0
- data/spec/vcloud_director/generators/compute/instantiate_vapp_template_params_spec.rb +7 -10
- data/spec/vcloud_director/generators/compute/metadata_spec.rb +4 -0
- data/spec/vcloud_director/generators/compute/org_vdc_network_spec.rb +4 -0
- data/spec/vcloud_director/generators/compute/recompose_vapp_spec.rb +4 -0
- data/spec/vcloud_director/generators/compute/reconfigure_vm_spec.rb +390 -0
- data/spec/vcloud_director/generators/compute/vapp_spec.rb +4 -0
- data/spec/vcloud_director/generators/compute/vm_network_spec.rb +4 -0
- data/spec/vcloud_director/generators/compute/vm_spec.rb +4 -0
- data/spec/vcloud_director/models/compute/basic_spec.rb +44 -0
- data/spec/vcloud_director/models/compute/vapps_spec.rb +104 -0
- data/spec/vcloud_director/models/compute/vms_spec.rb +80 -0
- data/spec/vcloud_director/parsers/compute/disks_spec.rb +4 -0
- data/spec/vcloud_director/parsers/compute/metadata_spec.rb +4 -0
- data/spec/vcloud_director/parsers/compute/network_spec.rb +4 -0
- data/spec/vcloud_director/parsers/compute/vm_customization_spec.rb +4 -0
- data/spec/vcloud_director/parsers/compute/vm_network_spec.rb +4 -0
- data/spec/vcloud_director/parsers/compute/vm_parser_helper_spec.rb +4 -0
- data/spec/vcloud_director/parsers/compute/vm_spec.rb +4 -0
- data/spec/vcloud_director/parsers/compute/vms_by_metadata_spec.rb +4 -0
- data/spec/vcloud_director/parsers/compute/vms_spec.rb +4 -0
- data/spec/vcloud_director/requests/compute/basic_spec.rb +212 -0
- data/spec/vcloud_director/requests/compute/get_vapp_spec.rb +11 -0
- data/spec/vcloud_director/requests/compute/get_vdc_spec.rb +10 -0
- data/spec/vcloud_director/requests/compute/instantiate_vapp_template_spec.rb +3 -5
- data/spec/vcloud_director/requests/compute/post_reconfigure_vm_spec.rb +26 -0
- data/spec/vcr_cassettes/authentication.yml +48 -0
- data/spec/vcr_cassettes/get_vapp-emptyvm.yml +806 -0
- data/spec/vcr_cassettes/get_vapp.yml +937 -0
- data/spec/vcr_cassettes/get_vapps-expired.yml +918 -0
- data/spec/vcr_cassettes/get_vapps-novms.yml +215 -0
- data/spec/vcr_cassettes/get_vapps.yml +118 -0
- data/spec/vcr_cassettes/get_vdc.yml +118 -0
- data/spec/vcr_cassettes/get_vm.yml +398 -0
- data/spec/vcr_cassettes/post_reconfigure_vm-virtual_hardware.yml +445 -0
- data/spec/vcr_spec_helper.rb +34 -0
- data/tasks/test.rake +3 -10
- data/tests/vcloud_director/ensure_list_tests.rb +1 -1
- data/tests/vcloud_director/generators/compute/compose_vapp_tests.rb +1 -1
- data/tests/vcloud_director/models/compute/helper.rb +1 -1
- data/tests/vcloud_director/models/compute/media_tests.rb +1 -1
- data/tests/vcloud_director/models/compute/network_tests.rb +1 -1
- data/tests/vcloud_director/models/compute/tasks_tests.rb +1 -1
- data/tests/vcloud_director/models/compute/vapp_template_tests.rb +1 -1
- data/tests/vcloud_director/models/compute/vms_tests.rb +6 -6
- data/tests/vcloud_director/requests/compute/admin_tests.rb +1 -1
- data/tests/vcloud_director/requests/compute/catalog_tests.rb +2 -2
- data/tests/vcloud_director/requests/compute/disk_tests.rb +11 -11
- data/tests/vcloud_director/requests/compute/edge_gateway_tests.rb +8 -8
- data/tests/vcloud_director/requests/compute/groups_tests.rb +1 -1
- data/tests/vcloud_director/requests/compute/media_tests.rb +11 -11
- data/tests/vcloud_director/requests/compute/network_tests.rb +6 -6
- data/tests/vcloud_director/requests/compute/organization_tests.rb +2 -2
- data/tests/vcloud_director/requests/compute/ovf_descriptor_tests.rb +1 -1
- data/tests/vcloud_director/requests/compute/query_tests.rb +1 -1
- data/tests/vcloud_director/requests/compute/session_tests.rb +1 -1
- data/tests/vcloud_director/requests/compute/supported_systems_tests.rb +1 -1
- data/tests/vcloud_director/requests/compute/task_tests.rb +4 -4
- data/tests/vcloud_director/requests/compute/users_tests.rb +1 -1
- data/tests/vcloud_director/requests/compute/vapp_tests.rb +4 -4
- data/tests/vcloud_director/requests/compute/vdc_storage_profile_tests.rb +2 -2
- data/tests/vcloud_director/requests/compute/vdc_tests.rb +2 -2
- data/tests/vcloud_director/requests/compute/versions_tests.rb +1 -1
- data/tests/vcloud_director/requests/compute/vm_tests.rb +4 -4
- metadata +140 -13
- data/lib/fog/vcloud_director/requests/compute/get_vms.rb +0 -41
- data/spec/vcloud_director/spec_helper.rb +0 -13
data/fog-vcloud-director.gemspec
CHANGED
@@ -18,14 +18,17 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.required_ruby_version = "
|
21
|
+
spec.required_ruby_version = ">= 2.0"
|
22
22
|
|
23
|
-
spec.add_dependency "fog-core"
|
23
|
+
spec.add_dependency "fog-core", ">= 1.40" # tested on 1.40 and 2.1.0
|
24
24
|
spec.add_dependency "fog-xml"
|
25
25
|
|
26
26
|
spec.add_development_dependency "rake"
|
27
27
|
spec.add_development_dependency "shindo"
|
28
28
|
spec.add_development_dependency "minitest"
|
29
|
+
spec.add_development_dependency "mocha"
|
29
30
|
spec.add_development_dependency "vcr"
|
30
|
-
spec.add_development_dependency "
|
31
|
+
spec.add_development_dependency "webmock"
|
32
|
+
spec.add_development_dependency "rubocop", "~>0.52.1"
|
33
|
+
spec.add_development_dependency "pronto-rubocop"
|
31
34
|
end
|
data/lib/fog/vcloud_director.rb
CHANGED
@@ -1,2 +1,15 @@
|
|
1
|
-
require '
|
1
|
+
require 'pp'
|
2
2
|
require 'securerandom'
|
3
|
+
|
4
|
+
require 'fog/core'
|
5
|
+
require 'fog/core/model'
|
6
|
+
require 'fog/core/collection'
|
7
|
+
require 'fog/xml'
|
8
|
+
require 'fog/vcloud_director/core'
|
9
|
+
require 'fog/vcloud_director/query'
|
10
|
+
require 'fog/vcloud_director/compute'
|
11
|
+
|
12
|
+
Dir[File.join(File.dirname(__FILE__), 'vcloud_director', 'generators', '**', '*.rb')].sort.each {|file| require file }
|
13
|
+
Dir[File.join(File.dirname(__FILE__), 'vcloud_director', 'models', '**', '*.rb')].sort.each {|file| require file }
|
14
|
+
Dir[File.join(File.dirname(__FILE__), 'vcloud_director', 'parsers', '**', '*.rb')].sort.each {|file| require file }
|
15
|
+
Dir[File.join(File.dirname(__FILE__), 'vcloud_director', 'requests', '**', '*.rb')].sort.each {|file| require file }
|
@@ -1,6 +1,3 @@
|
|
1
|
-
require 'fog/vcloud_director/core'
|
2
|
-
require 'fog/vcloud_director/query'
|
3
|
-
|
4
1
|
class VcloudDirectorParser < Fog::Parsers::Base
|
5
2
|
def extract_attributes(attributes_xml)
|
6
3
|
attributes = {}
|
@@ -23,8 +20,8 @@ class NonLoaded
|
|
23
20
|
end
|
24
21
|
|
25
22
|
module Fog
|
26
|
-
module
|
27
|
-
class
|
23
|
+
module VcloudDirector
|
24
|
+
class Compute < Fog::Service
|
28
25
|
module Defaults
|
29
26
|
PATH = '/api'
|
30
27
|
PORT = 443
|
@@ -44,6 +41,8 @@ module Fog
|
|
44
41
|
class DuplicateName < Fog::VcloudDirector::Errors::DuplicateName; end
|
45
42
|
class TaskError < Fog::VcloudDirector::Errors::TaskError; end
|
46
43
|
|
44
|
+
class PreProcessingError < Fog::Errors::Error; end
|
45
|
+
|
47
46
|
requires :vcloud_director_username, :vcloud_director_password, :vcloud_director_host
|
48
47
|
recognizes :vcloud_director_api_version, :vcloud_director_show_progress, :path, :vcloud_token, :port
|
49
48
|
|
@@ -196,7 +195,6 @@ module Fog
|
|
196
195
|
request :get_vm_disks
|
197
196
|
request :get_vm_network
|
198
197
|
request :get_vm_pending_question
|
199
|
-
request :get_vms
|
200
198
|
request :get_vms_by_metadata
|
201
199
|
request :get_vms_disk_attached_to
|
202
200
|
request :get_vms_in_lease_from_query
|
@@ -322,19 +320,33 @@ module Fog
|
|
322
320
|
end
|
323
321
|
|
324
322
|
def get_by_name(item_name)
|
325
|
-
item_found =
|
323
|
+
item_found = _item_list.find { |item| item[:name] == item_name }
|
326
324
|
return nil unless item_found
|
327
325
|
get(item_found[:id])
|
328
326
|
end
|
329
327
|
|
330
328
|
def index
|
331
|
-
load(
|
329
|
+
load(_item_list)
|
332
330
|
end
|
333
331
|
|
334
332
|
def get_everyone
|
335
|
-
items =
|
333
|
+
items = _item_list.map { |item| get_by_id(item[:id]) }
|
336
334
|
load(items)
|
337
335
|
end
|
336
|
+
|
337
|
+
# Use pre-fetched list of items. Particularly useful when parent's XML already contains enough information
|
338
|
+
# about child entities, hence we can parse them on parent already to reduce API requests. Some examples:
|
339
|
+
# - vApp XML contains all the information about each of its child VMs, so we can pre-fetch `vapp.vms`
|
340
|
+
# - VM XML contains all the information about customization, so we can pre-fecth `vm.guest_customization`
|
341
|
+
# - VM XML contains all the information about disks, so we can pre-fetch `vm.disks`
|
342
|
+
def with_item_list(hashes)
|
343
|
+
@items = Array(hashes)
|
344
|
+
self
|
345
|
+
end
|
346
|
+
|
347
|
+
def _item_list
|
348
|
+
@items || item_list || []
|
349
|
+
end
|
338
350
|
end
|
339
351
|
|
340
352
|
class Real
|
@@ -348,15 +360,15 @@ module Fog
|
|
348
360
|
@vcloud_director_password = options[:vcloud_director_password]
|
349
361
|
@vcloud_director_username = options[:vcloud_director_username]
|
350
362
|
@connection_options = options[:connection_options] || {}
|
351
|
-
@connection_options[:omit_default_port] = Fog::Compute::
|
363
|
+
@connection_options[:omit_default_port] = Fog::VcloudDirector::Compute::Defaults::OMIT_DEFAULT_PORT unless @connection_options[:omit_default_port]
|
352
364
|
@host = options[:vcloud_director_host]
|
353
|
-
@path = options[:path] || Fog::Compute::
|
365
|
+
@path = options[:path] || Fog::VcloudDirector::Compute::Defaults::PATH
|
354
366
|
@persistent = options[:persistent] || false
|
355
|
-
@port = options[:port] || Fog::Compute::
|
356
|
-
@scheme = options[:scheme] || Fog::Compute::
|
367
|
+
@port = options[:port] || Fog::VcloudDirector::Compute::Defaults::PORT
|
368
|
+
@scheme = options[:scheme] || Fog::VcloudDirector::Compute::Defaults::SCHEME
|
357
369
|
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
|
358
370
|
@end_point = "#{@scheme}://#{@host}#{@path}/"
|
359
|
-
@api_version = options[:vcloud_director_api_version] || Fog::Compute::
|
371
|
+
@api_version = options[:vcloud_director_api_version] || Fog::VcloudDirector::Compute::Defaults::API_VERSION
|
360
372
|
@show_progress = options[:vcloud_director_show_progress]
|
361
373
|
@show_progress = $stdin.tty? if @show_progress.nil?
|
362
374
|
@vcloud_token = options[:vcloud_token]
|
@@ -394,9 +406,23 @@ module Fog
|
|
394
406
|
response.body[:href].split('/').last # returns the vapp_id if it was instantiated successfully.
|
395
407
|
end
|
396
408
|
|
409
|
+
# Perform HTTP request against vCloud API.
|
410
|
+
#
|
411
|
+
# @param [Hash] params request parameters.
|
412
|
+
# - params[:parser] SAX parser class, SAX parser instance or string. String can be one of:
|
413
|
+
# - 'plaintext': returns unparsed text in response.body
|
414
|
+
# - 'xml': returns Nokogiri::XML instance in response.body
|
415
|
+
# @return [Excon::Response]
|
397
416
|
def request(params)
|
398
417
|
begin
|
399
|
-
|
418
|
+
parser_type = params[:parser]
|
419
|
+
params[:parser] = nil if parser_type.instance_of?(String)
|
420
|
+
params[:parser] = parser_type.new if parser_type.respond_to?(:new)
|
421
|
+
|
422
|
+
resp = do_request(params)
|
423
|
+
|
424
|
+
resp.body = Nokogiri::XML(resp.body) if parser_type == 'xml'
|
425
|
+
resp
|
400
426
|
rescue EOFError
|
401
427
|
# This error can occur if Vcloud receives a request from a network
|
402
428
|
# it deems to be unauthorized; no HTTP response is sent, but the
|
@@ -806,13 +832,13 @@ module Fog
|
|
806
832
|
@vcloud_director_username = options[:vcloud_director_username]
|
807
833
|
#@connection_options = options[:connection_options] || {}
|
808
834
|
@host = options[:vcloud_director_host]
|
809
|
-
@path = options[:path] || Fog::Compute::
|
835
|
+
@path = options[:path] || Fog::VcloudDirector::Compute::Defaults::PATH
|
810
836
|
@persistent = options[:persistent] || false
|
811
|
-
@port = options[:port] || Fog::Compute::
|
812
|
-
@scheme = options[:scheme] || Fog::Compute::
|
837
|
+
@port = options[:port] || Fog::VcloudDirector::Compute::Defaults::PORT
|
838
|
+
@scheme = options[:scheme] || Fog::VcloudDirector::Compute::Defaults::SCHEME
|
813
839
|
#@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
|
814
840
|
@end_point = "#{@scheme}://#{@host}#{@path}/"
|
815
|
-
@api_version = options[:vcloud_director_api_version] || Fog::Compute::
|
841
|
+
@api_version = options[:vcloud_director_api_version] || Fog::VcloudDirector::Compute::Defaults::API_VERSION
|
816
842
|
@vcloud_token = options[:vcloud_token]
|
817
843
|
end
|
818
844
|
|
@@ -1,6 +1,3 @@
|
|
1
|
-
require 'fog/core'
|
2
|
-
require 'fog/xml'
|
3
|
-
|
4
1
|
module Fog
|
5
2
|
module VcloudDirector
|
6
3
|
extend Fog::Provider
|
@@ -64,6 +61,9 @@ module Fog
|
|
64
61
|
class TaskError < ServiceError; end
|
65
62
|
end
|
66
63
|
|
64
|
+
# Services
|
65
|
+
autoload :Compute, File.expand_path('../compute', __FILE__)
|
66
|
+
|
67
67
|
service(:compute, 'Compute')
|
68
68
|
end
|
69
69
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Fog
|
2
|
-
module
|
3
|
-
module
|
4
|
-
module
|
2
|
+
module VcloudDirector
|
3
|
+
module Generators
|
4
|
+
module Compute
|
5
5
|
module ComposeCommon
|
6
6
|
|
7
7
|
def initialize(configuration={})
|
@@ -251,6 +251,19 @@ module Fog
|
|
251
251
|
return 'bridged' unless mode && mode != 'isolated'
|
252
252
|
mode
|
253
253
|
end
|
254
|
+
|
255
|
+
def network_section_nic(xml, new_idx:, name: 'none', mac: nil, ip: nil, connected: true, mode: 'DHCP', type: nil, needs: nil)
|
256
|
+
attr = { :network => name }
|
257
|
+
attr[:needsCustomization] = needs unless needs.nil?
|
258
|
+
xml.NetworkConnection(attr) do
|
259
|
+
xml.NetworkConnectionIndex(new_idx) if new_idx
|
260
|
+
xml.IpAddress(ip) unless ip.nil?
|
261
|
+
xml.IsConnected(connected) unless connected.nil?
|
262
|
+
xml.MACAddress(mac) if mac
|
263
|
+
xml.IpAddressAllocationMode(mode) if mode
|
264
|
+
xml.NetworkAdapterType(type) if type
|
265
|
+
end
|
266
|
+
end
|
254
267
|
end
|
255
268
|
end
|
256
269
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'fog/vcloud_director/generators/compute/compose_common'
|
2
2
|
|
3
3
|
module Fog
|
4
|
-
module
|
5
|
-
module
|
6
|
-
module
|
4
|
+
module VcloudDirector
|
5
|
+
module Generators
|
6
|
+
module Compute
|
7
7
|
# @see http://pubs.vmware.com/vcd-51/index.jsp#types/ComposeVAppParamsType.html
|
8
8
|
class ComposeVapp
|
9
9
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Fog
|
2
|
-
module
|
3
|
-
module
|
4
|
-
module
|
2
|
+
module VcloudDirector
|
3
|
+
module Generators
|
4
|
+
module Compute
|
5
5
|
# @see http://pubs.vmware.com/vcd-56/topic/com.vmware.ICbase/PDF/vcd_56_api_guide.pdf @page 121
|
6
6
|
class CreateSnapshot
|
7
7
|
attr_reader :attrs
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'fog/vcloud_director/generators/compute/compose_common'
|
2
2
|
|
3
3
|
module Fog
|
4
|
-
module
|
5
|
-
module
|
6
|
-
module
|
4
|
+
module VcloudDirector
|
5
|
+
module Generators
|
6
|
+
module Compute
|
7
7
|
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/types/VAppType.html
|
8
8
|
class InstantiateVappTemplateParams
|
9
9
|
attr_reader :options
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Fog
|
2
|
-
module
|
3
|
-
module
|
4
|
-
module
|
2
|
+
module VcloudDirector
|
3
|
+
module Generators
|
4
|
+
module Compute
|
5
5
|
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/types/OrgVdcNetworkType.html
|
6
6
|
class OrgVdcNetwork
|
7
7
|
attr_reader :options
|
@@ -11,7 +11,7 @@ module Fog
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def generate_xml
|
14
|
-
|
14
|
+
Nokogiri::XML::Builder.new do
|
15
15
|
attrs = {
|
16
16
|
:xmlns => 'http://www.vmware.com/vcloud/v1.5',
|
17
17
|
:name => options[:name]
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'fog/vcloud_director/generators/compute/compose_common'
|
2
2
|
|
3
3
|
module Fog
|
4
|
-
module
|
5
|
-
module
|
6
|
-
module
|
4
|
+
module VcloudDirector
|
5
|
+
module Generators
|
6
|
+
module Compute
|
7
7
|
# @see http://pubs.vmware.com/vcd-51/index.jsp#types/RecomposeVAppParamsType.html
|
8
8
|
class RecomposeVapp
|
9
9
|
|
@@ -0,0 +1,189 @@
|
|
1
|
+
require 'fog/vcloud_director/generators/compute/compose_common'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module VcloudDirector
|
5
|
+
module Generators
|
6
|
+
module Compute
|
7
|
+
class ReconfigureVm
|
8
|
+
extend ComposeCommon
|
9
|
+
|
10
|
+
NETWORK_SECTION_ORDER = ['ovf:Info'] + %w(PrimaryNetworkConnectionIndex NetworkConnection Link)
|
11
|
+
NETWORK_CONNECTION_ORDER = %w(NetworkConnectionIndex IpAddress ExternalIpAddress IsConnected MACAddress IpAddressAllocationMode NetworkAdapterType).freeze
|
12
|
+
|
13
|
+
class << self
|
14
|
+
# Generates VM reconfiguration XML.
|
15
|
+
#
|
16
|
+
# @param [Nokogiri::Xml] current DOM representing current VM configuration.
|
17
|
+
# @param [Hash] options desired configuration. Please see examples-vm-reconfigure.md for details.
|
18
|
+
#
|
19
|
+
# @return [String] xml string, a modification of `current` input, with desired configurations applied.
|
20
|
+
def generate_xml(current, options)
|
21
|
+
current.root['name'] = options[:name] if options[:name]
|
22
|
+
current.at('Description').content = options[:description] if options[:description]
|
23
|
+
# Remove entire section when no moification is required to improve performance, see
|
24
|
+
# https://pubs.vmware.com/vcd-80/index.jsp#com.vmware.vcloud.api.sp.doc_90/GUID-4759B018-86C2-4C91-8176-3EC73CD7122B.html
|
25
|
+
options[:hardware] ? update_virtual_hardware_section(current, options[:hardware]) : current.at('//ovf:VirtualHardwareSection').remove
|
26
|
+
options[:networks] ? update_network_connection_section(current, options[:networks]) : current.at('//xmlns:NetworkConnectionSection').remove
|
27
|
+
current.at('//ovf:OperatingSystemSection').remove # TODO(miha-plesko): support this type of customization
|
28
|
+
current.at('//xmlns:GuestCustomizationSection').remove # TODO(miha-plesko): support this type of customization
|
29
|
+
|
30
|
+
current.to_xml
|
31
|
+
end
|
32
|
+
|
33
|
+
# Apply desired hardware modifications to the original xml.
|
34
|
+
def update_virtual_hardware_section(xml, hardware)
|
35
|
+
update_virtual_hardware_section_item_mem(xml, **hardware[:memory]) if hardware[:memory]
|
36
|
+
update_virtual_hardware_section_item_cpu(xml, **hardware[:cpu]) if hardware[:cpu]
|
37
|
+
array_wrap(hardware[:disk]).reject { |d| d[:id].nil? || d[:capacity_mb] == -1 }.each { |disk| update_virtual_hardware_section_item_hdd(xml, **disk) }
|
38
|
+
array_wrap(hardware[:disk]).select { |d| d[:id].nil? }.each { |disk| add_virtual_hardware_section_item_hdd(xml, **disk) }
|
39
|
+
array_wrap(hardware[:disk]).select { |d| d[:capacity_mb] == -1 }.each { |disk| remove_virtual_hardware_section_item_hdd(xml, id: disk[:id]) }
|
40
|
+
end
|
41
|
+
|
42
|
+
# Apply desired NIC connection modifications to the original xml.
|
43
|
+
def update_network_connection_section(xml, networks)
|
44
|
+
array_wrap(networks).reject { |n| n[:new_idx] == -1 || n[:idx].nil? }.each { |nic| update_network_connection_section_by_index(xml, **nic) }
|
45
|
+
array_wrap(networks).select { |n| n[:new_idx] == -1 }.each { |nic| remove_network_connection_section_by_index(xml, :idx => nic[:idx]) }
|
46
|
+
array_wrap(networks).select { |n| n[:idx].nil? }.each { |nic| add_network_connection_section(xml, **nic) }
|
47
|
+
end
|
48
|
+
|
49
|
+
def update_virtual_hardware_section_item_cpu(xml, num_cores: nil, cores_per_socket: nil, reservation: nil, limit: nil, weight: nil)
|
50
|
+
update_virtual_hardware_section_item(xml, :type => 3) do |item|
|
51
|
+
item.at('./rasd:VirtualQuantity').content = num_cores if num_cores
|
52
|
+
item.at('./rasd:Reservation').content = reservation if reservation
|
53
|
+
item.at('./rasd:Limit').content = limit if limit
|
54
|
+
item.at('./rasd:Weight').content = weight if weight
|
55
|
+
item.at('./vmw:CoresPerSocket').content = cores_per_socket if cores_per_socket
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def update_virtual_hardware_section_item_mem(xml, quantity_mb: nil, reservation: nil, limit: nil, weight: nil)
|
60
|
+
update_virtual_hardware_section_item(xml, :type => 4) do |item|
|
61
|
+
item.at('./rasd:VirtualQuantity').content = quantity_mb if quantity_mb
|
62
|
+
item.at('./rasd:Reservation').content = reservation if reservation
|
63
|
+
item.at('./rasd:Limit').content = limit if limit
|
64
|
+
item.at('./rasd:Weight').content = weight if weight
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def update_virtual_hardware_section_item_hdd(xml, id:, capacity_mb: nil, address: nil, type: nil, subtype: nil)
|
69
|
+
hdd_exists = update_virtual_hardware_section_item(xml, :type => 17, :id => id) do |item|
|
70
|
+
item.at('./rasd:AddressOnParent').content = address if address
|
71
|
+
item.at('./rasd:HostResource')['ns13:capacity'] = capacity_mb if capacity_mb
|
72
|
+
item.at('./rasd:HostResource')['ns13:busType'] = type if type
|
73
|
+
item.at('./rasd:HostResource')['ns13:busSubType'] = subtype if subtype
|
74
|
+
end
|
75
|
+
raise Fog::VcloudDirector::Compute::PreProcessingError.new("Error resizing disk: disk with id '#{id}' does not exist.") unless hdd_exists
|
76
|
+
end
|
77
|
+
|
78
|
+
def remove_virtual_hardware_section_item_hdd(xml, id:)
|
79
|
+
remove_virtual_hardware_section_item(xml, :type => 17, :id => id)
|
80
|
+
end
|
81
|
+
|
82
|
+
def add_virtual_hardware_section_item_hdd(xml, **disk)
|
83
|
+
disk[:id] = rand(10_000..100_000)
|
84
|
+
add_virtual_hardware_section_item(xml) do |section|
|
85
|
+
virtual_hardware_section_item_hdd(section, **disk)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def add_virtual_hardware_section_item(xml)
|
90
|
+
virtual_hardware = xml.at('//ovf:VirtualHardwareSection')
|
91
|
+
virtual_hardware.add_namespace_definition('vcloud', 'http://www.vmware.com/vcloud/v1.5')
|
92
|
+
Nokogiri::XML::Builder.with(virtual_hardware) do |section|
|
93
|
+
yield section
|
94
|
+
end
|
95
|
+
# Move the new item to satisfy vCloud's sorting requirements.
|
96
|
+
item = virtual_hardware.at('./ovf:Item[last()]').remove
|
97
|
+
virtual_hardware.at('./ovf:Item[last()]').after(item)
|
98
|
+
end
|
99
|
+
|
100
|
+
def update_virtual_hardware_section_item(xml, type:, id: nil)
|
101
|
+
condition = "rasd:ResourceType = '#{type}'"
|
102
|
+
condition += " and rasd:InstanceID = '#{id}'" if id
|
103
|
+
if (item = xml.at("//ovf:VirtualHardwareSection/ovf:Item[#{condition}]"))
|
104
|
+
yield item
|
105
|
+
true
|
106
|
+
else
|
107
|
+
false
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def remove_virtual_hardware_section_item(xml, type:, id:)
|
112
|
+
item = xml.at("//ovf:VirtualHardwareSection/ovf:Item[rasd:ResourceType = '#{type}' and rasd:InstanceID = '#{id}']")
|
113
|
+
item.remove if item
|
114
|
+
end
|
115
|
+
|
116
|
+
def update_network_connection_section_by_index(xml, idx:, name: nil, mac: nil, ip: nil, connected: nil, mode: nil, type: nil, needs: nil, new_idx: nil, primary: nil)
|
117
|
+
conn = xml.at("//xmlns:NetworkConnectionSection/xmlns:NetworkConnection[./xmlns:NetworkConnectionIndex = '#{idx}']")
|
118
|
+
conn['network'] = name if name
|
119
|
+
conn['needsCustomization'] = needs unless needs.nil?
|
120
|
+
leaf_at(conn, 'IpAddress', NETWORK_CONNECTION_ORDER).content = ip unless ip.nil?
|
121
|
+
leaf_at(conn, 'IpAddressAllocationMode', NETWORK_CONNECTION_ORDER).content = mode if mode
|
122
|
+
leaf_at(conn, 'IsConnected', NETWORK_CONNECTION_ORDER).content = connected unless connected.nil?
|
123
|
+
leaf_at(conn, 'MACAddress', NETWORK_CONNECTION_ORDER).content = mac if mac
|
124
|
+
leaf_at(conn, 'NetworkAdapterType', NETWORK_CONNECTION_ORDER).content = type if type
|
125
|
+
leaf_at(conn, 'NetworkConnectionIndex', NETWORK_CONNECTION_ORDER).content = new_idx if new_idx
|
126
|
+
|
127
|
+
set_primary_nic(xml, new_idx || idx) if primary
|
128
|
+
end
|
129
|
+
|
130
|
+
def remove_network_connection_section_by_index(xml, idx:)
|
131
|
+
conn = xml.at("//xmlns:NetworkConnectionSection/xmlns:NetworkConnection[./xmlns:NetworkConnectionIndex = '#{idx}']")
|
132
|
+
conn.remove if conn
|
133
|
+
end
|
134
|
+
|
135
|
+
def add_network_connection_section(xml, primary: nil, **nic)
|
136
|
+
nic.delete(:idx)
|
137
|
+
network_section = xml.at('//xmlns:NetworkConnectionSection')
|
138
|
+
network_section.add_namespace_definition('vcloud', 'http://www.vmware.com/vcloud/v1.5')
|
139
|
+
Nokogiri::XML::Builder.with(network_section) do |section|
|
140
|
+
network_section_nic(section, **nic)
|
141
|
+
end
|
142
|
+
|
143
|
+
# Move the new item to satisfy vCloud's sorting requirements.
|
144
|
+
item = network_section.at('./xmlns:NetworkConnection[last()]').remove
|
145
|
+
(previous = find_previous(network_section, 'NetworkConnection', NETWORK_SECTION_ORDER)) ? previous.after(item) : network_section.prepend_child(item)
|
146
|
+
|
147
|
+
set_primary_nic(xml, nic[:new_idx]) if primary
|
148
|
+
end
|
149
|
+
|
150
|
+
def set_primary_nic(xml, idx)
|
151
|
+
leaf_at(xml.at('//xmlns:NetworkConnectionSection'), 'PrimaryNetworkConnectionIndex', NETWORK_SECTION_ORDER).content = idx
|
152
|
+
end
|
153
|
+
|
154
|
+
# Find leaf element if present or create new one. Respect XML ordering when adding new.
|
155
|
+
# Arguments:
|
156
|
+
# - xml: parent xml whose child element are we updating/adding
|
157
|
+
# - leaf_name: child element name (without namespace)
|
158
|
+
# - order: list of child names in proper order
|
159
|
+
# - ns: leaf element's namespace
|
160
|
+
# Returns:
|
161
|
+
# - leaf element
|
162
|
+
def leaf_at(xml, leaf_name, order, ns: 'xmlns')
|
163
|
+
el = xml.at("./#{ns}:#{leaf_name}")
|
164
|
+
el || begin
|
165
|
+
el = Nokogiri::XML::Node.new(ns == 'xmlns' ? leaf_name : "#{ns}:#{leaf_name}", xml)
|
166
|
+
(previous = find_previous(xml, leaf_name, order)) ? previous.after(el) : xml.prepend_child(el)
|
167
|
+
el
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
# Finds previous sybling for a leaf_name in accordance with ordered list of child elements.
|
172
|
+
# Arguments:
|
173
|
+
# - xml: parent xml whose children are we checking
|
174
|
+
# - leaf_name: child element name that we want to find preceeding sybling for (without namespace)
|
175
|
+
# - order: list of child names in proper order
|
176
|
+
# Returns:
|
177
|
+
# - previous sybling element if found or nil
|
178
|
+
def find_previous(xml, leaf_name, order)
|
179
|
+
order.reduce(nil) do |res, curr_name|
|
180
|
+
break res if curr_name == leaf_name
|
181
|
+
xml.at(curr_name.include?(':') ? "./#{curr_name}" : "./xmlns:#{curr_name}") || res
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|