Creates a new implementation of the service.
@param connection [Connection] The connection to be used by this service.
@param path [String] The relative path of this service, for example `vms/123/disks`.
@api private
# File lib/ovirtsdk4/services.rb, line 9028 def initialize(connection, path) @connection = connection @path = path end
This operation is used to import a virtual machine from external hypervisor, such as KVM, XEN or VMware.
For example import of a virtual machine from VMware can be facilitated using the following request:
POST /externalvmimports
With request body of type <<types/external_vm_import,ExternalVmImport>>, for example:
<external_vm_import>
<vm> <name>my_vm</name> </vm> <cluster id="360014051136c20574f743bdbd28177fd" /> <storage_domain id="8bb5ade5-e988-4000-8b93-dbfc6717fe50" /> <name>vm_name_as_is_in_vmware</name> <sparse>true</sparse> <username>vmware_user</username> <password>123456</password> <provider>VMWARE</provider> <url>vpx://wmware_user@vcenter-host/DataCenter/Cluster/esxi-host?no_verify=1</url> <drivers_iso id="virtio-win-1.6.7.iso" />
</external_vm_import>
@param import [ExternalVmImport] The `import` to add.
@param opts [Hash] Additional options.
@return [ExternalVmImport]
# File lib/ovirtsdk4/services.rb, line 9069 def add(import, opts = {}) if import.is_a?(Hash) import = OvirtSDK4::ExternalVmImport.new(import) end query = {} request = HttpRequest.new(method: :POST, url: @path, query: query) begin writer = XmlWriter.new(nil, true) ExternalVmImportWriter.write_one(import, writer) request.body = writer.string ensure writer.close end response = @connection.send(request) case response.code when 200, 201, 202 begin reader = XmlReader.new(response.body) return ExternalVmImportReader.read_one(reader) ensure reader.close end else check_fault(response) end end
Locates the service corresponding to the given path.
@param path [String] The path of the service.
@return [Service] A reference to the service.
# File lib/ovirtsdk4/services.rb, line 9103 def service(path) if path.nil? || path == '' return self end raise Error.new("The path \"#{path}\" doesn't correspond to any service") end
Returns an string representation of this service.
@return [String]
# File lib/ovirtsdk4/services.rb, line 9115 def to_s "#<#{ExternalVmImportsService}:#{@path}>" end