Class: Fog::Compute::VcloudDirector::Real

Inherits:
Object
  • Object
show all
Extended by:
Deprecation
Defined in:
lib/fog/vcloud_director/compute.rb,
lib/fog/vcloud_director/requests/compute/get_vm.rb,
lib/fog/vcloud_director/requests/compute/put_vm.rb,
lib/fog/vcloud_director/requests/compute/get_vdc.rb,
lib/fog/vcloud_director/requests/compute/get_vms.rb,
lib/fog/vcloud_director/requests/compute/put_cpu.rb,
lib/fog/vcloud_director/requests/compute/get_disk.rb,
lib/fog/vcloud_director/requests/compute/get_href.rb,
lib/fog/vcloud_director/requests/compute/get_task.rb,
lib/fog/vcloud_director/requests/compute/get_vapp.rb,
lib/fog/vcloud_director/requests/compute/get_media.rb,
lib/fog/vcloud_director/requests/compute/put_disks.rb,
lib/fog/vcloud_director/requests/compute/get_entity.rb,
lib/fog/vcloud_director/requests/compute/get_vcloud.rb,
lib/fog/vcloud_director/requests/compute/put_memory.rb,
lib/fog/vcloud_director/requests/compute/delete_disk.rb,
lib/fog/vcloud_director/requests/compute/delete_vapp.rb,
lib/fog/vcloud_director/requests/compute/get_catalog.rb,
lib/fog/vcloud_director/requests/compute/get_network.rb,
lib/fog/vcloud_director/requests/compute/get_request.rb,
lib/fog/vcloud_director/requests/compute/delete_media.rb,
lib/fog/vcloud_director/requests/compute/get_metadata.rb,
lib/fog/vcloud_director/requests/compute/get_vm_disks.rb,
lib/fog/vcloud_director/requests/compute/delete_logout.rb,
lib/fog/vcloud_director/requests/compute/get_shadow_vm.rb,
lib/fog/vcloud_director/requests/compute/get_task_list.rb,
lib/fog/vcloud_director/requests/compute/get_thumbnail.rb,
lib/fog/vcloud_director/requests/compute/delete_network.rb,
lib/fog/vcloud_director/requests/compute/get_disk_owner.rb,
lib/fog/vcloud_director/requests/compute/get_vapp_owner.rb,
lib/fog/vcloud_director/requests/compute/get_vm_network.rb,
lib/fog/vcloud_director/requests/compute/get_media_owner.rb,
lib/fog/vcloud_director/requests/compute/post_clone_vapp.rb,
lib/fog/vcloud_director/requests/compute/post_reset_vapp.rb,
lib/fog/vcloud_director/requests/compute/delete_shadow_vm.rb,
lib/fog/vcloud_director/requests/compute/get_catalog_item.rb,
lib/fog/vcloud_director/requests/compute/get_edge_gateway.rb,
lib/fog/vcloud_director/requests/compute/get_org_settings.rb,
lib/fog/vcloud_director/requests/compute/get_organization.rb,
lib/fog/vcloud_director/requests/compute/get_vdc_metadata.rb,
lib/fog/vcloud_director/requests/compute/post_attach_disk.rb,
lib/fog/vcloud_director/requests/compute/post_cancel_task.rb,
lib/fog/vcloud_director/requests/compute/post_clone_media.rb,
lib/fog/vcloud_director/requests/compute/post_deploy_vapp.rb,
lib/fog/vcloud_director/requests/compute/post_detach_disk.rb,
lib/fog/vcloud_director/requests/compute/post_reboot_vapp.rb,
lib/fog/vcloud_director/requests/compute/post_upload_disk.rb,
lib/fog/vcloud_director/requests/compute/get_cpu_rasd_item.rb,
lib/fog/vcloud_director/requests/compute/get_disk_metadata.rb,
lib/fog/vcloud_director/requests/compute/get_execute_query.rb,
lib/fog/vcloud_director/requests/compute/get_organizations.rb,
lib/fog/vcloud_director/requests/compute/get_vapp_metadata.rb,
lib/fog/vcloud_director/requests/compute/get_vapp_template.rb,
lib/fog/vcloud_director/requests/compute/post_capture_vapp.rb,
lib/fog/vcloud_director/requests/compute/post_eject_cd_rom.rb,
lib/fog/vcloud_director/requests/compute/post_suspend_vapp.rb,
lib/fog/vcloud_director/requests/compute/post_upload_media.rb,
lib/fog/vcloud_director/requests/compute/get_media_metadata.rb,
lib/fog/vcloud_director/requests/compute/post_insert_cd_rom.rb,
lib/fog/vcloud_director/requests/compute/post_login_session.rb,
lib/fog/vcloud_director/requests/compute/post_power_on_vapp.rb,
lib/fog/vcloud_director/requests/compute/post_shutdown_vapp.rb,
lib/fog/vcloud_director/requests/compute/post_undeploy_vapp.rb,
lib/fog/vcloud_director/requests/compute/put_metadata_value.rb,
lib/fog/vcloud_director/requests/compute/delete_catalog_item.rb,
lib/fog/vcloud_director/requests/compute/get_current_session.rb,
lib/fog/vcloud_director/requests/compute/get_startup_section.rb,
lib/fog/vcloud_director/requests/compute/get_vdcs_from_query.rb,
lib/fog/vcloud_director/requests/compute/get_vm_capabilities.rb,
lib/fog/vcloud_director/requests/compute/get_vms_by_metadata.rb,
lib/fog/vcloud_director/requests/compute/post_acquire_ticket.rb,
lib/fog/vcloud_director/requests/compute/post_power_off_vapp.rb,
lib/fog/vcloud_director/requests/compute/put_vm_capabilities.rb,
lib/fog/vcloud_director/requests/compute/delete_vapp_template.rb,
lib/fog/vcloud_director/requests/compute/get_catalog_metadata.rb,
lib/fog/vcloud_director/requests/compute/get_disks_from_query.rb,
lib/fog/vcloud_director/requests/compute/get_memory_rasd_item.rb,
lib/fog/vcloud_director/requests/compute/get_network_metadata.rb,
lib/fog/vcloud_director/requests/compute/get_org_vdc_gateways.rb,
lib/fog/vcloud_director/requests/compute/get_snapshot_section.rb,
lib/fog/vcloud_director/requests/compute/get_users_from_query.rb,
lib/fog/vcloud_director/requests/compute/get_vm_customization.rb,
lib/fog/vcloud_director/requests/compute/post_revert_snapshot.rb,
lib/fog/vcloud_director/requests/compute/get_groups_from_query.rb,
lib/fog/vcloud_director/requests/compute/get_medias_from_query.rb,
lib/fog/vcloud_director/requests/compute/get_vdc_storage_class.rb,
lib/fog/vcloud_director/requests/compute/post_enable_nested_hv.rb,
lib/fog/vcloud_director/requests/compute/get_supported_versions.rb,
lib/fog/vcloud_director/requests/compute/post_disable_nested_hv.rb,
lib/fog/vcloud_director/requests/compute/get_catalogs_from_query.rb,
lib/fog/vcloud_director/requests/compute/get_vapp_ovf_descriptor.rb,
lib/fog/vcloud_director/requests/compute/get_vapp_template_owner.rb,
lib/fog/vcloud_director/requests/compute/get_vm_pending_question.rb,
lib/fog/vcloud_director/requests/compute/post_discard_vapp_state.rb,
lib/fog/vcloud_director/requests/compute/post_upgrade_hw_version.rb,
lib/fog/vcloud_director/requests/compute/get_network_section_vapp.rb,
lib/fog/vcloud_director/requests/compute/get_vms_disk_attached_to.rb,
lib/fog/vcloud_director/requests/compute/post_check_vm_compliance.rb,
lib/fog/vcloud_director/requests/compute/post_clone_vapp_template.rb,
lib/fog/vcloud_director/requests/compute/post_consolidate_vm_vapp.rb,
lib/fog/vcloud_director/requests/compute/get_catalog_item_metadata.rb,
lib/fog/vcloud_director/requests/compute/get_disks_rasd_items_list.rb,
lib/fog/vcloud_director/requests/compute/get_organization_metadata.rb,
lib/fog/vcloud_director/requests/compute/get_product_sections_vapp.rb,
lib/fog/vcloud_director/requests/compute/get_vm_compliance_results.rb,
lib/fog/vcloud_director/requests/compute/instantiate_vapp_template.rb,
lib/fog/vcloud_director/requests/compute/post_install_vmware_tools.rb,
lib/fog/vcloud_director/requests/compute/post_remove_all_snapshots.rb,
lib/fog/vcloud_director/requests/compute/post_update_disk_metadata.rb,
lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb,
lib/fog/vcloud_director/requests/compute/post_upload_vapp_template.rb,
lib/fog/vcloud_director/requests/compute/get_allocated_ip_addresses.rb,
lib/fog/vcloud_director/requests/compute/get_supported_systems_info.rb,
lib/fog/vcloud_director/requests/compute/get_vapp_template_metadata.rb,
lib/fog/vcloud_director/requests/compute/post_exit_maintenance_mode.rb,
lib/fog/vcloud_director/requests/compute/post_update_media_metadata.rb,
lib/fog/vcloud_director/requests/compute/get_serial_ports_items_list.rb,
lib/fog/vcloud_director/requests/compute/get_vms_in_lease_from_query.rb,
lib/fog/vcloud_director/requests/compute/post_create_org_vdc_network.rb,
lib/fog/vcloud_director/requests/compute/post_enter_maintenance_mode.rb,
lib/fog/vcloud_director/requests/compute/get_network_cards_items_list.rb,
lib/fog/vcloud_director/requests/compute/get_operating_system_section.rb,
lib/fog/vcloud_director/requests/compute/get_organizations_from_query.rb,
lib/fog/vcloud_director/requests/compute/get_virtual_hardware_section.rb,
lib/fog/vcloud_director/requests/compute/get_runtime_info_section_type.rb,
lib/fog/vcloud_director/requests/compute/get_vapp_templates_from_query.rb,
lib/fog/vcloud_director/requests/compute/get_vapps_in_lease_from_query.rb,
lib/fog/vcloud_director/requests/compute/put_vapp_name_and_description.rb,
lib/fog/vcloud_director/requests/compute/get_control_access_params_vapp.rb,
lib/fog/vcloud_director/requests/compute/get_vdc_metadata_item_metadata.rb,
lib/fog/vcloud_director/requests/compute/get_vdc_storage_class_metadata.rb,
lib/fog/vcloud_director/requests/compute/post_instantiate_vapp_template.rb,
lib/fog/vcloud_director/requests/compute/get_disk_metadata_item_metadata.rb,
lib/fog/vcloud_director/requests/compute/get_lease_settings_section_vapp.rb,
lib/fog/vcloud_director/requests/compute/get_network_config_section_vapp.rb,
lib/fog/vcloud_director/requests/compute/get_vapp_metadata_item_metadata.rb,
lib/fog/vcloud_director/requests/compute/post_answer_vm_pending_question.rb,
lib/fog/vcloud_director/requests/compute/put_disk_metadata_item_metadata.rb,
lib/fog/vcloud_director/requests/compute/put_vapp_metadata_item_metadata.rb,
lib/fog/vcloud_director/requests/compute/get_media_drives_rasd_items_list.rb,
lib/fog/vcloud_director/requests/compute/get_media_metadata_item_metadata.rb,
lib/fog/vcloud_director/requests/compute/get_vapp_template_ovf_descriptor.rb,
lib/fog/vcloud_director/requests/compute/put_media_metadata_item_metadata.rb,
lib/fog/vcloud_director/requests/compute/get_control_access_params_catalog.rb,
lib/fog/vcloud_director/requests/compute/get_network_section_vapp_template.rb,
lib/fog/vcloud_director/requests/compute/post_consolidate_vm_vapp_template.rb,
lib/fog/vcloud_director/requests/compute/post_update_catalog_item_metadata.rb,
lib/fog/vcloud_director/requests/compute/delete_disk_metadata_item_metadata.rb,
lib/fog/vcloud_director/requests/compute/delete_vapp_metadata_item_metadata.rb,
lib/fog/vcloud_director/requests/compute/get_catalog_metadata_item_metadata.rb,
lib/fog/vcloud_director/requests/compute/get_network_metadata_item_metadata.rb,
lib/fog/vcloud_director/requests/compute/get_product_sections_vapp_template.rb,
lib/fog/vcloud_director/requests/compute/post_enable_vapp_template_download.rb,
lib/fog/vcloud_director/requests/compute/post_update_vapp_template_metadata.rb,
lib/fog/vcloud_director/requests/compute/delete_media_metadata_item_metadata.rb,
lib/fog/vcloud_director/requests/compute/post_disable_vapp_template_download.rb,
lib/fog/vcloud_director/requests/compute/post_configure_edge_gateway_services.rb,
lib/fog/vcloud_director/requests/compute/put_guest_customization_section_vapp.rb,
lib/fog/vcloud_director/requests/compute/get_catalog_item_metadata_item_metadata.rb,
lib/fog/vcloud_director/requests/compute/get_organization_metadata_item_metadata.rb,
lib/fog/vcloud_director/requests/compute/put_catalog_item_metadata_item_metadata.rb,
lib/fog/vcloud_director/requests/compute/get_lease_settings_section_vapp_template.rb,
lib/fog/vcloud_director/requests/compute/get_network_config_section_vapp_template.rb,
lib/fog/vcloud_director/requests/compute/get_vapp_template_metadata_item_metadata.rb,
lib/fog/vcloud_director/requests/compute/put_vapp_template_metadata_item_metadata.rb,
lib/fog/vcloud_director/requests/compute/delete_catalog_item_metadata_item_metadata.rb,
lib/fog/vcloud_director/requests/compute/get_network_connection_system_section_vapp.rb,
lib/fog/vcloud_director/requests/compute/put_network_connection_system_section_vapp.rb,
lib/fog/vcloud_director/requests/compute/delete_vapp_template_metadata_item_metadata.rb,
lib/fog/vcloud_director/requests/compute/get_guest_customization_system_section_vapp.rb,
lib/fog/vcloud_director/requests/compute/get_vdc_storage_class_metadata_item_metadata.rb,
lib/fog/vcloud_director/requests/compute/get_vapp_template_customization_system_section.rb,
lib/fog/vcloud_director/requests/compute/get_network_connection_system_section_vapp_template.rb,
lib/fog/vcloud_director/requests/compute/get_guest_customization_system_section_vapp_template.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Deprecation

deprecate, self_deprecate

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real.



329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
# File 'lib/fog/vcloud_director/compute.rb', line 329

def initialize(options={})
  @vcloud_director_password = options[:vcloud_director_password]
  @vcloud_director_username = options[:vcloud_director_username]
  @connection_options = options[:connection_options] || {}
  @host       = options[:vcloud_director_host]
  @path       = options[:path]        || Fog::Compute::VcloudDirector::Defaults::PATH
  @persistent = options[:persistent]  || false
  @port       = options[:port]        || Fog::Compute::VcloudDirector::Defaults::PORT
  @scheme     = options[:scheme]      || Fog::Compute::VcloudDirector::Defaults::SCHEME
  @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
  @end_point = "#{@scheme}://#{@host}#{@path}/"
  @api_version = options[:vcloud_director_api_version] || Fog::Compute::VcloudDirector::Defaults::API_VERSION
  @show_progress = options[:vcloud_director_show_progress]
  @show_progress = $stdin.tty? if @show_progress.nil?
end

Instance Attribute Details

#api_versionObject (readonly)

Returns the value of attribute api_version.



326
327
328
# File 'lib/fog/vcloud_director/compute.rb', line 326

def api_version
  @api_version
end

#end_pointObject (readonly)

Returns the value of attribute end_point.



326
327
328
# File 'lib/fog/vcloud_director/compute.rb', line 326

def end_point
  @end_point
end

#show_progressObject (readonly) Also known as: show_progress?

Returns the value of attribute show_progress.



326
327
328
# File 'lib/fog/vcloud_director/compute.rb', line 326

def show_progress
  @show_progress
end

Instance Method Details

#add_id_from_href!(data = {}) ⇒ Object



425
426
427
# File 'lib/fog/vcloud_director/compute.rb', line 425

def add_id_from_href!(data={})
  data[:id] = data[:href].split('/').last
end

#delete_catalog_item(id) ⇒ Excon::Response

Delete a catalog item.

Parameters:

  • id (String)

    Object identifier of the catalog item.

Returns:

  • (Excon::Response)

See Also:

Since:

  • vCloud API version 0.9



12
13
14
15
16
17
18
# File 'lib/fog/vcloud_director/requests/compute/delete_catalog_item.rb', line 12

def delete_catalog_item(id)
  request(
    :expects => 204,
    :method  => 'DELETE',
    :path    => "catalogItem/#{id}"
  )
end

#delete_catalog_item_metadata_item_metadata(id, key) ⇒ Excon::Response

Delete the specified key and its value from catalog item metadata.

Parameters:

  • id (String)

    Object identifier of the catalog item.

  • key (String)

    Key of the metadata item.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/delete_catalog_item_metadata_item_metadata.rb', line 14

def (id, key)
  request(
    :expects => 202,
    :method  => 'DELETE',
    :parser  => Fog::ToHashDocument.new,
    :path    => "catalogItem/#{id}/metadata/#{URI.escape(key)}"
  )
end

#delete_disk(id) ⇒ Excon::Response

Delete a disk.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the disk.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 5.1



16
17
18
19
20
21
22
23
# File 'lib/fog/vcloud_director/requests/compute/delete_disk.rb', line 16

def delete_disk(id)
  request(
    :expects => 202,
    :method  => 'DELETE',
    :parser  => Fog::ToHashDocument.new,
    :path    => "disk/#{id}"
  )
end

#delete_disk_metadata_item_metadata(id, key) ⇒ Excon::Response

Delete the specified key and its value from disk metadata.

Parameters:

  • id (String)

    Object identifier of the disk.

  • key (String)

    Key of the metadata item.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 5.1



14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/delete_disk_metadata_item_metadata.rb', line 14

def (id, key)
  request(
    :expects => 202,
    :method  => 'DELETE',
    :parser  => Fog::ToHashDocument.new,
    :path    => "disk/#{id}/metadata/#{URI.escape(key)}"
  )
end

#delete_logoutExcon::Response



8
9
10
11
12
13
14
# File 'lib/fog/vcloud_director/requests/compute/delete_logout.rb', line 8

def delete_logout
  request(
    :expects => 204,
    :method  => 'DELETE',
    :path    => 'session'
  )
end

#delete_media(id) ⇒ Excon::Response

Delete a media object.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the media object.

Returns:

  • (Excon::Response)
    • body<~Hash>:

      • :href<~String> - The URI of the entity.

      • :type<~String> - The MIME type of the entity.

      • :id<~String> - The entity identifier, expressed in URN format. The value of this attribute uniquely identifies the entity, persists for the life of the entity, and is never reused.

      • :operationKey<~String> - Optional unique identifier to support idempotent semantics for create and delete operations.

      • :name<~String> - The name of the entity.

      • :cancelRequested<~String> - Whether user has requested this processing to be canceled.

      • :endTime<~String> - The date and time that processing of the task was completed. May not be present if the task is still being executed.

      • :expiryTime<~String> - The date and time at which the task resource will be destroyed and no longer available for retrieval. May not be present if the task has not been executed or is still being executed.

      • :operation<~String> - A message describing the operation that is tracked by this task.

      • :operationName<~String> - The short name of the operation that is tracked by this task.

      • :serviceNamespace<~String> - Identifier of the service that created the task.

      • :startTime<~String> - The date and time the system started executing the task. May not be present if the task has not been executed yet.

      • :status<~String> - The execution status of the task.

      • :Link<~Array<Hash>>:

      • :Description<~String> - Optional description.

      • :Owner<~Hash> - Reference to the owner of the task. This is typically the object that the task is creating or updating.

      • :href<~String> - Contains the URI to the entity.

      • :name<~String> - Contains the name of the entity.

      • :type<~String> - Contains the type of the entity.

      • :Error<~Hash> - Represents error information from a failed task.

        • :majorErrorCode<~String> - The class of the error. Matches the HTTP status code.

        • :message<~String> - An one line, human-readable message describing the error that occurred.

        • :minorErrorCode<~String> - Resource-specific error code.

        • :stackTrace<~String> - The stack trace of the exception.

        • :vendorSpecificErrorCode<~String> - A vendor- or implementation-specific error code that can reference specific modules or source lines for diagnostic purposes.

        • :User<~Hash> - The user who started the task.

          • :href<~String> - Contains the URI to the entity.

          • :name<~String> - Contains the name of the entity.

          • :type<~String> - Contains the type of the entity.

        • :Organization<~Hash> - The organization to which the :User belongs.

          • :href<~String> - Contains the URI to the entity.

          • :name<~String> - Contains the name of the entity.

          • :type<~String> - Contains the type of the entity.

        • :Progress<~String> - Read-only indicator of task progress as an approximate percentage between 0 and 100. Not available for all tasks.

        • :Params

        • :Details<~String> - Detailed message about the task. Also contained by the :Owner entity when task status is preRunning.

Raises:

See Also:

Since:

  • vCloud API version 0.9



79
80
81
82
83
84
85
86
# File 'lib/fog/vcloud_director/requests/compute/delete_media.rb', line 79

def delete_media(id)
  request(
    :expects => 202,
    :method  => 'DELETE',
    :parser  => Fog::ToHashDocument.new,
    :path    => "media/#{id}"
  )
end

#delete_media_metadata_item_metadata(id, key) ⇒ Excon::Response

Delete the specified key and its value from media object metadata.

Parameters:

  • id (String)

    Object identifier of the media object.

  • key (String)

    Key of the metadata item.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/delete_media_metadata_item_metadata.rb', line 14

def (id, key)
  request(
    :expects => 202,
    :method  => 'DELETE',
    :parser  => Fog::ToHashDocument.new,
    :path    => "media/#{id}/metadata/#{URI.escape(key)}"
  )
end

#delete_network(id) ⇒ Excon::Response

Delete an OrgVdcNetwork

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the OrgVdcNetwork.

Returns:

  • (Excon::Response)
    • body<~Hash>:

Raises:

See Also:

Since:

  • vCloud API version 0.9



18
19
20
21
22
23
24
25
# File 'lib/fog/vcloud_director/requests/compute/delete_network.rb', line 18

def delete_network(id)
  request(
    :expects => 202,
    :method  => 'DELETE',
    :parser  => Fog::ToHashDocument.new,
    :path    => "admin/network/#{id}"
  )
end

#delete_shadow_vm(id) ⇒ Excon::Response

Deprecated.

Since vCloud API version 5.1 this operation may be removed in a future release.

Deletes shadow VM.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the vApp.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



19
20
21
22
23
24
25
26
# File 'lib/fog/vcloud_director/requests/compute/delete_shadow_vm.rb', line 19

def delete_shadow_vm(id)
  request(
    :expects => 202,
    :method  => 'DELETE',
    :parser  => Fog::ToHashDocument.new,
    :path    => "shadowVm/#{id}"
  )
end

#delete_vapp(id) ⇒ Excon::Response

Delete a vApp or VM.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the vApp.

Returns:

  • (Excon::Response)
    • body<~Hash>:

Raises:

See Also:

Since:

  • vCloud API version 0.9



18
19
20
21
22
23
24
25
# File 'lib/fog/vcloud_director/requests/compute/delete_vapp.rb', line 18

def delete_vapp(id)
  request(
    :expects => 202,
    :method  => 'DELETE',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}"
  )
end

#delete_vapp_metadata_item_metadata(id, key) ⇒ Excon::Response

Delete the specified key and its value from vApp or VM metadata.

Parameters:

  • id (String)

    Object identifier of the vApp or VM.

  • key (String)

    Key of the metadata item.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



19
20
21
22
23
24
25
26
# File 'lib/fog/vcloud_director/requests/compute/delete_vapp_metadata_item_metadata.rb', line 19

def (id, key)
  request(
    :expects => 202,
    :method  => 'DELETE',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/metadata/#{URI.escape(key)}"
  )
end

#delete_vapp_template(id) ⇒ Excon::Response

Delete a vApp template.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the vApp template.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



16
17
18
19
20
21
22
23
# File 'lib/fog/vcloud_director/requests/compute/delete_vapp_template.rb', line 16

def delete_vapp_template(id)
  request(
    :expects => 202,
    :method  => 'DELETE',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vAppTemplate/#{id}"
  )
end

#delete_vapp_template_metadata_item_metadata(id, key) ⇒ Excon::Response

Delete the specified key and its value from vApp template or VM metadata.

Parameters:

  • id (String)

    Object identifier of the vApp template or VM.

  • key (String)

    Key of the metadata item.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



15
16
17
18
19
20
21
22
# File 'lib/fog/vcloud_director/requests/compute/delete_vapp_template_metadata_item_metadata.rb', line 15

def (id, key)
  request(
    :expects => 202,
    :method  => 'DELETE',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vAppTemplate/#{id}/metadata/#{URI.escape(key)}"
  )
end

#do_request(params) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
# File 'lib/fog/vcloud_director/compute.rb', line 375

def do_request(params)
  headers = {
    'Accept' => "application/*+xml;version=#{@api_version}",
    'x-vcloud-authorization' => vcloud_token
  }
  if params[:path]
    if params[:override_path] == true
      path = params[:path]
    else
      path = "#{@path}/#{params[:path]}"
    end
  else
    path = "#{@path}"
  end
  @connection.request({
    :body       => params[:body],
    :expects    => params[:expects],
    :headers    => headers.merge!(params[:headers] || {}),
    :idempotent => params[:idempotent],
    :method     => params[:method],
    :parser     => params[:parser],
    :path       => path,
    :query      => params[:query]
  })
rescue Excon::Errors::HTTPStatusError => error
  raise case error
  when Excon::Errors::BadRequest   then BadRequest.slurp(error);
  when Excon::Errors::Unauthorized then Unauthorized.slurp(error);
  when Excon::Errors::Forbidden    then Forbidden.slurp(error);
  when Excon::Errors::Conflict     then Conflict.slurp(error);
  else                                  ServiceError.slurp(error)
  end
end

#ensure_list!(hash, key1, key2 = nil) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Compensate for Fog::ToHashDocument shortcomings.

Parameters:

Returns:



435
436
437
438
439
440
441
442
443
444
445
# File 'lib/fog/vcloud_director/compute.rb', line 435

def ensure_list!(hash, key1, key2=nil)
  if key2.nil?
    hash[key1] ||= []
    hash[key1] = [hash[key1]] if hash[key1].is_a?(Hash)
  else
    hash[key1] ||= {key2 => []}
    hash[key1] = {key2 => []} if hash[key1].empty?
    hash[key1][key2] = [hash[key1][key2]] if hash[key1][key2].is_a?(Hash)
  end
  hash
end

#get_allocated_ip_addresses(id) ⇒ Excon::Response

Retrieve a list of IP addresses allocated to the network.

Parameters:

  • id (String)

    Object identifier of the network.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 5.1



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_allocated_ip_addresses.rb', line 13

def get_allocated_ip_addresses(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "network/#{id}/allocatedAddresses"
  )
end

#get_catalog(id) ⇒ Excon::Response

Retrieve a catalog.

Parameters:

  • id (String)

    Object identifier of the catalog.

Returns:

  • (Excon::Response)
    • hash<~Hash>:

Raises:

See Also:

Since:

  • vCloud API version 0.9



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/vcloud_director/requests/compute/get_catalog.rb', line 15

def get_catalog(id)
  response = request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "catalog/#{id}"
  )
  ensure_list! response.body, :CatalogItems, :CatalogItem
  response
end

#get_catalog_item(id) ⇒ Excon::Response

Retrieve a catalog item.

Parameters:

  • id (String)

    Object identifier of the catalog item.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_catalog_item.rb', line 13

def get_catalog_item(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "catalogItem/#{id}"
  )
end

#get_catalog_item_metadata(id) ⇒ Excon::Response

Retrieve all metadata associated with a catalog item.

Parameters:

  • id (String)

    Object identifier of the catalog item.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_catalog_item_metadata.rb', line 13

def (id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "catalogItem/#{id}/metadata"
  )
end

#get_catalog_item_metadata_item_metadata(id, key) ⇒ Excon::Response

Retrieve the value of the specified key from catalog item metadata.

Parameters:

  • id (String)

    Object identifier of the catalog item.

  • key (String)

    Key of the metadata.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



14
15
16
17
18
19
20
21
22
# File 'lib/fog/vcloud_director/requests/compute/get_catalog_item_metadata_item_metadata.rb', line 14

def (id, key)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "catalogItem/#{id}/metadata/#{URI.escape(key)})"
  )
end

#get_catalog_metadata(id) ⇒ Excon::Response

Retrieve all catalog metadata.

Parameters:

  • id (String)

    Object identifier of the catalog.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_catalog_metadata.rb', line 13

def (id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "catalog/#{id}/metadata"
  )
end

#get_catalog_metadata_item_metadata(id, key) ⇒ Excon::Response

Retrieve the value of the specified key from catalog metadata.

Parameters:

  • id (String)

    Object identifier of the catalog.

  • key (String)

    Key of the metadata.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



14
15
16
17
18
19
20
21
22
# File 'lib/fog/vcloud_director/requests/compute/get_catalog_metadata_item_metadata.rb', line 14

def (id, key)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "catalog/#{id}/metadata/#{URI.escape(key)})"
  )
end

#get_catalogs_from_query(options = {}) ⇒ Excon::Response

Retrieves a list of Catalogs by using REST API general QueryHandler.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :sortAsc (String) — default: Sorted by database ID

    Sort results by attribute-name in ascending order. attribute-name cannot include metadata.

  • :sortDesc (String) — default: Sorted by database ID

    Sort results by attribute-name in descending order. attribute-name cannot include metadata.

  • :page (Integer) — default: 1

    If the query results span multiple pages, return this page.

  • :pageSize (Integer) — default: 25

    Number of results per page, to a maximum of 128.

  • :format (String) — default: records

    One of the following types:

    • references Returns a reference to each object, including its :name, :type, and :href attributes.

    • records Returns all database records for each object, with each record as an attribute.

    • idrecords Identical to the records format, except that object references are returned in :id format rather than :href format.

  • :fields (Array<String>) — default: all static attribute names

    List of attribute names or metadata key names to return.

  • :offset (Integer) — default: 0

    Integer value specifying the first record to return. Record numbers < offset are not returned.

  • :filter (String) — default: none

    Filter expression.

Returns:

  • (Excon::Response)
    • hash<~Hash>:

      • :href<~String> - The URI of the entity.

      • :type<~String> - The MIME type of the entity.

      • :name<~String> - Query name that generated this result set.

      • :page<~String> - Page of the result set that this container holds. The first page is page number 1.

      • :pageSize<~String> - Page size, as a number of records or references.

      • :total<~String> - Total number of records or references in the container.

      • :Link<~Array<Hash>>:

        • :href<~String> - Contains the URI to the entity.

        • :type<~String> - Contains the type of the entity.

        • :rel<~String> - Defines the relationship of the link to the object that contains it.

      • :CatalogRecord<~Array<Hash>>:

        • TODO

      • :firstPage<~Integer> - First page in the result set.

      • :previousPage<~Integer> - Previous page in the result set.

      • :nextPage<~Integer> - Next page in the result set.

      • :lastPage<~Integer> - Last page in the result set.

See Also:

Since:

  • vCloud API version 1.5



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/fog/vcloud_director/requests/compute/get_catalogs_from_query.rb', line 56

def get_catalogs_from_query(options={})
  query = []
  query << "sortAsc=#{options[:sortAsc]}" if options[:sortAsc]
  query << "sortDesc=#{options[:sortDesc]}" if options[:sortDesc]
  query << "page=#{options[:page]}" if options[:page]
  query << "pageSize=#{options[:pageSize]}" if options[:pageSize]
  query << "format=#{options[:format]}" if options[:format]
  query << "fields=#{Array(options[:fields]).join(',')}" if options[:fields]
  query << "offset=#{options[:offset]}" if options[:offset]
  query << "filter=#{options[:filter]}" if options[:filter]

  response = request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => 'catalogs/query',
    :query      => query.map {|q| URI.escape(q)}.join('&')
  )
  ensure_list! response.body, :Link
  ensure_list! response.body,
    response.body[:type] == 'application/vnd.vmware.vcloud.query.references+xml' ?
      :CatalogReference : :CatalogRecord

  %w[firstPage previousPage nextPage lastPage].each do |rel|
    if link = response.body[:Link].detect {|l| l[:rel] == rel}
      href = Nokogiri::XML.fragment(link[:href])
      query = CGI.parse(URI.parse(href.text).query)
      response.body[rel.to_sym] = query['page'].first.to_i
      response.body[:pageSize] ||= query['pageSize'].first.to_i
    end
  end

  response
end

#get_control_access_params_catalog(id, catalog_id) ⇒ Excon::Response

Retrieve access control information for a catalog.

Parameters:

  • id (String)

    Object identifier of the organization.

  • catalog_id (String)

    Object identifier of the catalog.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API 0.9



14
15
16
17
18
19
20
21
22
# File 'lib/fog/vcloud_director/requests/compute/get_control_access_params_catalog.rb', line 14

def get_control_access_params_catalog(id, catalog_id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "org/#{id}/catalog/#{catalog_id}/controlAccess"
  )
end

#get_control_access_params_vapp(id) ⇒ Excon::Response

Retrieve access control information for a vApp.

Parameters:

  • id (String)

    Object identifier of the vApp.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API 0.9



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_control_access_params_vapp.rb', line 13

def get_control_access_params_vapp(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vApp/#{id}/controlAccess"
  )
end

#get_cpu_rasd_item(id) ⇒ Excon::Response

Retrieve the RASD item that specifies CPU properties of a VM.

Parameters:

  • id (String)

    Object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



16
17
18
19
20
21
22
23
24
# File 'lib/fog/vcloud_director/requests/compute/get_cpu_rasd_item.rb', line 16

def get_cpu_rasd_item(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vApp/#{id}/virtualHardwareSection/cpu"
  )
end

#get_current_sessionExcon::Response

Retrieve a representation of the current session.

A Session object contains one or more URLs from which you can begin browsing, as well as links to the query service and entity resolver. The list of URLs in the Session object is based on the role and privileges of the authenticated user.

A Session object expires after a configurable interval of client inactivity.

Returns:

  • (Excon::Response)
    • body<~Hash>:

      • :href<~String> - The URI of the entity.

      • :type<~String> - The MIME type of the entity.

      • :org<~String> - The name of the user’s organization.

      • :user<~String> - The name of the user that owns the session

      • :Link<~Array<Hash>]:

        • :href<~String> - Contains the URI to the linked entity.

        • :name<~String> - Contains the name of the linked entity.

        • :type<~String> - Contains the type of the linked entity.

        • :rel<~String> - Defines the relationship of the link to the object that contains it.

See Also:

Since:

  • vCloud API version 1.5



30
31
32
33
34
35
36
37
38
# File 'lib/fog/vcloud_director/requests/compute/get_current_session.rb', line 30

def get_current_session
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => 'session'
  )
end

#get_disk(id) ⇒ Excon::Response

Retrieve a disk.

Parameters:

  • id (String)

    Object identifier of the disk.

Returns:

  • (Excon::Response)
    • body<~Hash>:

      • :href<~String> - The URI of the disk.

      • :type<~String> - The MIME type of the disk.

      • :id<~String> - The disk identifier, expressed in URN format.

      • :name<~String> - The name of the disk.

      • :status<~String> - Creation status of the disk.

      • :busSubType<~String> - Disk bus sub type.

      • :busType<~String> - Disk bus type.

      • :size<~String> - Size of the disk.

      • :Description<~String> - Optional description.

      • :Tasks<~Hash> - A list of queued, running, or recently completed tasks associated with this disk.

      • :StorageProfile<~Hash> - Storage profile of the disk.

      • :Owner<~Hash> - Disk owner.

Raises:

See Also:

Since:

  • vCloud API version 5.1



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/fog/vcloud_director/requests/compute/get_disk.rb', line 28

def get_disk(id)
  response = request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "disk/#{id}"
  )
  ensure_list! response.body, :Link
  ensure_list! response.body, :Tasks, :Task
  ensure_list! response.body, :Files, :File
  response
end

#get_disk_metadata(id) ⇒ Excon::Response

Retrieve metadata associated with the disk.

Parameters:

  • id (String)

    Object identifier of the disk.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 5.1



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_disk_metadata.rb', line 13

def (id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "disk/#{id}/metadata"
  )
end

#get_disk_metadata_item_metadata(id, key) ⇒ Excon::Response

Retrieve the value of the specified key from disk metadata.

Parameters:

  • id (String)

    Object identifier of the disk.

  • key (String)

    Key of the metadata.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 5.1



14
15
16
17
18
19
20
21
22
# File 'lib/fog/vcloud_director/requests/compute/get_disk_metadata_item_metadata.rb', line 14

def (id, key)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "disk/#{id}/metadata/#{URI.escape(key)})"
  )
end

#get_disk_owner(id) ⇒ Excon::Response

Retrieve the owner of a disk.

Parameters:

  • id (String)

    Object identifier of the disk.

Returns:

  • (Excon::Response)
    • body<~Hash>:

      • :href<~String> - The URI of the disk.

      • :type<~String> - The MIME type of the disk.

      • :Link<~Hash>:

        • :href<~String> -

        • :type<~String> -

        • :rel<~String> -

      • :User<~Hash> - Reference to the user who is the owner of this disk.

        • :href<~String> - The URI of the user.

        • :name<~String> - The name of the user.

        • :type<~String> - The MIME type of the user.

Raises:

See Also:

Since:

  • vCloud API version 5.1



26
27
28
29
30
31
32
33
34
# File 'lib/fog/vcloud_director/requests/compute/get_disk_owner.rb', line 26

def get_disk_owner(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "disk/#{id}/owner"
  )
end

#get_disks_from_query(options = {}) ⇒ Excon::Response

Retrieves a disk list by using REST API general QueryHandler.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :sortAsc (String) — default: Sorted by database ID

    Sort results by attribute-name in ascending order. attribute-name cannot include metadata.

  • :sortDesc (String) — default: Sorted by database ID

    Sort results by attribute-name in descending order. attribute-name cannot include metadata.

  • :page (Integer) — default: 1

    If the query results span multiple pages, return this page.

  • :pageSize (Integer) — default: 25

    Number of results per page, to a maximum of 128.

  • :format (String) — default: records

    One of the following types:

    • references Returns a reference to each object, including its :name, :type, and :href attributes.

    • records Returns all database records for each object, with each record as an attribute.

    • idrecords Identical to the records format, except that object references are returned in :id format rather than :href format.

  • :fields (Array<String>) — default: all static attribute names

    List of attribute names or metadata key names to return.

  • :offset (Integer) — default: 0

    Integer value specifying the first record to return. Record numbers < offset are not returned.

  • :filter (String) — default: none

    Filter expression.

Returns:

  • (Excon::Response)
    • hash<~Hash>:

      • :href<~String> - The URI of the entity.

      • :type<~String> - The MIME type of the entity.

      • :name<~String> - Query name that generated this result set.

      • :page<~String> - Page of the result set that this container holds. The first page is page number 1.

      • :pageSize<~String> - Page size, as a number of records or references.

      • :total<~String> - Total number of records or references in the container.

      • :Link<~Array<Hash>>:

        • :href<~String> - Contains the URI to the entity.

        • :type<~String> - Contains the type of the entity.

        • :rel<~String> - Defines the relationship of the link to the object that contains it.

      • :DiskRecord<~Array<Hash>>:

        • TODO

      • :firstPage<~Integer> - First page in the result set.

      • :previousPage<~Integer> - Previous page in the result set.

      • :nextPage<~Integer> - Next page in the result set.

      • :lastPage<~Integer> - Last page in the result set.

See Also:

Since:

  • vCloud API version 1.5



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/fog/vcloud_director/requests/compute/get_disks_from_query.rb', line 56

def get_disks_from_query(options={})
  query = []
  query << "sortAsc=#{options[:sortAsc]}" if options[:sortAsc]
  query << "sortDesc=#{options[:sortDesc]}" if options[:sortDesc]
  query << "page=#{options[:page]}" if options[:page]
  query << "pageSize=#{options[:pageSize]}" if options[:pageSize]
  query << "format=#{options[:format]}" if options[:format]
  query << "fields=#{Array(options[:fields]).join(',')}" if options[:fields]
  query << "offset=#{options[:offset]}" if options[:offset]
  query << "filter=#{options[:filter]}" if options[:filter]

  response = request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => 'disks/query',
    :query      => query.map {|q| URI.escape(q)}.join('&')
  )
  ensure_list! response.body, :Link
  ensure_list! response.body,
    response.body[:type] == 'application/vnd.vmware.vcloud.query.references+xml' ?
      :DiskReference : :DiskRecord

  %w[firstPage previousPage nextPage lastPage].each do |rel|
    if link = response.body[:Link].detect {|l| l[:rel] == rel}
      href = Nokogiri::XML.fragment(link[:href])
      query = CGI.parse(URI.parse(href.text).query)
      response.body[rel.to_sym] = query['page'].first.to_i
      response.body[:pageSize] ||= query['pageSize'].first.to_i
    end
  end

  response
end

#get_disks_rasd_items_list(id) ⇒ Excon::Response

Retrieve all RASD items that specify hard disk and hard disk controller properties of a VM.

Parameters:

  • id (String)

    Object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



14
15
16
17
18
19
20
21
22
# File 'lib/fog/vcloud_director/requests/compute/get_disks_rasd_items_list.rb', line 14

def get_disks_rasd_items_list(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vApp/#{id}/virtualHardwareSection/disks"
  )
end

#get_edge_gateway(id) ⇒ Excon::Response

Retrieve an edge gateway.

Parameters:

  • id (String)

    Object identifier of the edge gateway.

Returns:

  • (Excon::Response)
    • body<~Hash>:

Raises:

See Also:

Since:

  • vCloud API version 5.1



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fog/vcloud_director/requests/compute/get_edge_gateway.rb', line 15

def get_edge_gateway(id)
  response = request(
      :expects => 200,
      :idempotent => true,
      :method => 'GET',
      :parser => Fog::ToHashDocument.new,
      :path => "admin/edgeGateway/#{id}"
  )

  ensure_list! response.body[:Configuration], :GatewayInterfaces, :GatewayInterface

  edge_gateway_service_configuration = response.body[:Configuration][:EdgeGatewayServiceConfiguration]

  ensure_list! edge_gateway_service_configuration[:FirewallService], :FirewallRule if edge_gateway_service_configuration[:FirewallService]
  ensure_list! edge_gateway_service_configuration[:NatService], :NatRule if edge_gateway_service_configuration[:NatService]

  if edge_gateway_service_configuration[:LoadBalancerService]

    ensure_list! edge_gateway_service_configuration[:LoadBalancerService], :Pool
    edge_gateway_service_configuration[:LoadBalancerService][:Pool].each do |pool|
      ensure_list! pool, :ServicePort
      ensure_list! pool, :Member
      pool[:Member].each do |member|
        ensure_list! member, :ServicePort
      end
    end

    ensure_list! edge_gateway_service_configuration[:LoadBalancerService], :VirtualServer
    edge_gateway_service_configuration[:LoadBalancerService][:VirtualServer].each do |virtual_server|
      ensure_list! virtual_server, :ServiceProfile
    end

  end

  response
end

#get_entity(id) ⇒ Excon:Response

Redirects to the URL of an entity with the given VCD ID.

Parameters:

Returns:

  • (Excon:Response)
    • body<~Hash>:

      • :href<~String> - The URI of the entity.

      • :type<~String> - The MIME type of the entity.

      • :id<~String> - The entity identifier, expressed in URN format. The value of this attribute uniquely identifies the entity, persists for the life of the entity, and is never reused.

      • :name<~String> - The name of the entity.

      • :Link<~Array<Hash>]:

        • :href<~String> - Contains the URI to the linked entity.

        • :type<~String> - Contains the type of the linked entity.

        • :rel<~String> - Defines the relationship of the link to the object that contains it.

See Also:

Since:

  • vCloud API version 1.5



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/vcloud_director/requests/compute/get_entity.rb', line 24

def get_entity(id)
  response = request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "entity/#{id}"
  )
  ensure_list! response.body, :Link
  response
end

#get_execute_query(type = nil, options = {}) ⇒ Excon::Response

REST API General queries handler.

Parameters:

  • type (String) (defaults to: nil)

    The type of the query. Type names are case-sensitive. You can retrieve a summary list of all typed queries types accessible to the currently authenticated user by making a request with type=nil.

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :sortAsc (String) — default: Sorted by database ID

    Sort results by attribute-name in ascending order. attribute-name cannot include metadata.

  • :sortDesc (String) — default: Sorted by database ID

    Sort results by attribute-name in descending order. attribute-name cannot include metadata.

  • :page (Integer) — default: 1

    If the query results span multiple pages, return this page.

  • :pageSize (Integer) — default: 25

    Number of results per page, to a maximum of 128.

  • :format (String) — default: records

    One of the following types:

    • references Returns a reference to each object, including its :name, :type, and :href attributes.

    • records Returns all database records for each object, with each record as an attribute.

    • idrecords Identical to the records format, except that object references are returned in :id format rather than :href format.

  • :fields (Array<String>) — default: all static attribute names

    List of attribute names or metadata key names to return.

  • :offset (Integer) — default: 0

    Integer value specifying the first record to return. Record numbers < offset are not returned.

  • :filter (String) — default: none

    Filter expression.

Returns:

  • (Excon::Response)

    if type is specified.

    • hash<~Hash>:

      • :href<~String> - The URI of the entity.

      • :type<~String> - The MIME type of the entity.

      • :name<~String> - Query name that generated this result set.

      • :page<~String> - Page of the result set that this container holds. The first page is page number 1.

      • :pageSize<~String> - Page size, as a number of records or references.

      • :total<~String> - Total number of records or references in the container.

      • :Link<~Array<Hash>>:

        • :href<~String> - Contains the URI to the entity.

        • :type<~String> - Contains the type of the entity.

        • :rel<~String> - Defines the relationship of the link to the object that contains it.

      • :Record<~Array<Hash>> - The name and content of this item varies according to the type and format of the query.

      • :firstPage<~Integer> - First page in the result set.

      • :previousPage<~Integer> - Previous page in the result set.

      • :nextPage<~Integer> - Next page in the result set.

      • :lastPage<~Integer> - Last page in the result set.

  • (Excon::Response)

    if type is nil.

    • hash<~Hash>:

      • :href<~String> - The URI of the entity.

      • :type<~String> - The MIME type of the entity.

      • :Link<~Array<Hash>>:

        • :href<~String> - Contains the URI to the entity.

        • :name<~String> - Contains the name of the entity.

        • :type<~String> - Contains the type of the entity.

        • :rel<~String> - Defines the relationship of the link to the object that contains it.

See Also:

Since:

  • vCloud API version 1.5



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/fog/vcloud_director/requests/compute/get_execute_query.rb', line 70

def get_execute_query(type=nil, options={})
  if type.nil?
    response = request(
      :expects    => 200,
      :idempotent => true,
      :method     => 'GET',
      :parser     => Fog::ToHashDocument.new,
      :path       => 'query'
    )
  else
    query = ["type=#{type}"]
    query << "sortAsc=#{options[:sortAsc]}" if options[:sortAsc]
    query << "sortDesc=#{options[:sortDesc]}" if options[:sortDesc]
    query << "page=#{options[:page]}" if options[:page]
    query << "pageSize=#{options[:pageSize]}" if options[:pageSize]
    query << "format=#{options[:format]}" if options[:format]
    query << "fields=#{Array(options[:fields]).join(',')}" if options[:fields]
    query << "offset=#{options[:offset]}" if options[:offset]
    query << "filter=#{options[:filter]}" if options[:filter]

    response = request(
      :expects    => 200,
      :idempotent => true,
      :method     => 'GET',
      :parser     => Fog::ToHashDocument.new,
      :path       => 'query',
      :query      => query.map {|q| URI.escape(q)}.join('&')
    )
    ensure_list! response.body, :Link
    # TODO: figure out the right key (this isn't it)
    #ensure_list! response.body,
    #  response.body[:type] == 'application/vnd.vmware.vcloud.query.references+xml' ?
    #    "#{response.body[:name]}Reference".to_sym :
    #    "#{response.body[:name]}Record".to_sym

    %w[firstPage previousPage nextPage lastPage].each do |rel|
      if link = response.body[:Link].detect {|l| l[:rel] == rel}
        href = Nokogiri::XML.fragment(link[:href])
        query = CGI.parse(URI.parse(href.text).query)
        response.body[rel.to_sym] = query['page'].first.to_i
        response.body[:pageSize] ||= query['pageSize'].first.to_i
      end
    end

    response
  end
end

#get_groups_from_query(options = {}) ⇒ Excon::Response

Retrieves a list of groups for organization the org admin belongs to by using REST API general QueryHandler.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :sortAsc (String) — default: Sorted by database ID

    Sort results by attribute-name in ascending order. attribute-name cannot include metadata.

  • :sortDesc (String) — default: Sorted by database ID

    Sort results by attribute-name in descending order. attribute-name cannot include metadata.

  • :page (Integer) — default: 1

    If the query results span multiple pages, return this page.

  • :pageSize (Integer) — default: 25

    Number of results per page, to a maximum of 128.

  • :format (String) — default: records

    One of the following types:

    • references Returns a reference to each object, including its :name, :type, and :href attributes.

    • records Returns all database records for each object, with each record as an attribute.

    • idrecords Identical to the records format, except that object references are returned in :id format rather than :href format.

  • :fields (Array<String>) — default: all static attribute names

    List of attribute names or metadata key names to return.

  • :offset (Integer) — default: 0

    Integer value specifying the first record to return. Record numbers < offset are not returned.

  • :filter (String) — default: none

    Filter expression.

Returns:

  • (Excon::Response)
    • hash<~Hash>:

      • :href<~String> - The URI of the entity.

      • :type<~String> - The MIME type of the entity.

      • :name<~String> - Query name that generated this result set.

      • :page<~String> - Page of the result set that this container holds. The first page is page number 1.

      • :pageSize<~String> - Page size, as a number of records or references.

      • :total<~String> - Total number of records or references in the container.

      • :Link<~Array<Hash>>:

        • :href<~String> - Contains the URI to the entity.

        • :type<~String> - Contains the type of the entity.

        • :rel<~String> - Defines the relationship of the link to the object that contains it.

      • :GroupRecord<~Array<Hash>>:

        • TODO

      • :firstPage<~Integer> - First page in the result set.

      • :previousPage<~Integer> - Previous page in the result set.

      • :nextPage<~Integer> - Next page in the result set.

      • :lastPage<~Integer> - Last page in the result set.

See Also:

Since:

  • vCloud API version 1.5



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/fog/vcloud_director/requests/compute/get_groups_from_query.rb', line 57

def get_groups_from_query(options={})
  query = []
  query << "sortAsc=#{options[:sortAsc]}" if options[:sortAsc]
  query << "sortDesc=#{options[:sortDesc]}" if options[:sortDesc]
  query << "page=#{options[:page]}" if options[:page]
  query << "pageSize=#{options[:pageSize]}" if options[:pageSize]
  query << "format=#{options[:format]}" if options[:format]
  query << "fields=#{Array(options[:fields]).join(',')}" if options[:fields]
  query << "offset=#{options[:offset]}" if options[:offset]
  query << "filter=#{options[:filter]}" if options[:filter]

  response = request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => 'admin/groups/query',
    :query      => query.map {|q| URI.escape(q)}.join('&')
  )
  ensure_list! response.body, :Link
  ensure_list! response.body,
    response.body[:type] == 'application/vnd.vmware.vcloud.query.references+xml' ?
      :GroupReference : :GroupRecord

  %w[firstPage previousPage nextPage lastPage].each do |rel|
    if link = response.body[:Link].detect {|l| l[:rel] == rel}
      href = Nokogiri::XML.fragment(link[:href])
      query = CGI.parse(URI.parse(href.text).query)
      response.body[rel.to_sym] = query['page'].first.to_i
      response.body[:pageSize] ||= query['pageSize'].first.to_i
    end
  end

  response
end

#get_guest_customization_system_section_vapp(id) ⇒ Excon::Response

Retrieves the guest customization section of a VM.

Parameters:

  • id (String)

    Object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.0



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_guest_customization_system_section_vapp.rb', line 13

def get_guest_customization_system_section_vapp(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vApp/#{id}/guestCustomizationSection"
  )
end

#get_guest_customization_system_section_vapp_template(id) ⇒ Excon::Response

Retrieves the guest customization section of a VM.

Parameters:

  • id (String)

    Object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.0



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_guest_customization_system_section_vapp_template.rb', line 13

def get_guest_customization_system_section_vapp_template(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vAppTemplate/#{id}/guestCustomizationSection"
  )
end

#get_href(href) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This is used for manual testing.



8
9
10
11
12
13
14
15
16
17
# File 'lib/fog/vcloud_director/requests/compute/get_href.rb', line 8

def get_href(href)
  request(
    :expects       => 200,
    :idempotent    => true,
    :method        => 'GET',
    :parser        => Fog::ToHashDocument.new,
    :override_path => true,
    :path          => URI.parse(href).path
  )
end

#get_lease_settings_section_vapp(id) ⇒ Excon::Response

Retrieves the lease settings section of a vApp.

Parameters:

  • id (String)

    Object identifier of the vApp.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.0



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_lease_settings_section_vapp.rb', line 13

def get_lease_settings_section_vapp(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vApp/#{id}/leaseSettingsSection"
  )
end

#get_lease_settings_section_vapp_template(id) ⇒ Excon::Response

Retrieves the lease settings section of a vApp template.

Parameters:

  • id (String)

    Object identifier of the vApp template.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_lease_settings_section_vapp_template.rb', line 13

def get_lease_settings_section_vapp_template(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vAppTemplate/#{id}/leaseSettingsSection"
  )
end

#get_media(id) ⇒ Excon::Response

Retrieve a media object.

Parameters:

  • id (String)

    Object identifier of the media object.

Returns:

  • (Excon::Response)
    • body<~Hash>:

Raises:

See Also:

Since:

  • vCloud API version 0.9



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/vcloud_director/requests/compute/get_media.rb', line 15

def get_media(id)
  response = request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "media/#{id}"
  )
  ensure_list! response.body, :Files, :File
  response
end

#get_media_drives_rasd_items_list(id) ⇒ Excon::Response

Retrieve all RASD items that specify CD-ROM, DVD, and floppy disk device and controller properties of a VM.

Parameters:

  • id (String)

    Object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



14
15
16
17
18
19
20
21
22
# File 'lib/fog/vcloud_director/requests/compute/get_media_drives_rasd_items_list.rb', line 14

def get_media_drives_rasd_items_list(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vApp/#{id}/virtualHardwareSection/media"
  )
end

#get_media_metadata(id) ⇒ Excon::Response

Retrieve metadata associated with a media object.

Parameters:

  • id (String)

    Object identifier of the media object

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_media_metadata.rb', line 13

def (id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "media/#{id}/metadata"
  )
end

#get_media_metadata_item_metadata(id, key) ⇒ Excon::Response

Retrieve the value of the specified key from media object metadata.

Parameters:

  • id (String)

    Object identifier of the media object.

  • key (String)

    Key of the metadata.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



14
15
16
17
18
19
20
21
22
# File 'lib/fog/vcloud_director/requests/compute/get_media_metadata_item_metadata.rb', line 14

def (id, key)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "media/#{id}/metadata/#{URI.escape(key)})"
  )
end

#get_media_owner(id) ⇒ Excon::Response

Retrieve the owner of a media object.

Parameters:

  • id (String)

    Object identifier of the media object.

Returns:

  • (Excon::Response)
    • body<~Hash>:

      • :href<~String> - The URI of the media object.

      • :type<~String> - The MIME type of the media object.

      • :Link<~Hash>:

        • :href<~String> -

        • :type<~String> -

        • :rel<~String> -

      • :User<~Hash> - Reference to the user who is the owner of this media object.

        • :href<~String> - The URI of the user.

        • :name<~String> - The name of the user.

        • :type<~String> - The MIME type of the user.

Raises:

See Also:

Since:

  • vCloud API version 1.5



26
27
28
29
30
31
32
33
34
# File 'lib/fog/vcloud_director/requests/compute/get_media_owner.rb', line 26

def get_media_owner(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "media/#{id}/owner"
  )
end

#get_medias_from_query(options = {}) ⇒ Excon::Response

Retrieves a media list by using REST API general QueryHandler.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :sortAsc (String) — default: Sorted by database ID

    Sort results by attribute-name in ascending order. attribute-name cannot include metadata.

  • :sortDesc (String) — default: Sorted by database ID

    Sort results by attribute-name in descending order. attribute-name cannot include metadata.

  • :page (Integer) — default: 1

    If the query results span multiple pages, return this page.

  • :pageSize (Integer) — default: 25

    Number of results per page, to a maximum of 128.

  • :format (String) — default: records

    One of the following types:

    • references Returns a reference to each object, including its :name, :type, and :href attributes.

    • records Returns all database records for each object, with each record as an attribute.

    • idrecords Identical to the records format, except that object references are returned in :id format rather than :href format.

  • :fields (Array<String>) — default: all static attribute names

    List of attribute names or metadata key names to return.

  • :offset (Integer) — default: 0

    Integer value specifying the first record to return. Record numbers < offset are not returned.

  • :filter (String) — default: none

    Filter expression.

Returns:

  • (Excon::Response)
    • hash<~Hash>:

      • :href<~String> - The URI of the entity.

      • :type<~String> - The MIME type of the entity.

      • :name<~String> - Query name that generated this result set.

      • :page<~String> - Page of the result set that this container holds. The first page is page number 1.

      • :pageSize<~String> - Page size, as a number of records or references.

      • :total<~String> - Total number of records or references in the container.

      • :Link<~Array<Hash>>:

        • :href<~String> - Contains the URI to the entity.

        • :type<~String> - Contains the type of the entity.

        • :rel<~String> - Defines the relationship of the link to the object that contains it.

      • :MediaRecord<~Array<Hash>>:

        • TODO

      • :firstPage<~Integer> - First page in the result set.

      • :previousPage<~Integer> - Previous page in the result set.

      • :nextPage<~Integer> - Next page in the result set.

      • :lastPage<~Integer> - Last page in the result set.

See Also:

Since:

  • vCloud API version 1.5



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/fog/vcloud_director/requests/compute/get_medias_from_query.rb', line 56

def get_medias_from_query(options={})
  query = []
  query << "sortAsc=#{options[:sortAsc]}" if options[:sortAsc]
  query << "sortDesc=#{options[:sortDesc]}" if options[:sortDesc]
  query << "page=#{options[:page]}" if options[:page]
  query << "pageSize=#{options[:pageSize]}" if options[:pageSize]
  query << "format=#{options[:format]}" if options[:format]
  query << "fields=#{Array(options[:fields]).join(',')}" if options[:fields]
  query << "offset=#{options[:offset]}" if options[:offset]
  query << "filter=#{options[:filter]}" if options[:filter]

  response = request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => 'mediaList/query',
    :query      => query.map {|q| URI.escape(q)}.join('&')
  )
  ensure_list! response.body, :Link
  ensure_list! response.body,
    response.body[:type] == 'application/vnd.vmware.vcloud.query.references+xml' ?
      :MediaReference : :MediaRecord

  %w[firstPage previousPage nextPage lastPage].each do |rel|
    if link = response.body[:Link].detect {|l| l[:rel] == rel}
      href = Nokogiri::XML.fragment(link[:href])
      query = CGI.parse(URI.parse(href.text).query)
      response.body[rel.to_sym] = query['page'].first.to_i
      response.body[:pageSize] ||= query['pageSize'].first.to_i
    end
  end

  response
end

#get_memory_rasd_item(id) ⇒ Excon::Response

Retrieve the RASD item that specifies memory properties of a VM.

Parameters:

  • id (String)

    Object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



16
17
18
19
20
21
22
23
24
# File 'lib/fog/vcloud_director/requests/compute/get_memory_rasd_item.rb', line 16

def get_memory_rasd_item(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vApp/#{id}/virtualHardwareSection/memory"
  )
end

#get_metadata(id) ⇒ Excon::Response

Deprecated.

Use #get_vapp_metadata instead.

TODO:

Log deprecation warning.

Retrieve metadata associated with the vApp or VM.

Parameters:

  • id (String)

    Object identifier of the vApp or VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fog/vcloud_director/requests/compute/get_metadata.rb', line 16

def (id)
  require 'fog/vcloud_director/parsers/compute/metadata'

  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::Parsers::Compute::VcloudDirector::Metadata.new,
    :path       => "vApp/#{id}/metadata/"
  )
end

#get_network(id) ⇒ Excon::Response

Retrieve an organization network.

Parameters:

  • id (String)

    Object identifier of the network.

Returns:

  • (Excon::Response)
    • body<~Hash>:

Raises:

See Also:

Since:

  • vCloud API version 0.9



17
18
19
20
21
22
23
24
25
# File 'lib/fog/vcloud_director/requests/compute/get_network.rb', line 17

def get_network(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::Parsers::Compute::VcloudDirector::Network.new,
    :path       => "network/#{id}"
  )
end

#get_network_cards_items_list(id) ⇒ Excon::Response

Retrieve all RASD items that specify network card properties of a VM.

Parameters:

  • id (String)

    Object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_network_cards_items_list.rb', line 13

def get_network_cards_items_list(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vApp/#{id}/virtualHardwareSection/networkCards"
  )
end

#get_network_config_section_vapp(id) ⇒ Excon::Response

Retrieve the network config section of a vApp.

Parameters:

  • id (String)

    The object identifier of the vApp.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_network_config_section_vapp.rb', line 13

def get_network_config_section_vapp(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vApp/#{id}/networkConfigSection/"
  )
end

#get_network_config_section_vapp_template(id) ⇒ Excon::Response

Retrieve the network config section of a vApp template.

Parameters:

  • id (String)

    The object identifier of the vApp template.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_network_config_section_vapp_template.rb', line 13

def get_network_config_section_vapp_template(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vAppTemplate/#{id}/networkConfigSection/"
  )
end

#get_network_connection_system_section_vapp(id) ⇒ Excon::Response

Retrieve the network connection section of a VM.

Parameters:

  • id (String)

    The object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_network_connection_system_section_vapp.rb', line 13

def get_network_connection_system_section_vapp(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vApp/#{id}/networkConnectionSection/"
  )
end

#get_network_connection_system_section_vapp_template(id) ⇒ Excon::Response

Retrieve the network connection section of a VM.

Parameters:

  • id (String)

    The object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_network_connection_system_section_vapp_template.rb', line 13

def get_network_connection_system_section_vapp_template(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vAppTemplate/#{id}/networkConnectionSection/"
  )
end

#get_network_metadata(id) ⇒ Excon::Response

Retrieve metadata associated with the network.

Parameters:

  • id (String)

    Object identifier of the network.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_network_metadata.rb', line 13

def (id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "network/#{id}/metadata"
  )
end

#get_network_metadata_item_metadata(id, key) ⇒ Excon::Response

Retrieve the value of the specified key from network metadata.

Parameters:

  • id (String)

    Object identifier of the network.

  • key (String)

    Key of the metadata.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



14
15
16
17
18
19
20
21
22
# File 'lib/fog/vcloud_director/requests/compute/get_network_metadata_item_metadata.rb', line 14

def (id, key)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "admin/network/#{id}/metadata/#{URI.escape(key)})"
  )
end

#get_network_section_vapp(id) ⇒ Excon::Response

Retrieve the network section of a vApp.

Parameters:

  • id (String)

    The object identifier of the vApp.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_network_section_vapp.rb', line 13

def get_network_section_vapp(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vApp/#{id}/networkSection/"
  )
end

#get_network_section_vapp_template(id) ⇒ Excon::Response

Retrieve the network section of a vApp template.

Parameters:

  • id (String)

    The object identifier of the vApp template.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_network_section_vapp_template.rb', line 13

def get_network_section_vapp_template(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vAppTemplate/#{id}/networkSection/"
  )
end

#get_operating_system_section(id) ⇒ Excon::Response

Retrieve the operating system section of a VM.

Parameters:

  • id (String)

    The object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_operating_system_section.rb', line 13

def get_operating_system_section(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vApp/#{id}/operatingSystemSection/"
  )
end

#get_org_settings(id) ⇒ Excon:Response

Retrieve settings for this organization.

Organization settings are divided into categories. This request retrieves all categories of organization settings.

Parameters:

  • id (String)

    Object identitifier of the organization.

Returns:

  • (Excon:Response)
    • body<~Hash>:

      • :href<~String> - The URI of the entity.

      • :type<~String> - The MIME type of the entity.

      • :OrgGeneralSettings<~Hash>:

      • :VAppLeaseSettings<~Hash>:

      • :VAppTemplateLeaseSettings<~Hash>:

      • :OrgLdapSettings<~Hash>:

      • :OrgEmailSettings<~Hash>:

      • :OrgPasswordPolicySettings<~Hash>:

      • :OrgOperationLimitsSettings<~Hash>:

      • :OrgFederationSettings<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



26
27
28
29
30
31
32
33
34
# File 'lib/fog/vcloud_director/requests/compute/get_org_settings.rb', line 26

def get_org_settings(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "admin/org/#{id}/settings"
  )
end

#get_org_vdc_gateways(id) ⇒ Excon::Response

List all gateways for this Org vDC.

Parameters:

  • id (String)

    Object identifier of the vDC.

Returns:

  • (Excon::Response)
    • body<~Hash>:

Raises:

See Also:

Since:

  • vCloud API version 5.1



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fog/vcloud_director/requests/compute/get_org_vdc_gateways.rb', line 18

def get_org_vdc_gateways(id)
  response = request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "admin/vdc/#{id}/edgeGateways"
  )
  ensure_list! response.body, :EdgeGatewayRecord
  response
end

#get_organization(id) ⇒ Excon:Response

Retrieve an organization.

Parameters:

  • id (String)

    The object identifier of the organization.

Returns:

  • (Excon:Response)
    • body<~Hash>:

Raises:

See Also:

Since:

  • vCloud API version 0.9



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/vcloud_director/requests/compute/get_organization.rb', line 15

def get_organization(id)
  response = request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "org/#{id}"
  )
  ensure_list! response.body, :Tasks, :Task
  response
end

#get_organization_metadata(id) ⇒ Excon::Response

Retrieve metadata associated with the organization.

Parameters:

  • id (String)

    Object identifier of the organization.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_organization_metadata.rb', line 13

def (id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "org/#{id}/metadata"
  )
end

#get_organization_metadata_item_metadata(id, domain, key) ⇒ Excon::Response

Retrieve the value of the specified key in the specified domain from organization metadata.

Parameters:

  • id (String)

    Object identifier of the network.

  • domain (String)
  • key (String)

    Key of the metadata.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 5.1



16
17
18
19
20
21
22
23
24
# File 'lib/fog/vcloud_director/requests/compute/get_organization_metadata_item_metadata.rb', line 16

def (id, domain, key)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "admin/org/#{id}/metadata/#{URI.escape(domain)}/#{URI.escape(key)})"
  )
end

#get_organizationsExcon::Response

Retrieve a list of organizations accessible to you.

The system administrator has access to all organizations.

Returns:

  • (Excon::Response)
    • body<~Hash>:

      • :href<~String> - The URI of the entity.

      • :type<~String> - The MIME type of the entity.

      • :Org<~Array<Hash>]:

        • :href<~String> - Contains the URI to the linked entity.

        • :name<~String> - Contains the name of the linked entity.

        • :type<~String> - Contains the type of the linked entity.

See Also:

Since:

  • vCloud API version 0.9



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fog/vcloud_director/requests/compute/get_organizations.rb', line 20

def get_organizations
  response = request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => 'org'
  )
  ensure_list! response.body, :Org
  response
end

#get_organizations_from_query(options = {}) ⇒ Excon::Response

Retrieves a list of organizations by using REST API general QueryHandler.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :sortAsc (String) — default: Sorted by database ID

    Sort results by attribute-name in ascending order. attribute-name cannot include metadata.

  • :sortDesc (String) — default: Sorted by database ID

    Sort results by attribute-name in descending order. attribute-name cannot include metadata.

  • :page (Integer) — default: 1

    If the query results span multiple pages, return this page.

  • :pageSize (Integer) — default: 25

    Number of results per page, to a maximum of 128.

  • :format (String) — default: records

    One of the following types:

    • references Returns a reference to each object, including its :name, :type, and :href attributes.

    • records Returns all database records for each object, with each record as an attribute.

    • idrecords Identical to the records format, except that object references are returned in :id format rather than :href format.

  • :fields (Array<String>) — default: all static attribute names

    List of attribute names or metadata key names to return.

  • :offset (Integer) — default: 0

    Integer value specifying the first record to return. Record numbers < offset are not returned.

  • :filter (String) — default: none

    Filter expression.

Returns:

  • (Excon::Response)
    • hash<~Hash>:

      • :href<~String> - The URI of the entity.

      • :type<~String> - The MIME type of the entity.

      • :name<~String> - Query name that generated this result set.

      • :page<~String> - Page of the result set that this container holds. The first page is page number 1.

      • :pageSize<~String> - Page size, as a number of records or references.

      • :total<~String> - Total number of records or references in the container.

      • :Link<~Array<Hash>>:

        • :href<~String> - Contains the URI to the entity.

        • :type<~String> - Contains the type of the entity.

        • :rel<~String> - Defines the relationship of the link to the object that contains it.

      • :OrganizationRecord<~Array<Hash>>:

        • TODO

      • :firstPage<~Integer> - First page in the result set.

      • :previousPage<~Integer> - Previous page in the result set.

      • :nextPage<~Integer> - Next page in the result set.

      • :lastPage<~Integer> - Last page in the result set.

See Also:

Since:

  • vCloud API version 1.5



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/fog/vcloud_director/requests/compute/get_organizations_from_query.rb', line 57

def get_organizations_from_query(options={})
  query = []
  query << "sortAsc=#{options[:sortAsc]}" if options[:sortAsc]
  query << "sortDesc=#{options[:sortDesc]}" if options[:sortDesc]
  query << "page=#{options[:page]}" if options[:page]
  query << "pageSize=#{options[:pageSize]}" if options[:pageSize]
  query << "format=#{options[:format]}" if options[:format]
  query << "fields=#{Array(options[:fields]).join(',')}" if options[:fields]
  query << "offset=#{options[:offset]}" if options[:offset]
  query << "filter=#{options[:filter]}" if options[:filter]

  response = request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => 'admin/orgs/query',
    :query      => query.map {|q| URI.escape(q)}.join('&')
  )
  ensure_list! response.body, :Link
  ensure_list! response.body,
    response.body[:type] == 'application/vnd.vmware.vcloud.query.references+xml' ?
      :OrganizationReference : :OrganizationRecord

  %w[firstPage previousPage nextPage lastPage].each do |rel|
    if link = response.body[:Link].detect {|l| l[:rel] == rel}
      href = Nokogiri::XML.fragment(link[:href])
      query = CGI.parse(URI.parse(href.text).query)
      response.body[rel.to_sym] = query['page'].first.to_i
      response.body[:pageSize] ||= query['pageSize'].first.to_i
    end
  end

  response
end

#get_product_sections_vapp(id) ⇒ Excon::Response

Retrieve a list of ProductSection elements from a vApp or VM.

Parameters:

  • id (String)

    Object identifier of the vApp or VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_product_sections_vapp.rb', line 13

def get_product_sections_vapp(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vApp/#{id}/productSections"
  )
end

#get_product_sections_vapp_template(id) ⇒ Excon::Response

Retrieve a list of ProductSection elements from a vApp template or VM.

Parameters:

  • id (String)

    Object identifier of the vApp template or VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



14
15
16
17
18
19
20
21
22
# File 'lib/fog/vcloud_director/requests/compute/get_product_sections_vapp_template.rb', line 14

def get_product_sections_vapp_template(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vAppTemplate/#{id}/productSections"
  )
end

#get_request(uri) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This is used for manual testing.



8
9
10
11
12
13
14
15
# File 'lib/fog/vcloud_director/requests/compute/get_request.rb', line 8

def get_request(uri)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :path       => uri
  )
end

#get_runtime_info_section_type(id) ⇒ Excon::Response

Retrieve the runtime info section of a VM.

Parameters:

  • id (String)

    Object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_runtime_info_section_type.rb', line 13

def get_runtime_info_section_type(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vApp/#{id}/runtimeInfoSection"
  )
end

#get_serial_ports_items_list(id) ⇒ Excon::Response

Retrieve all RASD items that specify serial port properties of a VM.

Parameters:

  • id (String)

    Object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_serial_ports_items_list.rb', line 13

def get_serial_ports_items_list(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vApp/#{id}/virtualHardwareSection/serialPorts"
  )
end

#get_shadow_vm(id) ⇒ Excon::Response

Retrieve a shadow VM.

Parameters:

  • id (String)

    The object identifier of the shadow VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:



12
13
14
15
16
17
18
19
20
# File 'lib/fog/vcloud_director/requests/compute/get_shadow_vm.rb', line 12

def get_shadow_vm(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "shadowVm/#{id}"
  )
end

#get_snapshot_section(id) ⇒ Excon::Response

Retrieve SnapshotSection element for a vApp or VM.

Parameters:

  • id (String)

    Object identifier of the vApp or VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 5.1



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_snapshot_section.rb', line 13

def get_snapshot_section(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vApp/#{id}/snapshotSection"
  )
end

#get_startup_section(id) ⇒ Excon::Response

Retrieve the startup section of a vApp.

Parameters:

  • id (String)

    Object identifier of the vApp.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_startup_section.rb', line 13

def get_startup_section(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vApp/#{id}/startupSection"
  )
end

#get_supported_systems_infoExcon::Response

List operating systems available for use on virtual machines owned by this organization.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 5.1



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_supported_systems_info.rb', line 13

def get_supported_systems_info
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => 'supportedSystemsInfo'
  )
end

#get_supported_versionsExcon::Response

List all supported versions.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



12
13
14
15
16
17
18
19
20
# File 'lib/fog/vcloud_director/requests/compute/get_supported_versions.rb', line 12

def get_supported_versions
  @connection.request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "#{@path}/versions"
  )
end

#get_task(id) ⇒ Excon::Response

Retrieve a task.

Parameters:

  • id (String)

    The object identifier of the task.

Returns:

  • (Excon::Response)
    • body<~Hash>:

      • :href<~String> - The URI of the entity.

      • :type<~String> - The MIME type of the entity.

      • :id<~String> - The entity identifier, expressed in URN format. The value of this attribute uniquely identifies the entity, persists for the life of the entity, and is never reused.

      • :operationKey<~String> - Optional unique identifier to support idempotent semantics for create and delete operations.

      • :name<~String> - The name of the entity.

      • :cancelRequested<~String> - Whether user has requested this processing to be canceled.

      • :endTime<~String> - The date and time that processing of the task was completed. May not be present if the task is still being executed.

      • :expiryTime<~String> - The date and time at which the task resource will be destroyed and no longer available for retrieval. May not be present if the task has not been executed or is still being executed.

      • :operation<~String> - A message describing the operation that is tracked by this task.

      • :operationName<~String> - The short name of the operation that is tracked by this task.

      • :serviceNamespace<~String> - Identifier of the service that created the task.

      • :startTime<~String> - The date and time the system started executing the task. May not be present if the task has not been executed yet.

      • :status<~String> - The execution status of the task.

      • :Link<~Array<Hash>>:

      • :Description<~String> - Optional description.

      • :Owner<~Hash> - Reference to the owner of the task. This is typically the object that the task is creating or updating.

        • :href<~String> - Contains the URI to the entity.

        • :name<~String> - Contains the name of the entity.

        • :type<~String> - Contains the type of the entity.

      • :Error<~Hash> - Represents error information from a failed task.

        • :majorErrorCode<~String> - The class of the error. Matches the HTTP status code.

        • :message<~String> - An one line, human-readable message describing the error that occurred.

        • :minorErrorCode<~String> - Resource-specific error code.

        • :stackTrace<~String> - The stack trace of the exception.

        • :vendorSpecificErrorCode<~String> - A vendor- or implementation-specific error code that can reference specific modules or source lines for diagnostic purposes.

      • :User<~Hash> - The user who started the task.

        • :href<~String> - Contains the URI to the entity.

        • :name<~String> - Contains the name of the entity.

        • :type<~String> - Contains the type of the entity.

      • :Organization<~Hash> - The organization to which the :User belongs.

        • :href<~String> - Contains the URI to the entity.

        • :name<~String> - Contains the name of the entity.

        • :type<~String> - Contains the type of the entity.

      • :Progress<~String> - Read-only indicator of task progress as an approximate percentage between 0 and 100. Not available for all tasks.

      • :Params

      • :Details<~String> - Detailed message about the task. Also contained by the :Owner entity when task status is preRunning.

Raises:

See Also:

Since:

  • vCloud API version 0.9



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/fog/vcloud_director/requests/compute/get_task.rb', line 77

def get_task(id)
  response = request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "task/#{id}"
  )

  # vCloud Director bug: Owner may be absent for some tasks, fix
  # targeted for 5.1.3 (due out at the beginning Q1 2014).
  #
  # We'd prefer that Owner is always present; if nothing else, this
  # let's the tests pass.
  response.body[:Owner] ||= {:href => '', :name => nil, :type => nil}

  response
end

#get_task_list(id) ⇒ Excon::Response

Retrieve a list of this organization’s queued, running, or recently completed tasks.

Parameters:

  • id (String)

    Object identifier of the organization.

Returns:

  • (Excon::Response)
    • body<~Hash>:

      • :href<~String> - The URI of the entity.

      • :type<~String> - The MIME type of the entity.

      • :id<~String> - The entity identifier, expressed in URN format. The value of this attribute uniquely identifies the entity, persists for the life of the entity, and is never reused.

      • :name<~String> - The name of the entity.

      • :Task<~Array<Hash>>:

        • :href<~String> - The URI of the entity.

        • :type<~String> - The MIME type of the entity.

        • :id<~String> - The entity identifier, expressed in URN format. The value of this attribute uniquely identifies the entity, persists for the life of the entity, and is never reused.

        • :operationKey<~String> - Optional unique identifier to support idempotent semantics for create and delete operations.

        • :name<~String> - The name of the entity.

        • :cancelRequested<~String> - Whether user has requested this processing to be canceled.

        • :endTime<~String> - The date and time that processing of the task was completed. May not be present if the task is still being executed.

        • :expiryTime<~String> - The date and time at which the task resource will be destroyed and no longer available for retrieval. May not be present if the task has not been executed or is still being executed.

        • :operation<~String> - A message describing the operation that is tracked by this task.

        • :operationName<~String> - The short name of the operation that is tracked by this task.

        • :serviceNamespace<~String> - Identifier of the service that created the task.

        • :startTime<~String> - The date and time the system started executing the task. May not be present if the task has not been executed yet.

        • :status<~String> - The execution status of the task.

        • :Link<~Array<Hash>>:

        • :Description<~String> - Optional description.

        • :Owner<~Hash> - Reference to the owner of the task. This is typically the object that the task is creating or updating.

          • :href<~String> - Contains the URI to the entity.

          • :name<~String> - Contains the name of the entity.

          • :type<~String> - Contains the type of the entity.

        • :Error<~Hash> - Represents error information from a failed task.

          • :majorErrorCode<~String> - The class of the error. Matches the HTTP status code.

          • :message<~String> - An one line, human-readable message describing the error that occurred.

          • :minorErrorCode<~String> - Resource-specific error code.

          • :stackTrace<~String> - The stack trace of the exception.

          • :vendorSpecificErrorCode<~String> - A vendor- or implementation-specific error code that can reference specific modules or source lines for diagnostic purposes.

        • :User<~Hash> - The user who started the task.

          • :href<~String> - Contains the URI to the entity.

          • :name<~String> - Contains the name of the entity.

          • :type<~String> - Contains the type of the entity.

        • :Organization<~Hash> - The organization to which the :User belongs.

          • :href<~String> - Contains the URI to the entity.

          • :name<~String> - Contains the name of the entity.

          • :type<~String> - Contains the type of the entity.

        • :Progress<~String> - Read-only indicator of task progress as an approximate percentage between 0 and 100. Not available for all tasks.

        • :Params

        • :Details<~String> - Detailed message about the task. Also contained by the :Owner entity when task status is preRunning.

Raises:

See Also:

Since:

  • vCloud API version 0.9



90
91
92
93
94
95
96
97
98
99
100
# File 'lib/fog/vcloud_director/requests/compute/get_task_list.rb', line 90

def get_task_list(id)
  response = request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "tasksList/#{id}"
  )
  ensure_list! response.body, :Task
  response
end

#get_thumbnail(id) ⇒ Excon::Response

Retrieves a thumbnail image of a VM console.

The content type of the response can be any of ‘image/png`, `image/gif`.

Parameters:

  • id (String)

    Object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~String> - the thumbnail image.

See Also:

Since:

  • vCloud API version 0.9



16
17
18
19
20
21
22
23
24
# File 'lib/fog/vcloud_director/requests/compute/get_thumbnail.rb', line 16

def get_thumbnail(id)
  request(
    :expects    => 200,
    :headers    => {'Accept' => "image/*;version=#{@api_version}"},
    :idempotent => true,
    :method     => 'GET',
    :path       => "vApp/#{id}/screen"
  )
end

#get_users_from_query(options = {}) ⇒ Excon::Response

Retrieves a list of users for organization the org admin belongs to by using REST API general QueryHandler.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :sortAsc (String) — default: Sorted by database ID

    Sort results by attribute-name in ascending order. attribute-name cannot include metadata.

  • :sortDesc (String) — default: Sorted by database ID

    Sort results by attribute-name in descending order. attribute-name cannot include metadata.

  • :page (Integer) — default: 1

    If the query results span multiple pages, return this page.

  • :pageSize (Integer) — default: 25

    Number of results per page, to a maximum of 128.

  • :format (String) — default: records

    One of the following types:

    • references Returns a reference to each object, including its :name, :type, and :href attributes.

    • records Returns all database records for each object, with each record as an attribute.

    • idrecords Identical to the records format, except that object references are returned in :id format rather than :href format.

  • :fields (Array<String>) — default: all static attribute names

    List of attribute names or metadata key names to return.

  • :offset (Integer) — default: 0

    Integer value specifying the first record to return. Record numbers < offset are not returned.

  • :filter (String) — default: none

    Filter expression.

Returns:

  • (Excon::Response)
    • hash<~Hash>:

      • :href<~String> - The URI of the entity.

      • :type<~String> - The MIME type of the entity.

      • :name<~String> - Query name that generated this result set.

      • :page<~String> - Page of the result set that this container holds. The first page is page number 1.

      • :pageSize<~String> - Page size, as a number of records or references.

      • :total<~String> - Total number of records or references in the container.

      • :Link<~Array<Hash>>:

        • :href<~String> - Contains the URI to the entity.

        • :type<~String> - Contains the type of the entity.

        • :rel<~String> - Defines the relationship of the link to the object that contains it.

      • :UserRecord<~Array<Hash>>:

        • TODO

      • :firstPage<~Integer> - First page in the result set.

      • :previousPage<~Integer> - Previous page in the result set.

      • :nextPage<~Integer> - Next page in the result set.

      • :lastPage<~Integer> - Last page in the result set.

See Also:

Since:

  • vCloud API version 1.5



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/fog/vcloud_director/requests/compute/get_users_from_query.rb', line 57

def get_users_from_query(options={})
  query = []
  query << "sortAsc=#{options[:sortAsc]}" if options[:sortAsc]
  query << "sortDesc=#{options[:sortDesc]}" if options[:sortDesc]
  query << "page=#{options[:page]}" if options[:page]
  query << "pageSize=#{options[:pageSize]}" if options[:pageSize]
  query << "format=#{options[:format]}" if options[:format]
  query << "fields=#{Array(options[:fields]).join(',')}" if options[:fields]
  query << "offset=#{options[:offset]}" if options[:offset]
  query << "filter=#{options[:filter]}" if options[:filter]

  response = request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => 'admin/users/query',
    :query      => query.map {|q| URI.escape(q)}.join('&')
  )
  ensure_list! response.body, :Link
  ensure_list! response.body,
    response.body[:type] == 'application/vnd.vmware.vcloud.query.references+xml' ?
      :UserReference : :UserRecord

  %w[firstPage previousPage nextPage lastPage].each do |rel|
    if link = response.body[:Link].detect {|l| l[:rel] == rel}
      href = Nokogiri::XML.fragment(link[:href])
      query = CGI.parse(URI.parse(href.text).query)
      response.body[rel.to_sym] = query['page'].first.to_i
      response.body[:pageSize] ||= query['pageSize'].first.to_i
    end
  end

  response
end

#get_vapp(id) ⇒ Excon::Response

Retrieve a vApp or VM.

Parameters:

  • id (String)

    Object identifier of the vApp or VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fog/vcloud_director/requests/compute/get_vapp.rb', line 13

def get_vapp(id)
  response = request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vApp/#{id}"
  )
  ensure_list! response.body, :Children, :Vm
  response
end

#get_vapp_metadata(id) ⇒ Excon::Response

Retrieve metadata associated with the vApp or VM.

Parameters:

  • id (String)

    Object identifier of the vApp or VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fog/vcloud_director/requests/compute/get_vapp_metadata.rb', line 13

def (id)
  response = request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vApp/#{id}/metadata/"
  )
  ensure_list! response.body, :MetadataEntry
  response
end

#get_vapp_metadata_item_metadata(id, key) ⇒ Excon::Response

Retrieve the value of the specified key from vApp or VM metadata.

Parameters:

  • id (String)

    Object identifier of the vApp or VM.

  • key (String)

    Key of the metadata.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



14
15
16
17
18
19
20
21
22
# File 'lib/fog/vcloud_director/requests/compute/get_vapp_metadata_item_metadata.rb', line 14

def (id, key)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vApp/#{id}/metadata/#{URI.escape(key)})"
  )
end

#get_vapp_ovf_descriptor(id) ⇒ Excon::Response

Retrieve the OVF descriptor of a vApp directly.

Parameters:

  • id (String)

    Object identifier of the vApp.

Returns:

  • (Excon::Response)
    • body<~String> - the OVF descriptor.

See Also:

Since:

  • vCloud API version 5.1



13
14
15
16
17
18
19
20
# File 'lib/fog/vcloud_director/requests/compute/get_vapp_ovf_descriptor.rb', line 13

def get_vapp_ovf_descriptor(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :path       => "vApp/#{id}/ovf"
  )
end

#get_vapp_owner(id) ⇒ Excon::Response

Retrieve the owner of a vApp.

Parameters:

  • id (String)

    Object identifier of the vApp.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_vapp_owner.rb', line 13

def get_vapp_owner(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vApp/#{id}/owner"
  )
end

#get_vapp_template(id) ⇒ Excon::Response

Retrieve a vApp template.

Parameters:

  • id (String)

    Object identifier of the vApp template.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_vapp_template.rb', line 13

def get_vapp_template(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vAppTemplate/#{id}"
  )
end

#get_vapp_template_customization_system_section(id) ⇒ Excon::Response

Retrieves the customization section of a vApp template.

Parameters:

  • id (String)

    Object identifier of the vApp template.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.0



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_vapp_template_customization_system_section.rb', line 13

def get_vapp_template_customization_system_section(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vAppTemplate/#{id}/customizationSection"
  )
end

#get_vapp_template_metadata(id) ⇒ Excon::Response

Retrieve metadata associated with the vApp template or VM.

Parameters:

  • id (String)

    Object identifier of the vApp template or VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_vapp_template_metadata.rb', line 13

def (id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vAppTemplate/#{id}/metadata/"
  )
end

#get_vapp_template_metadata_item_metadata(id, key) ⇒ Excon::Response

Retrieve the value of the specified key from vApp template or VM metadata.

Parameters:

  • id (String)

    Object identifier of the vApp template or VM.

  • key (String)

    Key of the metadata.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



15
16
17
18
19
20
21
22
23
# File 'lib/fog/vcloud_director/requests/compute/get_vapp_template_metadata_item_metadata.rb', line 15

def (id, key)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vAppTemplate/#{id}/metadata/#{URI.escape(key)})"
  )
end

#get_vapp_template_ovf_descriptor(id) ⇒ Excon::Response

Retrieve the OVF descriptor of a vApp template.

Parameters:

  • id (String)

    Object identifier of the vAppTemplate.

Returns:

  • (Excon::Response)
    • body<~String> - the OVF descriptor.

See Also:

Since:

  • vCloud API version 0.9



13
14
15
16
17
18
19
20
# File 'lib/fog/vcloud_director/requests/compute/get_vapp_template_ovf_descriptor.rb', line 13

def get_vapp_template_ovf_descriptor(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :path       => "vAppTemplate/#{id}/ovf"
  )
end

#get_vapp_template_owner(id) ⇒ Excon::Response

Retrieve the owner of a vApp template.

Parameters:

  • id (String)

    Object identifier of the vApp template.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_vapp_template_owner.rb', line 13

def get_vapp_template_owner(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vAppTemplate/#{id}/owner"
  )
end

#get_vapp_templates_from_query(options = {}) ⇒ Excon::Response

Retrieves a list of vAppTemplates using REST API general QueryHandler.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :sortAsc (String) — default: Sorted by database ID

    Sort results by attribute-name in ascending order. attribute-name cannot include metadata.

  • :sortDesc (String) — default: Sorted by database ID

    Sort results by attribute-name in descending order. attribute-name cannot include metadata.

  • :page (Integer) — default: 1

    If the query results span multiple pages, return this page.

  • :pageSize (Integer) — default: 25

    Number of results per page, to a maximum of 128.

  • :format (String) — default: records

    One of the following types:

    • references Returns a reference to each object, including its :name, :type, and :href attributes.

    • records Returns all database records for each object, with each record as an attribute.

    • idrecords Identical to the records format, except that object references are returned in :id format rather than :href format.

  • :fields (Array<String>) — default: all static attribute names

    List of attribute names or metadata key names to return.

  • :offset (Integer) — default: 0

    Integer value specifying the first record to return. Record numbers < offset are not returned.

  • :filter (String) — default: none

    Filter expression.

Returns:

  • (Excon::Response)
    • hash<~Hash>:

      • :href<~String> - The URI of the entity.

      • :type<~String> - The MIME type of the entity.

      • :name<~String> - Query name that generated this result set.

      • :page<~String> - Page of the result set that this container holds. The first page is page number 1.

      • :pageSize<~String> - Page size, as a number of records or references.

      • :total<~String> - Total number of records or references in the container.

      • :Link<~Array<Hash>>:

        • :href<~String> - Contains the URI to the entity.

        • :type<~String> - Contains the type of the entity.

        • :rel<~String> - Defines the relationship of the link to the object that contains it.

      • :VAppTemplateRecord<~Array<Hash>>:

        • TODO

      • :firstPage<~Integer> - First page in the result set.

      • :previousPage<~Integer> - Previous page in the result set.

      • :nextPage<~Integer> - Next page in the result set.

      • :lastPage<~Integer> - Last page in the result set.

See Also:

Since:

  • vCloud API version 1.5



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/fog/vcloud_director/requests/compute/get_vapp_templates_from_query.rb', line 57

def get_vapp_templates_from_query(options={})
  query = []
  query << "sortAsc=#{options[:sortAsc]}" if options[:sortAsc]
  query << "sortDesc=#{options[:sortDesc]}" if options[:sortDesc]
  query << "page=#{options[:page]}" if options[:page]
  query << "pageSize=#{options[:pageSize]}" if options[:pageSize]
  query << "format=#{options[:format]}" if options[:format]
  query << "fields=#{Array(options[:fields]).join(',')}" if options[:fields]
  query << "offset=#{options[:offset]}" if options[:offset]
  query << "filter=#{options[:filter]}" if options[:filter]

  response = request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => 'vAppTemplates/query',
    :query      => query.map {|q| URI.escape(q)}.join('&')
  )
  ensure_list! response.body, :Link
  ensure_list! response.body,
    response.body[:type] == 'application/vnd.vmware.vcloud.query.references+xml' ?
      :VAppTemplateReference : :VAppTemplateRecord

  %w[firstPage previousPage nextPage lastPage].each do |rel|
    if link = response.body[:Link].detect {|l| l[:rel] == rel}
      href = Nokogiri::XML.fragment(link[:href])
      query = CGI.parse(URI.parse(href.text).query)
      response.body[rel.to_sym] = query['page'].first.to_i
      response.body[:pageSize] ||= query['pageSize'].first.to_i
    end
  end

  response
end

#get_vapps_in_lease_from_query(options = {}) ⇒ Excon::Response

Retrieves a list of vApps by using REST API general QueryHandler.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :sortAsc (String) — default: Sorted by database ID

    Sort results by attribute-name in ascending order. attribute-name cannot include metadata.

  • :sortDesc (String) — default: Sorted by database ID

    Sort results by attribute-name in descending order. attribute-name cannot include metadata.

  • :page (Integer) — default: 1

    If the query results span multiple pages, return this page.

  • :pageSize (Integer) — default: 25

    Number of results per page, to a maximum of 128.

  • :format (String) — default: records

    One of the following types:

    • references Returns a reference to each object, including its :name, :type, and :href attributes.

    • records Returns all database records for each object, with each record as an attribute.

    • idrecords Identical to the records format, except that object references are returned in :id format rather than :href format.

  • :fields (Array<String>) — default: all static attribute names

    List of attribute names or metadata key names to return.

  • :offset (Integer) — default: 0

    Integer value specifying the first record to return. Record numbers < offset are not returned.

  • :filter (String) — default: none

    Filter expression.

Returns:

  • (Excon::Response)
    • hash<~Hash>:

      • :href<~String> - The URI of the entity.

      • :type<~String> - The MIME type of the entity.

      • :name<~String> - Query name that generated this result set.

      • :page<~String> - Page of the result set that this container holds. The first page is page number 1.

      • :pageSize<~String> - Page size, as a number of records or references.

      • :total<~String> - Total number of records or references in the container.

      • :Link<~Array<Hash>>:

        • :href<~String> - Contains the URI to the entity.

        • :type<~String> - Contains the type of the entity.

        • :rel<~String> - Defines the relationship of the link to the object that contains it.

      • :VAppRecord<~Array<Hash>>:

        • TODO

      • :firstPage<~Integer> - First page in the result set.

      • :previousPage<~Integer> - Previous page in the result set.

      • :nextPage<~Integer> - Next page in the result set.

      • :lastPage<~Integer> - Last page in the result set.

See Also:

Since:

  • vCloud API version 1.5



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/fog/vcloud_director/requests/compute/get_vapps_in_lease_from_query.rb', line 56

def get_vapps_in_lease_from_query(options={})
  query = []
  query << "sortAsc=#{options[:sortAsc]}" if options[:sortAsc]
  query << "sortDesc=#{options[:sortDesc]}" if options[:sortDesc]
  query << "page=#{options[:page]}" if options[:page]
  query << "pageSize=#{options[:pageSize]}" if options[:pageSize]
  query << "format=#{options[:format]}" if options[:format]
  query << "fields=#{Array(options[:fields]).join(',')}" if options[:fields]
  query << "offset=#{options[:offset]}" if options[:offset]
  query << "filter=#{options[:filter]}" if options[:filter]

  response = request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => 'vApps/query',
    :query      => query.map {|q| URI.escape(q)}.join('&')
  )
  ensure_list! response.body, :Link
  ensure_list! response.body, 
    response.body[:type] == 'application/vnd.vmware.vcloud.query.references+xml' ?
      :VAppReference : :VAppRecord

  %w[firstPage previousPage nextPage lastPage].each do |rel|
    if link = response.body[:Link].detect {|l| l[:rel] == rel}
      href = Nokogiri::XML.fragment(link[:href])
      query = CGI.parse(URI.parse(href.text).query)
      response.body[rel.to_sym] = query['page'].first.to_i
      response.body[:pageSize] ||= query['pageSize'].first.to_i
    end
  end

  response
end

#get_vcloudExcon:Response

Retrieve an administrative view of a cloud.

The VCloud element provides access to cloud-wide namespace of objects that an administrator can view and, in most cases, modify.

Returns:

  • (Excon:Response)
    • body<~Hash>:

      • :href<~String> - The URI of the entity.

      • :type<~String> - The MIME type of the entity.

      • :name<~String> - The name of the entity.

      • :Description<~String> - Optional description.

      • :OrganizationReferences<Hash>:

        • :OrganizationReference<~Array<Hash>>:

          • :href<~String> - Contains the URI to the entity.

          • :name<~String> - Contains the name of the entity.

          • :type<~String> - Contains the type of the entity.

      • :ProviderVdcReferences<~Hash>:

        • :ProviderVdcReferences<~Array<Hash>>:

      • :RightReferences<~Hash>:

        • :RightReferences<~Array<Hash>>:

      • :RoleReferences<~Hash>:

        • :RoleReferences<~Array<Hash>>:

      • :Networks<~Hash>:

        • :Network<~Array<Hash>>:

See Also:

Since:

  • vCloud API version 0.9



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/fog/vcloud_director/requests/compute/get_vcloud.rb', line 32

def get_vcloud
  response = request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => 'admin/'
  )
  ensure_list! response.body, :OrganizationReferences, :OrganizationReference
  ensure_list! response.body, :ProviderVdcReferences, :ProviderVdcReference
  ensure_list! response.body, :RightReferences, :RightReference
  ensure_list! response.body, :RoleReferences, :RoleReference
  ensure_list! response.body, :Networks, :Network
  response
end

#get_vdc(id) ⇒ Excon::Response

Retrieve a vDC.

Parameters:

  • id (String)

    Object identifier of the vDC.

Returns:

  • (Excon::Response)
    • body<~Hash>:

Raises:

See Also:

Since:

  • vCloud API version 0.9



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fog/vcloud_director/requests/compute/get_vdc.rb', line 15

def get_vdc(id)
  response = request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vdc/#{id}"
  )
  ensure_list! response.body, :ResourceEntities, :ResourceEntity
  ensure_list! response.body, :AvailableNetworks, :Network
  ensure_list! response.body, :VdcStorageProfiles, :VdcStorageProfile
  response
end

#get_vdc_metadata(id) ⇒ Excon::Response

Retrieve metadata associated with a vDC.

Parameters:

  • id (String)

    Object identifier of the vDC.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_vdc_metadata.rb', line 13

def (id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vdc/#{id}/metadata/"
  )
end

#get_vdc_metadata_item_metadata(id, domain, key) ⇒ Excon::Response

Retrieve the value of the specified key from virtual datacenter metadata.

Parameters:

  • id (String)

    Object identifier of the network.

  • domain (String)
  • key (String)

    Key of the metadata.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



16
17
18
19
20
21
22
23
24
# File 'lib/fog/vcloud_director/requests/compute/get_vdc_metadata_item_metadata.rb', line 16

def (id, domain, key)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "admin/vdc/#{id}/metadata/#{URI.escape(key)})"
  )
end

#get_vdc_storage_class(id) ⇒ Excon::Response

Returns storage class referred by the Id. All properties of the storage classes are visible to vcloud user, except for VDC Storage Class reference.

Parameters:

  • id (String)

    Object identifier of the vDC storage profile.

Returns:

  • (Excon::Response)
    • body<~Hash>:

      • :href<~String> - The URI of the entity.

      • :type<~String> - The MIME type of the entity.

      • :id<~String> - The entity identifier, expressed in URN format. The value of this attribute uniquely identifies the entity, persists for the life of the entity, and is never reused.

      • :name<~String> - The name of the entity.

      • :Description<~String> - Optional description.

      • :Enabled<~String> - True if this storage profile is enabled for use in the vDC.

      • :Units<~String> - Units used to define :Limit.

      • :Limit<~String> - Maximum number of :Units allocated for this storage profile.

      • :Default<~String> - True if this is default storage profile for this vDC. The default storage profile is used when an object that can specify a storage profile is created with no storage profile specified.

Raises:

See Also:



35
36
37
38
39
40
41
42
43
# File 'lib/fog/vcloud_director/requests/compute/get_vdc_storage_class.rb', line 35

def get_vdc_storage_class(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vdcStorageProfile/#{id}"
  )
end

#get_vdc_storage_class_metadata(id) ⇒ Excon::Response

Retrieve metadata associated with the vDC storage profile.

Parameters:

  • id (String)

    Object identifier of the vDC storage profile.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:



15
16
17
18
19
20
21
22
23
# File 'lib/fog/vcloud_director/requests/compute/get_vdc_storage_class_metadata.rb', line 15

def (id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vdcStorageProfile/#{id}/metadata/"
  )
end

#get_vdc_storage_class_metadata_item_metadata(id, key) ⇒ Excon::Response

Retrieve metadata associated with the vDC storage profile.

Parameters:

  • id (String)

    Object identifier of the vDC storage profile.

  • key (String)

    Key of the metadata.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:



13
14
15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/get_vdc_storage_class_metadata_item_metadata.rb', line 13

def (id, key)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vdcStorageProfile/#{id}/metadata/#{URI.escape(key)})"
  )
end

#get_vdcs_from_query(options = {}) ⇒ Excon::Response

Retrieves a list of vdcs in the organization.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :sortAsc (String) — default: Sorted by database ID

    Sort results by attribute-name in ascending order. attribute-name cannot include metadata.

  • :sortDesc (String) — default: Sorted by database ID

    Sort results by attribute-name in descending order. attribute-name cannot include metadata.

  • :page (Integer) — default: 1

    If the query results span multiple pages, return this page.

  • :pageSize (Integer) — default: 25

    Number of results per page, to a maximum of 128.

  • :format (String) — default: records

    One of the following types:

    • references Returns a reference to each object, including its :name, :type, and :href attributes.

    • records Returns all database records for each object, with each record as an attribute.

    • idrecords Identical to the records format, except that object references are returned in :id format rather than :href format.

  • :fields (Array<String>) — default: all static attribute names

    List of attribute names or metadata key names to return.

  • :offset (Integer) — default: 0

    Integer value specifying the first record to return. Record numbers < offset are not returned.

  • :filter (String) — default: none

    Filter expression.

Returns:

  • (Excon::Response)
    • hash<~Hash>:

      • :href<~String> - The URI of the entity.

      • :type<~String> - The MIME type of the entity.

      • :name<~String> - Query name that generated this result set.

      • :page<~String> - Page of the result set that this container holds. The first page is page number 1.

      • :pageSize<~String> - Page size, as a number of records or references.

      • :total<~String> - Total number of records or references in the container.

      • :Link<~Array<Hash>>:

        • :href<~String> - Contains the URI to the entity.

        • :type<~String> - Contains the type of the entity.

        • :rel<~String> - Defines the relationship of the link to the object that contains it.

      • :OrgVdcRecord<~Array<Hash>>:

        • TODO

      • :firstPage<~Integer> - First page in the result set.

      • :previousPage<~Integer> - Previous page in the result set.

      • :nextPage<~Integer> - Next page in the result set.

      • :lastPage<~Integer> - Last page in the result set.

See Also:

Since:

  • vCloud API version 1.5



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/fog/vcloud_director/requests/compute/get_vdcs_from_query.rb', line 56

def get_vdcs_from_query(options={})
  query = []
  query << "sortAsc=#{options[:sortAsc]}" if options[:sortAsc]
  query << "sortDesc=#{options[:sortDesc]}" if options[:sortDesc]
  query << "page=#{options[:page]}" if options[:page]
  query << "pageSize=#{options[:pageSize]}" if options[:pageSize]
  query << "format=#{options[:format]}" if options[:format]
  query << "fields=#{Array(options[:fields]).join(',')}" if options[:fields]
  query << "offset=#{options[:offset]}" if options[:offset]
  query << "filter=#{options[:filter]}" if options[:filter]

  response = request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => 'admin/vdcs/query',
    :query      => query.map {|q| URI.escape(q)}.join('&')
  )
  ensure_list! response.body, :Link
  ensure_list! response.body, 
    response.body[:type] == 'application/vnd.vmware.vcloud.query.references+xml' ?
      :OrgVdcReference : :OrgVdcRecord

  %w[firstPage previousPage nextPage lastPage].each do |rel|
    if link = response.body[:Link].detect {|l| l[:rel] == rel}
      href = Nokogiri::XML.fragment(link[:href])
      query = CGI.parse(URI.parse(href.text).query)
      response.body[rel.to_sym] = query['page'].first.to_i
      response.body[:pageSize] ||= query['pageSize'].first.to_i
    end
  end

  response
end

#get_virtual_hardware_section(id) ⇒ Excon::Response

Retrieve the virtual hardware section of a VM.

This operation retrieves the entire VirtualHardwareSection of a VM. You can also retrieve many RASD item elements of a VirtualHardwareSection individually, or as groups of related items.

Parameters:

  • id (String)

    Object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



17
18
19
20
21
22
23
24
25
# File 'lib/fog/vcloud_director/requests/compute/get_virtual_hardware_section.rb', line 17

def get_virtual_hardware_section(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vApp/#{id}/virtualHardwareSection/"
  )
end

#get_vm(id) ⇒ Excon::Response

Note:

This should probably be deprecated.

Retrieve a vApp or VM.

Parameters:

  • id (String)

    Object identifier of the vApp or VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:



16
17
18
19
20
21
22
23
24
# File 'lib/fog/vcloud_director/requests/compute/get_vm.rb', line 16

def get_vm(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::Parsers::Compute::VcloudDirector::Vm.new,
    :path       => "vApp/#{id}"
  )
end

#get_vm_capabilities(id) ⇒ Excon::Response

Gets capabilities for the VM identified by id.

Parameters:

  • id (String)

    Object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

    • :href<~String> - The URI of the entity.

    • :type<~String> - The MIME type of the entity.

    • :MemoryHotAddEnabled<~String> - True if the virtual machine supports addition of memory while powered on.

    • :CpuHotAddEnabled<~String> - True if the virtual machine supports addition of virtual CPUs while powered on.

See Also:



18
19
20
21
22
23
24
25
26
# File 'lib/fog/vcloud_director/requests/compute/get_vm_capabilities.rb', line 18

def get_vm_capabilities(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vApp/#{id}/vmCapabilities"
  )
end

#get_vm_compliance_results(id) ⇒ Excon::Response

Retrieve the results of a compliance check.

Parameters:

  • id (String)

    Object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:



12
13
14
15
16
17
18
19
20
# File 'lib/fog/vcloud_director/requests/compute/get_vm_compliance_results.rb', line 12

def get_vm_compliance_results(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vApp/#{id}/complianceResult"
  )
end

#get_vm_customization(id) ⇒ Excon::Response

TODO:

Log deprecation warning.

Retrieves the guest customization section of a VM.

Parameters:

  • id (String)

    Object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.0



19
20
21
22
23
24
25
26
27
# File 'lib/fog/vcloud_director/requests/compute/get_vm_customization.rb', line 19

def get_vm_customization(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::Parsers::Compute::VcloudDirector::VmCustomization.new,
    :path       => "vApp/#{id}/guestCustomizationSection"
  )
end

#get_vm_disks(id) ⇒ Excon::Response

Deprecated.
TODO:

Log deprecation warning.

Retrieve all RASD items that specify hard disk and hard disk controller properties of a VM.

Parameters:

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



19
20
21
22
23
24
25
26
27
# File 'lib/fog/vcloud_director/requests/compute/get_vm_disks.rb', line 19

def get_vm_disks(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::Parsers::Compute::VcloudDirector::Disks.new,
    :path       => "vApp/#{id}/virtualHardwareSection/disks"
  )
end

#get_vm_network(id) ⇒ Excon::Response

TODO:

Log deprecation warning.

Retrieve the network connection section of a VM.

Parameters:

  • id (String)

    Object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



19
20
21
22
23
24
25
26
27
# File 'lib/fog/vcloud_director/requests/compute/get_vm_network.rb', line 19

def get_vm_network(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::Parsers::Compute::VcloudDirector::VmNetwork.new,
    :path       => "vApp/#{id}/networkConnectionSection/"
  )
end

#get_vm_pending_question(id) ⇒ Excon::Response

Retrieve a question being asked by a VM.

Parameters:

  • id (String)

    Object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

      • :href<~String> - The URI of the entity.

      • :type<~String> - The MIME type of the entity.

      • :Question<~String> - Question text.

      • :QuestionId<~String> - Question ID of this question.

      • Choices<~Array<Hash>>:

        • Id<~String> - Choice ID of the answer.

        • Text<~String> - Answer text.

See Also:

Since:

  • vCloud API version 0.9



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fog/vcloud_director/requests/compute/get_vm_pending_question.rb', line 20

def get_vm_pending_question(id)
  response = request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "vApp/#{id}/question"
  )
  ensure_list! response.body, :Choices
  response
end

#get_vms(id) ⇒ Excon::Response

Note:

This should probably be deprecated.

Retrieve a vApp or VM.

Parameters:

  • id (String)

    Object identifier of the vApp or VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:



16
17
18
19
20
21
22
23
24
# File 'lib/fog/vcloud_director/requests/compute/get_vms.rb', line 16

def get_vms(id)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::Parsers::Compute::VcloudDirector::Vms.new,
    :path       => "vApp/#{id}"
  )
end

#get_vms_by_metadata(key, value) ⇒ Object

See Also:

  • #get_vms_in_lease_by_query


8
9
10
11
12
13
14
15
16
# File 'lib/fog/vcloud_director/requests/compute/get_vms_by_metadata.rb', line 8

def (key,value)
  request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::Parsers::Compute::VcloudDirector::VmsByMetadata.new,
    :path       => "vms/query?format=records&filter=metadata:#{key}==STRING:#{value}"
  )
end

#get_vms_disk_attached_to(id) ⇒ Excon::Response

Retrieve a list of all VMs attached to a disk.

Parameters:

  • id (String)

    Object identifier of the disk.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 5.1



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fog/vcloud_director/requests/compute/get_vms_disk_attached_to.rb', line 13

def get_vms_disk_attached_to(id)
  response = request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => "disk/#{id}/attachedVms"
  )
  ensure_list! response.body, :VmReference
  response
end

#get_vms_in_lease_from_query(options = {}) ⇒ Excon::Response

Retrieves a list of VMs in lease by using REST API general QueryHandler.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :sortAsc (String) — default: Sorted by database ID

    Sort results by attribute-name in ascending order. attribute-name cannot include metadata.

  • :sortDesc (String) — default: Sorted by database ID

    Sort results by attribute-name in descending order. attribute-name cannot include metadata.

  • :page (Integer) — default: 1

    If the query results span multiple pages, return this page.

  • :pageSize (Integer) — default: 25

    Number of results per page, to a maximum of 128.

  • :format (String) — default: records

    One of the following types:

    • references Returns a reference to each object, including its :name, :type, and :href attributes.

    • records Returns all database records for each object, with each record as an attribute.

    • idrecords Identical to the records format, except that object references are returned in :id format rather than :href format.

  • :fields (Array<String>) — default: all static attribute names

    List of attribute names or metadata key names to return.

  • :offset (Integer) — default: 0

    Integer value specifying the first record to return. Record numbers < offset are not returned.

  • :filter (String) — default: none

    Filter expression.

Returns:

  • (Excon::Response)
    • hash<~Hash>:

      • :href<~String> - The URI of the entity.

      • :type<~String> - The MIME type of the entity.

      • :name<~String> - Query name that generated this result set.

      • :page<~String> - Page of the result set that this container holds. The first page is page number 1.

      • :pageSize<~String> - Page size, as a number of records or references.

      • :total<~String> - Total number of records or references in the container.

      • :Link<~Array<Hash>>:

        • :href<~String> - Contains the URI to the entity.

        • :type<~String> - Contains the type of the entity.

        • :rel<~String> - Defines the relationship of the link to the object that contains it.

      • :VMRecord<~Array<Hash>>:

        • TODO

      • :firstPage<~Integer> - First page in the result set.

      • :previousPage<~Integer> - Previous page in the result set.

      • :nextPage<~Integer> - Next page in the result set.

      • :lastPage<~Integer> - Last page in the result set.

See Also:

Since:

  • vCloud API version 1.5



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/fog/vcloud_director/requests/compute/get_vms_in_lease_from_query.rb', line 57

def get_vms_in_lease_from_query(options={})
  query = []
  query << "sortAsc=#{options[:sortAsc]}" if options[:sortAsc]
  query << "sortDesc=#{options[:sortDesc]}" if options[:sortDesc]
  query << "page=#{options[:page]}" if options[:page]
  query << "pageSize=#{options[:pageSize]}" if options[:pageSize]
  query << "format=#{options[:format]}" if options[:format]
  query << "fields=#{Array(options[:fields]).join(',')}" if options[:fields]
  query << "offset=#{options[:offset]}" if options[:offset]
  query << "filter=#{options[:filter]}" if options[:filter]

  response = request(
    :expects    => 200,
    :idempotent => true,
    :method     => 'GET',
    :parser     => Fog::ToHashDocument.new,
    :path       => 'vms/query',
    :query      => query.map {|q| URI.escape(q)}.join('&')
  )
  ensure_list! response.body, :Link
  ensure_list! response.body,
    response.body[:type] == 'application/vnd.vmware.vcloud.query.references+xml' ?
      :VMReference : :VMRecord

  %w[firstPage previousPage nextPage lastPage].each do |rel|
    if link = response.body[:Link].detect {|l| l[:rel] == rel}
      href = Nokogiri::XML.fragment(link[:href])
      query = CGI.parse(URI.parse(href.text).query)
      response.body[rel.to_sym] = query['page'].first.to_i
      response.body[:pageSize] ||= query['pageSize'].first.to_i
    end
  end

  response
end

#instantiate_vapp_template(vapp_name, template_id, options = {}) ⇒ Excon::Response

Create a vApp from a vApp template.

The response includes a Task element. You can monitor the task to to track the creation of the vApp.

Parameters:

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/fog/vcloud_director/requests/compute/instantiate_vapp_template.rb', line 18

def instantiate_vapp_template(vapp_name, template_id, options={})
  params = populate_uris(options.merge(:vapp_name => vapp_name, :template_id => template_id))

  # @todo Move all the logic to a generator.
  data = generate_instantiate_vapp_template_request(params)

  request(
    :body    => data,
    :expects => 201,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml'},
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vdc/#{params[:vdc_id]}/action/instantiateVAppTemplate"
  )
end

#make_task_object(task_response) ⇒ Object



415
416
417
418
# File 'lib/fog/vcloud_director/compute.rb', line 415

def make_task_object(task_response)
  task_response[:id] = task_response[:href].split('/').last
  tasks.new(task_response)
end

#org_nameObject



350
351
352
353
# File 'lib/fog/vcloud_director/compute.rb', line 350

def org_name
   if @org_name.nil?
  @org_name
end

#post_acquire_ticket(id) ⇒ Excon::Response

Retrieve a screen ticket that you can use with the VMRC browser plug-in to gain access to the console of a running VM.

Parameters:

  • id (String)

    Object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

Raises:

See Also:

Since:

  • vCloud API version 0.9



16
17
18
19
20
21
22
23
# File 'lib/fog/vcloud_director/requests/compute/post_acquire_ticket.rb', line 16

def post_acquire_ticket(id)
  request(
    :expects => 200,
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/screen/action/acquireTicket"
  )
end

#post_answer_pending_vm_question(id, choice_id, question_id) ⇒ Excon::Response

Answer a question being asked by a VM.

Parameters:

  • id (String)

    Object identifier of the VM.

  • choice_id (Integer)

    Choice ID of this answer.

  • question_id (String)

    Question ID of the question.

Returns:

  • (Excon::Response)

See Also:

Since:

  • vCloud API version 0.9



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/fog/vcloud_director/requests/compute/post_answer_vm_pending_question.rb', line 14

def post_answer_pending_vm_question(id, choice_id, question_id)
  body = Nokogiri::XML::Builder.new do
    attrs = {
      :xmlns => 'http://www.vmware.com/vcloud/v1.5'
    }
    VmAnswerQuestion(attrs) {
      ChoiceId choice_id
      QuestionId question_id
    }
  end.to_xml

  request(
    :body    => body,
    :expects => 204, # this might be wrong
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.vmPendingAnswer+xml'},
    :method  => 'POST',
    :path    => "vApp/#{id}/quesiton/action/answer"
  )
end

#post_attach_disk(id, disk_id, options = {}) ⇒ Excon::Response

Attach a disk to a VM.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the VM.

  • disk_id (String)

    Object identifier of the disk.

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :BusNumber (Integer)

    Bus number on which to place the disk controller. If empty or missing, the system assigns a bus number and a unit number on that bus.

  • :BusNumber (Integer)

    Unit number (slot) on the bus specified by :BusNumber. Ignored if :BusNumber is empty or missing.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 5.1



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fog/vcloud_director/requests/compute/post_attach_disk.rb', line 23

def post_attach_disk(id, disk_id, options={})
  body = Nokogiri::XML::Builder.new do
    attrs = {
      :xmlns => 'http://www.vmware.com/vcloud/v1.5'
    }
    DiskAttachOrDetachParams(attrs) {
      Disk(:href => "#{end_point}disk/#{disk_id}")
      if options.key?(:BusNumber)
        BusNumber options[:BusNumber]
      end
      if options.key?(:UnitNumber)
        BusNumber options[:UnitNumber]
      end
    }
  end.to_xml

  request(
    :body    => body,
    :expects => 202,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.diskAttachOrDetachParams+xml'},
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/disk/action/attach"
  )
end

#post_cancel_task(id) ⇒ Excon::Response

Cancel a task.

Parameters:

  • id (String)

    Object identifier of the task.

Returns:

  • (Excon::Response)

See Also:

Since:

  • vCloud API version 1.5



15
16
17
18
19
20
21
# File 'lib/fog/vcloud_director/requests/compute/post_cancel_task.rb', line 15

def post_cancel_task(id)
  request(
    :expects => 204,
    :method  => 'POST',
    :path    => "task/#{id}/action/cancel"
  )
end

#post_capture_vapp(vdc_id, name, source_id, options = {}) ⇒ Excon::Response

Create a vApp template from a vApp.

The response includes a Task element. You can monitor the task to to track the creation of the vApp template.

Parameters:

  • vdc_id (String)

    Object identifier of the vDC.

  • name (String)

    Name of the vApp template.

  • source_id (String)

    Object identifier of the vApp to capture.

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :Description (String)

    Optional description.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fog/vcloud_director/requests/compute/post_capture_vapp.rb', line 20

def post_capture_vapp(vdc_id, name, source_id, options={})
  body = Nokogiri::XML::Builder.new do
    attrs = {
      :xmlns => 'http://www.vmware.com/vcloud/v1.5',
      :name => name
    }
    CaptureVAppParams(attrs) {
      if options.key?(:Description)
        Description options[:Description]
      end
      Source(:href => "#{end_point}vApp/#{source_id}")
    }
  end.to_xml

  request(
    :body    => body,
    :expects => 201,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.captureVAppParams+xml'},
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vdc/#{vdc_id}/action/captureVApp"
  )
end

#post_check_vm_compliance(id) ⇒ Excon::Response

Perform storage profile compliance check on a VM.

This operation is asynchronous and return a task. When the task completes, the compliance check on the VM has been completed and the results can be retrieved.

Parameters:

  • id (String)

    Object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 5.1



17
18
19
20
21
22
23
24
# File 'lib/fog/vcloud_director/requests/compute/post_check_vm_compliance.rb', line 17

def post_check_vm_compliance(id)
  request(
    :expects => 202,
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/action/checkCompliance"
  )
end

#post_clone_media(vdc_id, source_id, options = {}) ⇒ Excon::Response

Create a copy of a media object.

The response includes a Task element. You can monitor the task to to track the creation of the vApp template.

Parameters:

  • vdc_id (String)

    Object identifier of the vDC.

  • source_id (String)

    Object identifier of the source media object.

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :Description (String)

    Optional description.

  • :IsSourceDelete (Boolean)

    A value of true deletes the Source object after successful completion of the copy operation. Defaults to false if empty or missing.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/fog/vcloud_director/requests/compute/post_clone_media.rb', line 23

def post_clone_media(vdc_id, source_id, options={})
  body = Nokogiri::XML::Builder.new do
    attrs = {
      :xmlns => 'http://www.vmware.com/vcloud/v1.5'
    }
    CloneMediaParams(attrs) {
      if options.key?(:Description)
        Description options[:Description]
      end
      Source(:href => "#{end_point}media/#{source_id}")
      if options.key?(:IsSourceDelete)
        IsSourceDelete options[:IsSourceDelete]
      end
    }
  end.to_xml

  response = request(
    :body    => body,
    :expects => 201,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.cloneMediaParams+xml'},
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vdc/#{vdc_id}/action/cloneMedia"
  )
  ensure_list! response.body, :Files, :File
  response
end

#post_clone_vapp(vdc_id, name, source_id, options = {}) ⇒ Excon::Response

Create a copy of a vApp.

The response includes a Task element. You can monitor the task to to track the creation of the vApp template.

Parameters:

  • vdc_id (String)

    Object identifier of the vDC.

  • name (String)

    Name of the new vApp.

  • source_id (String)

    Object identifier of the source vApp.

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :deploy (Boolean)

    True if the vApp should be deployed at instantiation. Defaults to true.

  • :powerOn (Boolean)

    True if the vApp should be powered-on at instantiation. Defaults to true.

  • :Description (String)

    Optional description.

  • :InstantiationParams (Hash)

    Instantiation parameters for the composed vApp.

  • :IsSourceDelete (Boolean)

    Set to true to delete the source object after the operation completes.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/fog/vcloud_director/requests/compute/post_clone_vapp.rb', line 28

def post_clone_vapp(vdc_id, name, source_id, options={})
  body = Nokogiri::XML::Builder.new do
    attrs = {
      :xmlns => 'http://www.vmware.com/vcloud/v1.5',
      :name => name
    }
    attrs[:deploy] = options[:deploy] if options.key?(:deploy)
    attrs[:powerOn] = options[:powerOn] if options.key?(:powerOn)
    CloneVAppParams(attrs) {
      if options.key?(:Description)
        Description options[:Description]
      end
      InstantiationParams {
        # TODO
      }
      Source(:href => "#{end_point}vApp/#{source_id}")
      if options.key?(:IsSourceDelete)
        IsSourceDelete options[:IsSourceDelete]
      end
    }
  end.to_xml

  request(
    :body    => body,
    :expects => 201,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.cloneVAppParams+xml'},
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vdc/#{vdc_id}/action/cloneVApp"
  )
end

#post_clone_vapp_template(vdc_id, name, source_id, options = {}) ⇒ Excon::Response

Create a copy of a vApp template.

The response includes a Task element. You can monitor the task to to track the creation of the vApp template.

Parameters:

  • vdc_id (String)

    Object identifier of the vDC.

  • name (String)

    Name of the new vApp template.

  • source_id (String)

    Object identifier of the source vApp template.

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :Description (String)

    Optional description.

  • :IsSourceDelete (Boolean)

    Set to true to delete the source object after the operation completes.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fog/vcloud_director/requests/compute/post_clone_vapp_template.rb', line 23

def post_clone_vapp_template(vdc_id, name, source_id, options={})
  body = Nokogiri::XML::Builder.new do
    attrs = {
      :xmlns => 'http://www.vmware.com/vcloud/v1.5',
      :name => name
    }
    CloneVAppTemplateParams(attrs) {
      if options.key?(:Description)
        Description options[:Description]
      end
      Source(:href => "#{end_point}vAppTemplate/#{source_id}")
      if options.key?(:IsSourceDelete)
        IsSourceDelete options[:IsSourceDelete]
      end
    }
  end.to_xml

  request(
    :body    => body,
    :expects => 201,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml'},
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vdc/#{vdc_id}/action/cloneVAppTemplate"
  )
end

#post_configure_edge_gateway_services(id, configuration) ⇒ Excon::Response

Configure edge gateway services like firewall, nat and load balancer.

The response includes a Task element. You can monitor the task to track the configuration of edge gateway services.

Parameters:

  • id (String)

    Object identifier of the edge gateway.

  • configuration (Hash)

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 5.1



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/vcloud_director/requests/compute/post_configure_edge_gateway_services.rb', line 23

def post_configure_edge_gateway_services(id, configuration)
  body = Fog::Generators::Compute::VcloudDirector::EdgeGatewayServiceConfiguration.new(configuration).generate_xml

  request(
      :body => body,
      :expects => 202,
      :headers => {'Content-Type' => 'application/vnd.vmware.admin.edgeGatewayServiceConfiguration+xml'},
      :method => 'POST',
      :parser => Fog::ToHashDocument.new,
      :path => "admin/edgeGateway/#{id}/action/configureServices"
  )
end

#post_consolidate_vm_vapp(id) ⇒ Excon::Response

Consolidate VM snapshots.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



16
17
18
19
20
21
22
23
# File 'lib/fog/vcloud_director/requests/compute/post_consolidate_vm_vapp.rb', line 16

def post_consolidate_vm_vapp(id)
  request(
    :expects => 202,
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/action/consolidate"
  )
end

#post_consolidate_vm_vapp_template(id) ⇒ Excon::Response

Consolidate VM snapshots.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



16
17
18
19
20
21
22
23
# File 'lib/fog/vcloud_director/requests/compute/post_consolidate_vm_vapp_template.rb', line 16

def post_consolidate_vm_vapp_template(id)
  request(
    :expects => 202,
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vAppTemplate/#{id}/action/consolidate"
  )
end

#post_create_org_vdc_network(vdc_id, name, options = {}) ⇒ Excon::Response

Create an Org vDC network.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Produce media type(s): application/vnd.vmware.vcloud.orgVdcNetwork+xml Output type: OrgVdcNetworkType

Parameters:

  • vdc_id (String)

    Object identifier of the vDC

  • name (String)

    The name of the entity.

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :Description (String)

    Optional description.

  • :Configuration (Hash)

    Network configuration.

  • :EdgeGateway (Hash)

    EdgeGateway that connects this Org vDC network. Applicable only for routed networks.

  • :ServiceConfig (Hash)

    Specifies the service configuration for an isolated Org vDC networks.

  • :IsShared (Boolean)

    True if this network is shared to multiple Org vDCs.

    • :Configuration<~Hash>: NetworkConfigurationType

      • :IpScopes<~Hash>:

        • :IpScope<~Hash>:

          • :IsInherited<~Boolean>: ?

          • :Gateway<~String>: IP address of gw

          • :Netmask<~String>: Subnet mask of network

          • :Dns1<~String>: Primary DNS server.

          • :Dns2<~String>: Secondary DNS server.

          • :DnsSuffix<~String>: DNS suffix.

          • :IsEnabled<~String>: Indicates if subnet is enabled or not.

            Default value is True.
            
          • :IpRanges<~Array>: IP ranges used for static pool allocation

            in the network. Array of Hashes of:
              * :StartAddress - start IP in range
              * :EndAddress - end IP in range
            
    • :EdgeGateway<~Hash>: EdgeGateway that connects this Org vDC

      network. Applicable only for routed networks.
      
    • :ServiceConfig<~Hash>: Specifies the service configuration for an

      isolated network
      

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 5.1



54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/fog/vcloud_director/requests/compute/post_create_org_vdc_network.rb', line 54

def post_create_org_vdc_network(vdc_id, name, options={})

  body = Fog::Generators::Compute::VcloudDirector::OrgVdcNetwork.new(options.merge(:name => name)).generate_xml

  request(
    :body    => body,
    :expects => 201,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.orgVdcNetwork+xml'},
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "admin/vdc/#{vdc_id}/networks"
  )

end

#post_deploy_vapp(id, options = {}) ⇒ Excon::Response

Deploy a vApp or VM.

Deployment allocates all resources for the vApp and the virtual machines it contains.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the vApp.

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :deploymentLeaseSeconds (Integer)

    Lease in seconds for deployment. A value of 0 is replaced by the organization default deploymentLeaseSeconds value.

  • :forceCustomization (Boolean)

    Used to specify whether to force customization on deployment, if not set default value is false.

  • :powerOn (Boolean)

    Used to specify whether to power on vApp on deployment, if not set default value is true.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fog/vcloud_director/requests/compute/post_deploy_vapp.rb', line 28

def post_deploy_vapp(id, options={})
  body = Nokogiri::XML::Builder.new do
    attrs = {
      :xmlns => 'http://www.vmware.com/vcloud/v1.5'
    }
    attr[:deploymentLeaseSeconds] = options[:deploymentLeaseSeconds] if options.key?(:deploymentLeaseSeconds)
    attr[:forceCustomization] = options[:forceCustomization] if options.key?(:forceCustomization)
    attr[:powerOn] = options[:powerOn] if options.key?(:powerOn)
    DeployVAppParams(attrs)
  end.to_xml

  request(
    :body    => body,
    :expects => 202,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.deployVAppParams+xml'},
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/action/deploy"
  )
end

#post_detach_disk(id, disk_id) ⇒ Excon::Response

Detach a disk from a VM.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the VM.

  • disk_id (String)

    Object identifier of the disk.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 5.1



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/vcloud_director/requests/compute/post_detach_disk.rb', line 17

def post_detach_disk(id, disk_id)
  body = Nokogiri::XML::Builder.new do
    attrs = {
      :xmlns => 'http://www.vmware.com/vcloud/v1.5'
    }
    DiskAttachOrDetachParams(attrs) {
      Disk(:href => "#{end_point}disk/#{disk_id}")
    }
  end.to_xml

  request(
    :body    => body,
    :expects => 202,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.diskAttachOrDetachParams+xml'},
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/disk/action/detach"
  )
end

#post_disable_nested_hv(id) ⇒ Excon::Response

Hide hardware-assisted CPU virtualization from guest OS.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 5.1



16
17
18
19
20
21
22
23
# File 'lib/fog/vcloud_director/requests/compute/post_disable_nested_hv.rb', line 16

def post_disable_nested_hv(id)
  request(
    :expects => 202,
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/action/disableNestedHypervisor"
  )
end

#post_disable_vapp_template_download(id) ⇒ Excon::Response

Disable a vApp template for download.

Parameters:

  • id (String)

    Object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



13
14
15
16
17
18
19
20
# File 'lib/fog/vcloud_director/requests/compute/post_disable_vapp_template_download.rb', line 13

def post_disable_vapp_template_download(id)
  request(
    :expects => 202,
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vAppTemplate/#{id}/action/disableDownload"
  )
end

#post_discard_vapp_state(id) ⇒ Excon::Response

Discard suspended state of a vApp or VM.

Discarding the suspended state of a vApp discards the suspended state of all VMs it contains.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the vApp or VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



19
20
21
22
23
24
25
26
# File 'lib/fog/vcloud_director/requests/compute/post_discard_vapp_state.rb', line 19

def post_discard_vapp_state(id)
  request(
    :expects => 202,
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/action/discardSuspendedState"
  )
end

#post_eject_cd_rom(id, media_id) ⇒ Excon::Response

Eject virtual media.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the VM.

  • media_id (String)

    Object identifier of the media object.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/vcloud_director/requests/compute/post_eject_cd_rom.rb', line 17

def post_eject_cd_rom(id, media_id)
  body = Nokogiri::XML::Builder.new do
    attrs = {
      :xmlns => 'http://www.vmware.com/vcloud/v1.5'
    }
    MediaInsertOrEjectParams(attrs) {
      Media(:href => "#{end_point}media/#{media_id}")
    }
  end.to_xml

  request(
    :body    => body,
    :expects => 202,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.mediaInsertOrEjectParams+xml'},
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/media/action/ejectMedia"
  )
end

#post_enable_nested_hv(id) ⇒ Excon::Response

Expose hardware-assisted CPU virtualization to guest OS.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 5.1



16
17
18
19
20
21
22
23
# File 'lib/fog/vcloud_director/requests/compute/post_enable_nested_hv.rb', line 16

def post_enable_nested_hv(id)
  request(
    :expects => 202,
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/action/enableNestedHypervisor"
  )
end

#post_enable_vapp_template_download(id) ⇒ Excon::Response

Enable a vApp template for download.

Parameters:

  • id (String)

    Object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



13
14
15
16
17
18
19
20
# File 'lib/fog/vcloud_director/requests/compute/post_enable_vapp_template_download.rb', line 13

def post_enable_vapp_template_download(id)
  request(
    :expects => 202,
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vAppTemplate/#{id}/action/enableDownload"
  )
end

#post_enter_maintenance_mode(id) ⇒ Excon::Response

Place the vApp in maintenance mode.

When a vApp is in maintenance mode, it is read-only to users. Only a system administrator can modify it. User-initiated tasks that are running when the vApp enters maintenance mode continue to run.

Parameters:

  • id (String)

    Object identifier of the vApp.

Returns:

  • (Excon::Response)

See Also:

Since:

  • vCloud API version 1.5



16
17
18
19
20
21
22
# File 'lib/fog/vcloud_director/requests/compute/post_enter_maintenance_mode.rb', line 16

def post_enter_maintenance_mode(id)
  request(
    :expects => 204,
    :method  => 'POST',
    :path    => "vApp/#{id}/action/enterMaintenanceMode"
  )
end

#post_exit_maintenance_mode(id) ⇒ Excon::Response

Take the vApp out of maintenance mode.

Parameters:

  • id (String)

    Object identifier of the vApp.

Returns:

  • (Excon::Response)

See Also:

Since:

  • vCloud API version 1.5



12
13
14
15
16
17
18
# File 'lib/fog/vcloud_director/requests/compute/post_exit_maintenance_mode.rb', line 12

def post_exit_maintenance_mode(id)
  request(
    :expects => 204,
    :method  => 'POST',
    :path    => "vApp/#{id}/action/exitMaintenanceMode"
  )
end

#post_insert_cd_rom(id, media_id) ⇒ Excon::Response

Insert virtual media.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the VM.

  • media_id (String)

    Object identifier of the media object.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/vcloud_director/requests/compute/post_insert_cd_rom.rb', line 17

def post_insert_cd_rom(id, media_id)
  body = Nokogiri::XML::Builder.new do
    attrs = {
      :xmlns => 'http://www.vmware.com/vcloud/v1.5'
    }
    MediaInsertOrEjectParams(attrs) {
      Media(:href => "#{end_point}media/#{media_id}")
    }
  end.to_xml

  request(
    :body    => body,
    :expects => 202,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.mediaInsertOrEjectParams+xml'},
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/media/action/insertMedia"
  )
end

#post_install_vmware_tools(id) ⇒ Excon::Response

Install VMware Tools on a running VM.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



16
17
18
19
20
21
22
23
# File 'lib/fog/vcloud_director/requests/compute/post_install_vmware_tools.rb', line 16

def post_install_vmware_tools(id)
  request(
    :expects => 202,
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/action/installVMwareTools"
  )
end

#post_instantiate_vapp_template(id, vapp_template_id, name, options = {}) ⇒ Excon::Response

Note:

This may not work at all or may work only under certain circumstances.

Create a vApp from a vApp template.

The response includes a Task element. You can monitor the task to to track the creation of the vApp.

Parameters:

  • id (String)

    Object identifier of the vDC.

  • vapp_template_id (String)

    Object identifier of the vApp template.

  • name (String)
  • options (Hash) (defaults to: {})

Options Hash (options):

  • :deploy (Boolean)

    True if the vApp should be deployed at instantiation. Defaults to true.

  • :powerOn (Boolean)

    True if the vApp should be powered-on at instantiation. Defaults to true.

  • :Description (String)

    Optional description.

  • :InstantiationParams (Hash)

    Instantiation parameters for the composed vApp.

    • :LeaseSettingsSection<~Hasn>:

      • :DeploymentLeaseTimeInSeconds<~Integer> - Deployment lease in seconds.

      • :StorageLeaseTimeInSeconds<~Integer> - Storage lease in seconds.

      • :DeploymentLeaseExpiration<~Integer> - Expiration date/time of deployment lease.

      • :StorageLeaseExpiration<~Integer> - Expiration date/time of storage lease.

    • :NetworkConfigSection<~Hash>:

      • :NetworkConfig<~Hash>:

        • :networkName<~String> - The name of the vApp network.

        • :Configuration<~Hash>:

          • :ParentNetwork<~Hash>:

            • :href<~String> -

          • :FenceMode<~String> - Isolation type of the network.

  • :IsSourceDelete (Boolean)

    Set to true to delete the source object after the operation completes.

  • :AllEULAsAccepted (Boolean)

    True confirms acceptance of all EULAs in a vApp template.

Returns:

  • (Excon::Response)
    • body<~Hash>:

Raises:

  • Fog::Compute::VcloudDirector::DuplicateName

See Also:

Since:

  • vCloud API version 0.9



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/fog/vcloud_director/requests/compute/post_instantiate_vapp_template.rb', line 52

def post_instantiate_vapp_template(id, vapp_template_id, name, options={})
  body = Nokogiri::XML::Builder.new do
    attrs = {
      'xmlns' => 'http://www.vmware.com/vcloud/v1.5',
      'xmlns:ovf' => 'http://schemas.dmtf.org/ovf/envelope/1',
      :name => name
    }
    attrs[:deploy] = options[:deploy] if options.key?(:deploy)
    attrs[:powerOn] = options[:powerOn] if options.key?(:powerOn)
    InstantiateVAppTemplateParams(attrs) {
      if options.key?(:Description)
        Description options[:Description]
      end
      if instantiation_params = options[:InstantiationParams]
        InstantiationParams {
          if section = instantiation_params[:LeaseSettingsSection]
            LeaseSettingsSection {
              self['ovf'].Info 'Lease settings section'
              if section.key?(:DeploymentLeaseInSeconds)
                DeploymentLeaseInSeconds section[:DeploymentLeaseInSeconds]
              end
              if section.key?(:StorageLeaseInSeconds)
                StorageLeaseInSeconds section[:StorageLeaseInSeconds]
              end
              if section.key?(:DeploymentLeaseExpiration)
                DeploymentLeaseExpiration section[:DeploymentLeaseExpiration].strftime('%Y-%m-%dT%H:%M:%S%z')
              end
              if section.key?(:StorageLeaseExpiration)
                StorageLeaseExpiration section[:StorageLeaseExpiration].strftime('%Y-%m-%dT%H:%M:%S%z')
              end
            }
          end
          if section = instantiation_params[:NetworkConfigSection]
            NetworkConfigSection {
              self['ovf'].Info 'Configuration parameters for logical networks'
              if network_configs = section[:NetworkConfig]
                network_configs = [network_configs] if network_configs.is_a?(Hash)
                network_configs.each do |network_config|
                  NetworkConfig(:networkName => network_config[:networkName]) {
                    if configuration = network_config[:Configuration]
                      Configuration {
                        ParentNetwork(configuration[:ParentNetwork])
                        FenceMode configuration[:FenceMode]
                      }
                    end
                  }
                end
              end
            }
          end
        }
      end
      Source(:href => "#{end_point}vAppTemplate/#{vapp_template_id}")
      if options.key?(:IsSourceDelete)
        IsSourceDelete options[:IsSourceDelete]
      end
      if options.key?(:AllEULAsAccepted)
        AllEULAsAccepted options[:AllEULAsAccepted]
      end
    }
  end.to_xml

  begin
    request(
      :body    => body,
      :expects => 201,
      :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml'},
      :method  => 'POST',
      :parser  => Fog::ToHashDocument.new,
      :path    => "vdc/#{id}/action/instantiateVAppTemplate"
    )
  rescue Fog::Compute::VcloudDirector::BadRequest => e
    if e.minor_error_code == 'DUPLICATE_NAME'
      raise Fog::Compute::VcloudDirector::DuplicateName.new(e.message)
    end
    raise
  end
end

#post_login_sessionExcon::Response

Log in and create a Session object.

Returns:

  • (Excon::Response)
    • body<~Hash>:

      • :href<~String> - The URI of the entity.

      • :type<~String> - The MIME type of the entity.

      • :org<~String> - The name of the user’s organization.

      • :user<~String> - The name of the user that owns the session

      • :Link<~Array<Hash>]:

        • :href<~String> - Contains the URI to the linked entity.

        • :name<~String> - Contains the name of the linked entity.

        • :type<~String> - Contains the type of the linked entity.

        • :rel<~String> - Defines the relationship of the link to the object that contains it.

See Also:

Since:

  • vCloud API version 1.5



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/vcloud_director/requests/compute/post_login_session.rb', line 22

def 
  headers = {
    'Accept' => "application/*+xml;version=#{@api_version}",
    'Authorization' => "Basic #{Base64.encode64("#{@vcloud_director_username}:#{@vcloud_director_password}").delete("\r\n")}"
  }

  @connection.request(
    :expects => 200,
    :headers => headers,
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "#{@path}/sessions"
  )
end

#post_power_off_vapp(id) ⇒ Excon::Response

Power off a vApp or VM.

If used on a vApp, powers off all VMs in the vApp. If used on a VM, powers off the VM. This operation is available only for a vApp or VM that is powered on.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the vApp or VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

Raises:

See Also:

Since:

  • vCloud API version 0.9



25
26
27
28
29
30
31
32
# File 'lib/fog/vcloud_director/requests/compute/post_power_off_vapp.rb', line 25

def post_power_off_vapp(id)
  request(
    :expects => 202,
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/power/action/powerOff"
  )
end

#post_power_on_vapp(id) ⇒ Excon::Response

 Power on a vApp or VM.

If used on a vApp, powers on all VMs in the vApp. If used on a VM, powers on the VM. This operation is available only for a vApp or VM that is powered off.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the vApp or VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

Raises:

See Also:

Since:

  • vCloud API version 0.9



25
26
27
28
29
30
31
32
# File 'lib/fog/vcloud_director/requests/compute/post_power_on_vapp.rb', line 25

def post_power_on_vapp(id)
  request(
    :expects => 202,
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/power/action/powerOn"
  )
end

#post_reboot_vapp(id) ⇒ Excon::Response

Reboot a vApp or VM.

If used on a vApp, reboots all VMs in the vApp. If used on a VM, reboots the VM. This operation is available only for a vApp or VM that is powered on.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the vApp or VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

Raises:

See Also:

Since:

  • vCloud API version 0.9



22
23
24
25
26
27
28
29
# File 'lib/fog/vcloud_director/requests/compute/post_reboot_vapp.rb', line 22

def post_reboot_vapp(id)
  request(
    :expects => 202,
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/power/action/reboot"
  )
end

#post_remove_all_snapshots(id) ⇒ Excon::Response

Removes all user created snapshots for a vApp or virtual machine.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the vApp or virtual machine.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 5.1



16
17
18
19
20
21
22
23
# File 'lib/fog/vcloud_director/requests/compute/post_remove_all_snapshots.rb', line 16

def post_remove_all_snapshots(id)
  request(
    :expects => 202,
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/action/removeAllSnapshots"
  )
end

#post_reset_vapp(id) ⇒ Excon::Response

Reset a vApp or VM.

If used on a vApp, resets all VMs in the vApp. If used on a VM, resets the VM. This operation is available only for a vApp or VM that is powered on.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the vApp or VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

Raises:

See Also:

Since:

  • vCloud API version 0.9



22
23
24
25
26
27
28
29
# File 'lib/fog/vcloud_director/requests/compute/post_reset_vapp.rb', line 22

def post_reset_vapp(id)
  request(
    :expects => 202,
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/power/action/reset"
  )
end

#post_revert_snapshot(id) ⇒ Excon::Response

Reverts a vApp or virtual machine to the current snapshot, if any.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the vApp or virtual machine.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 5.1



16
17
18
19
20
21
22
23
# File 'lib/fog/vcloud_director/requests/compute/post_revert_snapshot.rb', line 16

def post_revert_snapshot(id)
  request(
    :expects => 202,
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/action/revertToCurrentSnapshot"
  )
end

#post_shutdown_vapp(id) ⇒ Excon::Response

Shut down a vApp or VM.

If used on a vApp, shuts down all VMs in the vApp. If used on a VM, shuts down the VM. This operation is available only for a vApp or VM that is powered on.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the vApp or VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

Raises:

See Also:

Since:

  • vCloud API version 0.9



22
23
24
25
26
27
28
29
# File 'lib/fog/vcloud_director/requests/compute/post_shutdown_vapp.rb', line 22

def post_shutdown_vapp(id)
  request(
    :expects => 202,
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/power/action/shutdown"
  )
end

#post_suspend_vapp(id) ⇒ Excon::Response

Suspend a vApp or VM.

If used on a vApp, suspends all VMs in the vApp. If used on a VM, suspends the VM. This operation is available only for a vApp or VM that is powered on.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the vApp or VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

Raises:

See Also:

Since:

  • vCloud API version 0.9



22
23
24
25
26
27
28
29
# File 'lib/fog/vcloud_director/requests/compute/post_suspend_vapp.rb', line 22

def post_suspend_vapp(id)
  request(
    :expects => 202,
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/power/action/suspend"
  )
end

#post_undeploy_vapp(id, options = {}) ⇒ Excon::Response

Undeploy a vApp/VM.

Undeployment deallocates all resources used by the vApp and the VMs it contains.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the vApp.

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :UndeployPowerAction (String)

    The specified action is applied to all virtual machines in the vApp. All values other than default ignore actions, order, and delay specified in the StartupSection. One of:

    • powerOff (Power off the virtual machines. This is the default action if this attribute is missing or empty)

    • suspend (Suspend the virtual machines)

    • shutdown (Shut down the virtual machines)

    • force (Attempt to power off the virtual machines. Failures in undeploying the virtual machine or associated networks are ignored. All references to the vApp and its virtual machines are removed from the database)

    • default (Use the actions, order, and delay specified in the StartupSection).

Returns:

  • (Excon::Response)
    • body<~Hash>:

Raises:

See Also:

Since:

  • vCloud API version 0.9



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/fog/vcloud_director/requests/compute/post_undeploy_vapp.rb', line 36

def post_undeploy_vapp(id, options={})
  body = Nokogiri::XML::Builder.new do
    attrs = {
      :xmlns => 'http://www.vmware.com/vcloud/v1.5'
    }
    UndeployVAppParams(attrs) {
      if options[:UndeployPowerAction]
        UndeployPowerAction options[:UndeployPowerAction]
      end
    }
  end.to_xml

  request(
    :body    => body,
    :expects => 202,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.undeployVAppParams+xml'},
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/action/undeploy"
  )
end

#post_update_catalog_item_metadata(id, metadata = {}) ⇒ Excon::Response

Merge the metadata provided in the request with existing catalog item metadata.

Parameters:

  • id (String)

    Object identifier of the catalog item.

  • metadata (Hash{String=>Boolean,DateTime,Fixnum,String}) (defaults to: {})

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fog/vcloud_director/requests/compute/post_update_catalog_item_metadata.rb', line 14

def (id, ={})
  body = Nokogiri::XML::Builder.new do
    attrs = {
      :xmlns => 'http://www.vmware.com/vcloud/v1.5',
      'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance'
    }
    Metadata(attrs) {
      .each do |key, value|
        MetadataEntry {
          Key key
          if api_version.to_f < 5.1
            Value value
          else
            type = case value
                   when TrueClass, FalseClass then 'MetadataBooleanValue';
                   when DateTime then 'MetadataDateTimeValue';
                   when Fixnum then 'MetadataNumberValue';
                   else 'MetadataStringValue'
                   end
            TypedValue('xsi:type' => type) { Value value }
          end
        }
      end
    }
  end.to_xml

  request(
    :body    => body,
    :expects => 202,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.metadata+xml'},
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "catalogItem/#{id}/metadata/"
  )
end

#post_update_disk_metadata(id, metadata = {}) ⇒ Excon::Response

Merge the metadata provided in the request with existing metadata.

Parameters:

  • id (String)

    Object identifier of the disk.

  • metadata (Hash{String=>Boolean,DateTime,Fixnum,String}) (defaults to: {})

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 5.1



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fog/vcloud_director/requests/compute/post_update_disk_metadata.rb', line 14

def (id, ={})
  body = Nokogiri::XML::Builder.new do
    attrs = {
      :xmlns => 'http://www.vmware.com/vcloud/v1.5',
      'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance'
    }
    Metadata(attrs) {
      .each do |key, value|
        MetadataEntry {
          Key key
          if api_version.to_f < 5.1
            Value value
          else
            type = case value
                   when TrueClass, FalseClass then 'MetadataBooleanValue';
                   when DateTime then 'MetadataDateTimeValue';
                   when Fixnum then 'MetadataNumberValue';
                   else 'MetadataStringValue'
                   end
            TypedValue('xsi:type' => type) { Value value }
          end
        }
      end
    }
  end.to_xml

  request(
    :body    => body,
    :expects => 202,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.metadata+xml'},
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "disk/#{id}/metadata/"
  )
end

#post_update_media_metadata(id, metadata = {}) ⇒ Excon::Response

Merge the metadata provided in the request with existing metadata.

Parameters:

  • id (String)

    Object identifier of the media object.

  • metadata (Hash{String=>Boolean,DateTime,Fixnum,String}) (defaults to: {})

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fog/vcloud_director/requests/compute/post_update_media_metadata.rb', line 14

def (id, ={})
  body = Nokogiri::XML::Builder.new do
    attrs = {
      :xmlns => 'http://www.vmware.com/vcloud/v1.5',
      'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance'
    }
    Metadata(attrs) {
      .each do |key, value|
        MetadataEntry {
          Key key
          if api_version.to_f < 5.1
            Value value
          else
            type = case value
                   when TrueClass, FalseClass then 'MetadataBooleanValue';
                   when DateTime then 'MetadataDateTimeValue';
                   when Fixnum then 'MetadataNumberValue';
                   else 'MetadataStringValue'
                   end
            TypedValue('xsi:type' => type) { Value value }
          end
        }
      end
    }
  end.to_xml

  request(
    :body    => body,
    :expects => 202,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.metadata+xml'},
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "media/#{id}/metadata/"
  )
end

#post_update_vapp_metadata(id, metadata = {}) ⇒ Excon::Response

Merge the metadata provided in the request with existing metadata.

Parameters:

  • id (String)

    Object identifier of the vApp or VM.

  • metadata (Hash{String=>Boolean,DateTime,Fixnum,String}) (defaults to: {})

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fog/vcloud_director/requests/compute/post_update_vapp_metadata.rb', line 14

def (id, ={})
  body = Nokogiri::XML::Builder.new do
    attrs = {
      :xmlns => 'http://www.vmware.com/vcloud/v1.5',
      'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance'
    }
    Metadata(attrs) {
      .each do |key, value|
        MetadataEntry {
          Key key
          if api_version.to_f < 5.1
            Value value
          else
            type = case value
                   when TrueClass, FalseClass then 'MetadataBooleanValue';
                   when DateTime then 'MetadataDateTimeValue';
                   when Fixnum then 'MetadataNumberValue';
                   else 'MetadataStringValue'
                   end
            TypedValue('xsi:type' => type) { Value value }
          end
        }
      end
    }
  end.to_xml

  request(
    :body    => body,
    :expects => 202,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.metadata+xml'},
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/metadata/"
  )
end

#post_update_vapp_template_metadata(id, metadata = {}) ⇒ Excon::Response

Merge the metadata provided in the request with existing metadata.

Parameters:

  • id (String)

    Object identifier of the vApp template.

  • metadata (Hash{String=>Boolean,DateTime,Fixnum,String}) (defaults to: {})

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fog/vcloud_director/requests/compute/post_update_vapp_template_metadata.rb', line 14

def (id, ={})
  body = Nokogiri::XML::Builder.new do
    attrs = {
      :xmlns => 'http://www.vmware.com/vcloud/v1.5',
      'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance'
    }
    Metadata(attrs) {
      .each do |key, value|
        MetadataEntry {
          Key key
          if api_version.to_f < 5.1
            Value value
          else
            type = case value
                   when TrueClass, FalseClass then 'MetadataBooleanValue';
                   when DateTime then 'MetadataDateTimeValue';
                   when Fixnum then 'MetadataNumberValue';
                   else 'MetadataStringValue'
                   end
            TypedValue('xsi:type' => type) { Value value }
          end
        }
      end
    }
  end.to_xml

  request(
    :body    => body,
    :expects => 202,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.metadata+xml'},
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vAppTemplate/#{id}/metadata/"
  )
end

#post_upgrade_hw_version(id) ⇒ Excon::Response

Upgrade the virtual hardware version of a VM to the highest supported virtual hardware version of the vDC that contains it.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the VM.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 5.1



17
18
19
20
21
22
23
24
# File 'lib/fog/vcloud_director/requests/compute/post_upgrade_hw_version.rb', line 17

def post_upgrade_hw_version(id)
  request(
    :expects => 202,
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/action/upgradeHardwareVersion"
  )
end

#post_upload_disk(id, name, size, options = {}) ⇒ Excon::Response

Create a disk.

Parameters:

  • id (String)

    Object identifier of the vDC.

  • name (String)

    The name of the disk.

  • size (Integer)

    Size of the disk. For modify operation this is required only for the XSD validation it could not be changed.

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :operationKey (String)

    Optional unique identifier to support idempotent semantics for create and delete operations.

  • :busSubType (Integer)

    Disk bus sub type.

  • :busType (Integer)

    Disk bus type.

  • :Description (String)

    Optional description.

Returns:

  • (Excon::Response)
    • body<~Hash>:

      • :href<~String> - The URI of the disk.

      • :type<~String> - The MIME type of the disk.

      • :id<~String> - The disk identifier, expressed in URN format.

      • :operationKey<~String> - Optional unique identifier to support idempotent semantics for create and delete operations.

      • :name<~String> - The name of the disk.

      • :status<~String> - Creation status of the disk.

      • :busSubType<~String> - Disk bus sub type.

      • :busType<~String> - Disk bus type.

      • :size<~String> - Size of the disk.

      • :Link:

      • :Description<~String> - Optional description.

      • :Tasks<~Hash>:

      • :StorageProfile<~Hash> - Storage profile of the disk.

        • :href<~String> - Contains the URI to the entity.

        • :name<~String> - Contains the name of the entity.

        • :type<~String> - Contains the type of the entity.

      • :Owner<~Hash> - Disk owner.

        • :type<~String> - The MIME type of the entity.

        • :User<~Hash> - Reference to the user who is the owner of this disk.

          • :href<~String> - Contains the URI to the entity.

          • :name<~String> - Contains the name of the entity.

          • :type<~String> - Contains the type of the entity.

See Also:

Since:

  • vCloud API version 5.1



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/fog/vcloud_director/requests/compute/post_upload_disk.rb', line 46

def post_upload_disk(id, name, size, options={})
  body = Nokogiri::XML::Builder.new do
    DiskCreateParams(:xmlns => 'http://www.vmware.com/vcloud/v1.5') {
      attrs = {
        :name => name,
        :size => size
      }
      attrs[:operationKey] = options[:operationKey] if options.key?(:operationKey)
      attrs[:busSubType] = options[:busSubType] if options.key?(:busSubType)
      attrs[:busType] = options[:busType] if options.key?(:busType)
      Disk(attrs) {
        if options.key?(:Description)
          Description options[:Description]
        end
        if options.key?(:StorageProfile)
          attrs = {
            :href => options[:StorageProfile][:href]
          }
          StorageProfile(attrs)
        end
      }
    }
  end.to_xml

  request(
    :body    => body,
    :expects => 201,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.diskCreateParams+xml'},
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vdc/#{id}/disk"
  )
end

#post_upload_media(vdc_id, name, image_type, size, options = {}) ⇒ Excon::Response

TODO:

Support vDC Storage Profiles.

Upload a media image.

The response includes an upload link for the media image.

Parameters:

  • vdc_id (String)

    Object identifier of the vDC.

  • name (String)

    The name of the media image.

  • image_type (String)

    Media image type. One of: iso, floppy.

  • size (Integer)

    Size of the media file, in bytes.

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :operationKey (String)

    Optional unique identifier to support idempotent semantics for create and delete operations.

  • :Description (String)

    Optional description.

Returns:

  • (Excon::Response)
    • body<~Hash>:

Raises:

See Also:

Since:

  • vCloud API version 0.9



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fog/vcloud_director/requests/compute/post_upload_media.rb', line 26

def post_upload_media(vdc_id, name, image_type, size, options={})
  body = Nokogiri::XML::Builder.new do
    attrs = {
      :xmlns => 'http://www.vmware.com/vcloud/v1.5',
      :name => name,
      :imageType => image_type,
      :size => size
    }
    attrs[:operationKey] = options[:operationKey] if options.key?(:operationKey)
    Media(attrs) {
      if options.key?(:Description)
        Description options[:Description]
      end
    }
  end.to_xml

  response = request(
    :body    => body,
    :expects => 201,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.media+xml'},
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vdc/#{vdc_id}/media"
  )
  ensure_list! response.body, :Files, :File
  response
end

#post_upload_vapp_template(vdc_id, name, options = {}) ⇒ Excon::Response

Upload an OVF package to create a vApp template

The response includes an upload link for the OVF descriptor.

Parameters:

  • vdc_id (String)

    Object identifier of the vDC.

  • name (String)

    The name of the vApp template.

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :manifestRequired (Boolean)

    True if an OVF manifest is included in the upload. Default value is false.

  • :Description (String)

    Optional description.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fog/vcloud_director/requests/compute/post_upload_vapp_template.rb', line 20

def post_upload_vapp_template(vdc_id, name, options={})
  body = Nokogiri::XML::Builder.new do
    attrs = {
      :xmlns => 'http://www.vmware.com/vcloud/v1.5',
      :name => name
    }
    attrs[:manifestRequired] = options[:manifestRequired] if options.key?(:manifestRequired)
    UploadVAppTemplateParams(attrs) {
      if options.key?(:Description)
        Description options[:Description]
      end
    }
  end.to_xml

  request(
    :body    => body,
    :expects => 201,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.vAppTemplateParams+xml'},
    :method  => 'POST',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vdc/#{vdc_id}/action/uploadVAppTemplate"
  )
end

#process_task(response_body) ⇒ Object



409
410
411
412
413
# File 'lib/fog/vcloud_director/compute.rb', line 409

def process_task(response_body)
  task = make_task_object(response_body)
  wait_and_raise_unless_success(task)
  true
end

#put_catalog_item_metadata_item_metadata(id, key, value) ⇒ Excon::Response

Set the metadata value for the specified key to the value provided, overwriting any existing value.

Parameters:

  • id (String)

    Object identifier of the catalog item.

  • key (String)

    Key of the metadata item.

  • value (Boolean, DateTime, Fixnum, String)

    Value of the metadata item.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/fog/vcloud_director/requests/compute/put_catalog_item_metadata_item_metadata.rb', line 17

def (id, key, value)
  body = Nokogiri::XML::Builder.new do
    attrs = {
      :xmlns => 'http://www.vmware.com/vcloud/v1.5',
      'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance'
    }
    MetadataValue(attrs) {
      if api_version.to_f < 5.1
        Value value
      else
        type = case value
               when TrueClass, FalseClass then 'MetadataBooleanValue';
               when DateTime then 'MetadataDateTimeValue';
               when Fixnum then 'MetadataNumberValue';
               else 'MetadataStringValue'
               end
        TypedValue('xsi:type' => type) { Value value }
      end
    }
  end.to_xml

  request(
    :body    => body,
    :expects => 202,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.metadata.value+xml'},
    :method  => 'PUT',
    :parser  => Fog::ToHashDocument.new,
    :path    => "catalogItem/#{id}/metadata/#{URI.escape(key)}"
  )
end

#put_cpu(id, num_cpus) ⇒ Excon:Response

Update the RASD item that specifies CPU properties of a VM.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the VM.

  • num_cpus (Integer)

Returns:

  • (Excon:Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fog/vcloud_director/requests/compute/put_cpu.rb', line 20

def put_cpu(id, num_cpus)
  data = <<EOF
  <Item xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns12="http://www.vmware.com/vcloud/v1.5" ns12:href="#{end_point}vApp/#{id}/virtualHardwareSection/cpu" ns12:type="application/vnd.vmware.vcloud.rasdItem+xml" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://10.194.1.65/api/v1.5/schema/master.xsd http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.22.0/CIM_ResourceAllocationSettingData.xsd">
    <rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
    <rasd:Description>Number of Virtual CPUs</rasd:Description>
    <rasd:ElementName>#{num_cpus} virtual CPU(s)</rasd:ElementName>
    <rasd:InstanceID>4</rasd:InstanceID>
    <rasd:Reservation>0</rasd:Reservation>
    <rasd:ResourceType>3</rasd:ResourceType>
    <rasd:VirtualQuantity>#{num_cpus}</rasd:VirtualQuantity>
    <rasd:Weight>0</rasd:Weight>
    <Link rel="edit" type="application/vnd.vmware.vcloud.rasdItem+xml" href="#{end_point}vApp/#{id}/virtualHardwareSection/cpu"/>
  </Item>
EOF

  request(
    :body    => data,
    :expects => 202,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.rasdItem+xml'},
    :method  => 'PUT',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/virtualHardwareSection/cpu"
  )
end

#put_disk_metadata_item_metadata(id, key, value) ⇒ Excon::Response

Set the value for the specified metadata key to the value provided, overwriting any existing value.

Parameters:

  • id (String)

    Object identifier of the disk.

  • key (String)

    Key of the metadata item.

  • value (Boolean, DateTime, Fixnum, String)

    Value of the metadata item.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 5.1



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fog/vcloud_director/requests/compute/put_disk_metadata_item_metadata.rb', line 17

def (id, key, value)
  body = Nokogiri::XML::Builder.new do
    attrs = {
      :xmlns => 'http://www.vmware.com/vcloud/v1.5',
      'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance'
    }
    MetadataValue(attrs) {
      type = case value
             when TrueClass, FalseClass then 'MetadataBooleanValue';
             when DateTime then 'MetadataDateTimeValue';
             when Fixnum then 'MetadataNumberValue';
             else 'MetadataStringValue'
             end
      TypedValue('xsi:type' => type) { Value value }
    }
  end.to_xml

  request(
    :body    => body,
    :expects => 202,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.metadata.value+xml'},
    :method  => 'PUT',
    :parser  => Fog::ToHashDocument.new,
    :path    => "disk/#{id}/metadata/#{URI.escape(key)}"
  )
end

#put_disks(id, disks = []) ⇒ Excon::Response

Update all RASD items that specify hard disk and hard disk controller properties of a VM.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the VM.

  • disks (Array) (defaults to: [])
    • disks is the body of #get_vm_disks

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/vcloud_director/requests/compute/put_disks.rb', line 24

def put_disks(id, disks=[])
  data = Fog::Generators::Compute::VcloudDirector::Disks.new(disks)

  request(
    :body    => data.generate_xml,
    :expects => 202,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.rasdItemsList+xml'},
    :method  => 'PUT',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/virtualHardwareSection/disks"
  )
end

#put_guest_customization_section_vapp(id, options = {}) ⇒ Excon::Response

Updates the guest customization section of a VM.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the VM.

  • options (Hash) (defaults to: {})
  • customization (Hash)

    a customizable set of options

Options Hash (options):

  • :Enabled (Boolean)

    True if guest customization is enabled.

  • :ChangeSid (Boolean)

    True if customization can change the Windows SID of this virtual machine.

  • :JoinDomainEnabled (Boolean)

    True if this virtual machine can join a Windows Domain.

  • :UseOrgSettings (Boolean)

    True if customization should use organization settings (OrgGuestPersonalizationSettings) when joining a Windows Domain.

  • :DomainName (String)

    The name of the Windows Domain to join.

  • :DomainUserName (String)

    User name to specify when joining a Windows Domain.

  • :DomainUserPassword (String)

    Password to use with :DomainUserName.

  • :MachineObjectOU (String)

    The name of the Windows Domain Organizational Unit (OU) in which the computer account for this virtual machine will be created.

  • :AdminPassword_enabled (Boolean)

    True if guest customization can modify administrator password settings for this virtual machine.

  • :AdminPassword_auto (Boolean)

    True if the administrator password for this virtual machine should be automatically generated.

  • :AdminPassword (String)

    True if the administrator password for this virtual machine should be set to this string. (:AdminPasswordAuto must be false.)

  • :ResetPasswordRequired (Boolean)

    True if the administrator password for this virtual machine must be reset after first use.

Returns:

  • (Excon::Response)
    • body<~Hash>:

      • :Tasks<~Hash>:

        • :Task<~Hash>:

See Also:

Since:

  • vCloud API version 1.0



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/fog/vcloud_director/requests/compute/put_guest_customization_section_vapp.rb', line 56

def put_guest_customization_section_vapp(id, options={})
  options = options.dup

  # Mutate options to new format.
  deprecated = {
    :enabled => :Enabled,
    :change_sid => :ChangeSid,
    :join_domain_enabled => :JoinDomainEnabled,
    :use_org_settings => :UseOrgSettings,
    :admin_password => :AdminPassword,
    :admin_password_enabled => :AdminPasswordEnabled,
    :admin_password_auto => :AdminPasswordAuto,
    :reset_password_required => :ResetPasswordRequired,
    :customization_script => :CustomizationScript,
    :computer_name => :ComputerName
  }
  deprecated.each do |from, to|
    options[to] = options.delete(from) if options.key?(from)
  end

  body = Nokogiri::XML::Builder.new do
    attrs = {
      :xmlns => 'http://www.vmware.com/vcloud/v1.5',
      'xmlns:ovf' => 'http://schemas.dmtf.org/ovf/envelope/1'
    }
    GuestCustomizationSection(attrs) {
      self['ovf'].Info 'Specifies Guest OS Customization Settings'
      if options.key?(:Enabled)
        Enabled options[:Enabled]
      end
      if options.key?(:ChangeSid)
        ChangeSid options[:ChangeSid]
      end
      if options.key?(:JoinDomainEnabled)
        JoinDomainEnabled options[:JoinDomainEnabled]
      end
      if options.key?(:UseOrgSettings)
        UseOrgSettings options[:UseOrgSettings]
      end
      if options.key?(:DomainName)
        DomainName options[:DomainName]
      end
      if options.key?(:DomainUser)
        DomainUser options[:DomainUser]
      end
      if options.key?(:DomainUserPassword)
        DomainUserPassword options[:DomainUserPassword]
      end
      if options.key?(:MachineObjectOU)
        MachineObjectOU options[:MachineObjectOU]
      end
      if options.key?(:AdminPasswordEnabled)
        AdminPasswordEnabled options[:AdminPasswordEnabled]
      end
      if options.key?(:AdminPasswordAuto)
        AdminPasswordAuto options[:AdminPasswordAuto]
      end
      if options.key?(:AdminPassword)
        AdminPassword options[:AdminPassword]
      end
      if options.key?(:ResetPasswordRequired)
        ResetPasswordRequired options[:ResetPasswordRequired]
      end
      if options.key?(:CustomizationScript)
        CustomizationScript options[:CustomizationScript]
      end
      if options.key?(:ComputerName)
        ComputerName options[:ComputerName]
      end
    }
  end.to_xml

  request(
    :body    => body,
    :expects => 202,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.guestCustomizationSection+xml'},
    :method  => 'PUT',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/guestCustomizationSection"
  )
end

#put_media_metadata_item_metadata(id, key, value) ⇒ Excon::Response

Set the value for the specified metadata key to the value provided, overwriting any existing value.

Parameters:

  • id (String)

    Object identifier of the media object.

  • key (String)

    Key of the metadata item.

  • value (Boolean, DateTime, Fixnum, String)

    Value of the metadata item.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/fog/vcloud_director/requests/compute/put_media_metadata_item_metadata.rb', line 17

def (id, key, value)
  body = Nokogiri::XML::Builder.new do
    attrs = {
      :xmlns => 'http://www.vmware.com/vcloud/v1.5',
      'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance'
    }
    MetadataValue(attrs) {
      if api_version.to_f < 5.1
        Value value
      else
        type = case value
               when TrueClass, FalseClass then 'MetadataBooleanValue';
               when DateTime then 'MetadataDateTimeValue';
               when Fixnum then 'MetadataNumberValue';
               else 'MetadataStringValue'
               end
        TypedValue('xsi:type' => type) { Value value }
      end
    }
  end.to_xml

  request(
    :body    => body,
    :expects => 202,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.metadata.value+xml'},
    :method  => 'PUT',
    :parser  => Fog::ToHashDocument.new,
    :path    => "media/#{id}/metadata/#{URI.escape(key)}"
  )
end

#put_memory(id, memory) ⇒ Excon::Response

Update the RASD item that specifies memory properties of a VM.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the VM.

  • memory (Integer)

    Memory size in Megabytes.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fog/vcloud_director/requests/compute/put_memory.rb', line 20

def put_memory(id, memory)
  data = <<EOF
  <Item xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns12="http://www.vmware.com/vcloud/v1.5" ns12:href="#{end_point}vApp/#{id}/virtualHardwareSection/memory" ns12:type="application/vnd.vmware.vcloud.rasdItem+xml" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://10.194.1.65/api/v1.5/schema/master.xsd http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.22.0/CIM_ResourceAllocationSettingData.xsd">
    <rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
    <rasd:Description>Memory Size</rasd:Description>
    <rasd:ElementName>#{memory} MB of memory</rasd:ElementName>
    <rasd:InstanceID>5</rasd:InstanceID>
    <rasd:Reservation>0</rasd:Reservation>
    <rasd:ResourceType>4</rasd:ResourceType>
    <rasd:VirtualQuantity>#{memory}</rasd:VirtualQuantity>
    <rasd:Weight>0</rasd:Weight>
    <Link rel="edit" type="application/vnd.vmware.vcloud.rasdItem+xml" href="#{end_point}vApp/#{id}/virtualHardwareSection/memory"/>
  </Item>
EOF

  request(
    :body    => data,
    :expects => 202,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.rasdItem+xml'},
    :method  => 'PUT',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/virtualHardwareSection/memory"
  )
end

#put_metadata_value(vm_id, metadata_key, metadata_value) ⇒ Object

deprecated Use #put_vapp_metadata_item_metadata instead.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fog/vcloud_director/requests/compute/put_metadata_value.rb', line 6

def (vm_id, , )
  Fog::Logger.deprecation("#{self} => ##{} is deprecated, use ##{} instead [light_black](#{caller.first})[/]")

  body="
  <MetadataValue xmlns=\"http://www.vmware.com/vcloud/v1.5\">
      <Value>#{}</Value>
   </MetadataValue>"

  request(
    :body    => body,
    :expects => 202,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.metadata.value+xml'},
    :method  => 'PUT',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{vm_id}/metadata/#{URI.escape()}"
  )
end

#put_network_connection_system_section_vapp(id, options = {}) ⇒ Excon::Response

Update the network connection section of a VM.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the VM.

  • options (Hash) (defaults to: {})

    Container for the network connections of this virtual machine.

Options Hash (options):

  • :PrimaryNetworkConnectionIndex (Integer) — default: 0

    Virtual slot number associated with the NIC that should be considered this virtual machine’s primary network connection. Defaults to slot 0.

  • :NetworkConnection (Array<Hash>)
    • :needsCustomization<~Boolean> - True if this NIC needs customization.

    • :network<~String> - Name of the network to which this NIC is connected.

    • :NetworkConnectionIndex<~Integer> - Virtual slot number associated with this NIC. First slot number is 0.

    • :IpAddress<~String> - IP address assigned to this NIC.

    • :IsConnected<~Boolean> - If the virtual machine is undeployed, this value specifies whether the NIC should be connected upon deployment. If the virtual machine is deployed, this value reports the current status of this NIC’s connection, and can be updated to change that connection status.

    • :MACAddress<~String> - MAC address associated with the NIC.

    • :IpAddressAllocationMode<~String> - IP address allocation mode for this connection. One of:

      • POOL (A static IP address is allocated automatically from a pool of addresses.)

      • DHCP (The IP address is obtained from a DHCP service.)

      • MANUAL (The IP address is assigned manually in the :IpAddress element.)

      • NONE (No IP addressing mode specified.)

Returns:

  • (Excon::Response)
    • body<~Hash>:

      • :Tasks<~Hash>:

        • :Task<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/fog/vcloud_director/requests/compute/put_network_connection_system_section_vapp.rb', line 49

def put_network_connection_system_section_vapp(id, options={})
  options = options.dup

  # Mutate options to new format.
  deprecated = {
    :needs_customization => :needsCustomization,
    :network => :network,
    :network_connection_index => :NetworkConnectionIndex,
    :ip_address => :IpAddress,
    :is_connected => :IsConnected,
    :mac_address => :MACAddress,
    :ip_address_allocation_mode => :IpAddressAllocationMode
  }
  option = options.delete(:primary_network_connection_index)
  options[:PrimaryNetworkConnectionIndex] ||= option unless option.nil?
  unless options.key?(:NetworkConnection)
    deprecated.each do |from, to|
      if options.key?(from)
        options[:NetworkConnection] ||= [{}]
        options[:NetworkConnection].first[to] = options.delete(from)
      end
    end
  end

  options[:NetworkConnection] = [options[:NetworkConnection]] if options[:NetworkConnection].is_a?(Hash)

  body = Nokogiri::XML::Builder.new do
    attrs = {
      :xmlns => 'http://www.vmware.com/vcloud/v1.5',
      'xmlns:ovf' => 'http://schemas.dmtf.org/ovf/envelope/1'
    }
    NetworkConnectionSection(attrs) {
      self[:ovf].Info 'Specifies the available VM network connections'
      if options.key?(:PrimaryNetworkConnectionIndex)
        PrimaryNetworkConnectionIndex options[:PrimaryNetworkConnectionIndex]
      end
      if network_connection = options[:NetworkConnection]
       network_connection.each do |nic|
          attrs = {
            :network => nic[:network]
          }
          if nic.key?(:needsCustomization)
            attrs[:needsCustomization] = nic[:needsCustomization]
          end
          NetworkConnection(attrs) {
            NetworkConnectionIndex nic[:NetworkConnectionIndex]
            if nic.key?(:IpAddress)
              IpAddress nic[:IpAddress]
            end
            IsConnected nic[:IsConnected]
            if nic.key?(:MACAddress)
              MACAddress nic[:MACAddress]
            end
            IpAddressAllocationMode nic[:IpAddressAllocationMode]
          }
        end
      end
    }
  end.to_xml

  request(
    :body    => body,
    :expects => 202,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.networkConnectionSection+xml'},
    :method  => 'PUT',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/networkConnectionSection/"
  )
end

#put_vapp_metadata_item_metadata(id, key, value) ⇒ Excon::Response

Set the value for the specified metadata key to the value provided, overwriting any existing value.

Parameters:

  • id (String)

    Object identifier of the vApp or VM.

  • key (String)

    Key of the metadata item.

  • value (Boolean, DateTime, Fixnum, String)

    Value of the metadata item.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/fog/vcloud_director/requests/compute/put_vapp_metadata_item_metadata.rb', line 17

def (id, key, value)
  body = Nokogiri::XML::Builder.new do
    attrs = {
      :xmlns => 'http://www.vmware.com/vcloud/v1.5',
      'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance'
    }
    MetadataValue(attrs) {
      if api_version.to_f < 5.1
        Value value
      else
        type = case value
               when TrueClass, FalseClass then 'MetadataBooleanValue';
               when DateTime then 'MetadataDateTimeValue';
               when Fixnum then 'MetadataNumberValue';
               else 'MetadataStringValue'
               end
        TypedValue('xsi:type' => type) { Value value }
      end
    }
  end.to_xml

  request(
    :body    => body,
    :expects => 202,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.metadata.value+xml'},
    :method  => 'PUT',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/metadata/#{URI.escape(key)}"
  )
end

#put_vapp_name_and_description(id, name, options = {}) ⇒ Excon::Response

Modify the name or description of a vApp.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the vApp.

  • name (String)

    of the vApp.

  • options (Hash) (defaults to: {})
    • :Description<~String>: - description to be assigned (optional)

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/vcloud_director/requests/compute/put_vapp_name_and_description.rb', line 23

def put_vapp_name_and_description(id, name, options={})
  body = Fog::Generators::Compute::VcloudDirector::Vapp.new(name, options).generate_xml
  request(
    :body    => body,
    :expects => 202,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.vApp+xml'},
    :method  => 'PUT',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}"
  )
end

#put_vapp_template_metadata_item_metadata(id, key, value) ⇒ Excon::Response

Set the value for the specified metadata key to the value provided, overwriting any existing value.

Parameters:

  • id (String)

    Object identifier of the vApp template.

  • key (String)

    Key of the metadata item.

  • value (Boolean, DateTime, Fixnum, String)

    Value of the metadata item.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 1.5



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/fog/vcloud_director/requests/compute/put_vapp_template_metadata_item_metadata.rb', line 17

def (id, key, value)
  body = Nokogiri::XML::Builder.new do
    attrs = {
      :xmlns => 'http://www.vmware.com/vcloud/v1.5',
      'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance'
    }
    MetadataValue(attrs) {
      if api_version.to_f < 5.1
        Value value
      else
        type = case value
               when TrueClass, FalseClass then 'MetadataBooleanValue';
               when DateTime then 'MetadataDateTimeValue';
               when Fixnum then 'MetadataNumberValue';
               else 'MetadataStringValue'
               end
        TypedValue('xsi:type' => type) { Value value }
      end
    }
  end.to_xml

  request(
    :body    => body,
    :expects => 202,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.metadata.value+xml'},
    :method  => 'PUT',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vappTemplate/#{id}/metadata/#{URI.escape(key)}"
  )
end

#put_vm(id, name, options) ⇒ Excon::Response

Update the name, description and storage profile for VM.

This operation is asynchronous and returns a task that you can monitor to track the progress of the request.

Parameters:

  • id (String)

    Object identifier of the VM.

  • name (String)

    of the VM.

  • options (Hash)
    • :Description<~String>: - description to be assigned.

    • :StorageProfile<~Hash>: - storage profile to be assigned.

      • :name<~String>

      • :href<~String>

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:

Since:

  • vCloud API version 0.9



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/vcloud_director/requests/compute/put_vm.rb', line 25

def put_vm(id, name, options)
  body = Fog::Generators::Compute::VcloudDirector::Vm.new(options.merge(:name => name)).generate_xml
  request(
    :body    => body,
    :expects => 202,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.vm+xml'},
    :method  => 'PUT',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}"
  )
end

#put_vm_capabilities(id, options = {}) ⇒ Excon::Response

Update VM’s capabilities.

Parameters:

  • id (String)

    Object identifier of the VM.

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :MemoryHotAddEnabled (Boolean)

    True if the virtual machine supports addition of memory while powered on.

  • :CpuHotAddEnabled (Boolean)

    True if the virtual machine supports addition of virtual CPUs while powered on.

Returns:

  • (Excon::Response)
    • body<~Hash>:

See Also:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/fog/vcloud_director/requests/compute/put_vm_capabilities.rb', line 17

def put_vm_capabilities(id, options={})
  body = Nokogiri::XML::Builder.new do
    attrs = {
      :xmlns => 'http://www.vmware.com/vcloud/v1.5'
    }
    VmCapabilities(attrs) {
      if options.key?(:MemoryHotAddEnabled)
        MemoryHotAddEnabled options[:MemoryHotAddEnabled]
      end
      if options.key?(:CpuHotAddEnabled)
        MemoryHotAddEnabled options[:CpuHotAddEnabled]
      end
    }
  end.to_xml

  request(
    :body    => body,
    :expects => 202,
    :headers => {'Content-Type' => 'application/vnd.vmware.vcloud.vmCapabilitiesSection+xml'},
    :method  => 'PUT',
    :parser  => Fog::ToHashDocument.new,
    :path    => "vApp/#{id}/vmCapabilities"
  )
end

#reloadObject



360
361
362
# File 'lib/fog/vcloud_director/compute.rb', line 360

def reload
  @connection.reset
end

#request(params) ⇒ Object



364
365
366
367
368
369
370
371
372
# File 'lib/fog/vcloud_director/compute.rb', line 364

def request(params)
  begin
    do_request(params)
  # this is to know if Excon::Errors::Unauthorized really happens
  #rescue Excon::Errors::Unauthorized
  #  login
  #  do_request(params)
  end
end

#undeploy(id) ⇒ Object

Deprecated.

Use #post_undeploy_vapp instead.



59
60
61
62
# File 'lib/fog/vcloud_director/requests/compute/post_undeploy_vapp.rb', line 59

def undeploy(id)
  Fog::Logger.deprecation("#{self} => ##{undeploy} is deprecated, use ##{post_undeploy_vapp} instead [light_black](#{caller.first})[/]")
  post_undeploy_vapp(id, :UndeployPowerAction => 'shutdown')
end

#user_nameObject



355
356
357
358
# File 'lib/fog/vcloud_director/compute.rb', line 355

def user_name
   if @user_name.nil?
  @user_name
end

#vcloud_tokenObject



345
346
347
348
# File 'lib/fog/vcloud_director/compute.rb', line 345

def vcloud_token
   if @vcloud_token.nil?
  @vcloud_token
end

#wait_and_raise_unless_success(task) ⇒ Object



420
421
422
423
# File 'lib/fog/vcloud_director/compute.rb', line 420

def wait_and_raise_unless_success(task)
  task.wait_for { non_running? }
  raise TaskError.new "status: #{task.status}, error: #{task.error}" unless task.success?
end