Class: OvirtSDK4::StorageServerConnectionExtensionsService

Inherits:
Service
  • Object
show all
Defined in:
lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb

Instance Method Summary (collapse)

Instance Method Details

- (StorageConnectionExtension) add(extension, opts = {})

Adds a new extension.

Parameters:

Returns:



20296
20297
20298
20299
20300
20301
20302
20303
20304
20305
20306
20307
20308
20309
20310
20311
20312
20313
20314
20315
20316
20317
20318
20319
20320
# File 'lib/ovirtsdk4/services.rb', line 20296

def add(extension, opts = {})
  if extension.is_a?(Hash)
    extension = OvirtSDK4::StorageConnectionExtension.new(extension)
  end
  request = Request.new(:method => :POST, :path => @path)
  begin
    writer = XmlWriter.new(nil, true)
    StorageConnectionExtensionWriter.write_one(extension, writer, 'extension')
    request.body = writer.string
  ensure
    writer.close
  end
  response = @connection.send(request)
  case response.code
  when 201, 202
    begin
      reader = XmlReader.new(response.body)
      return StorageConnectionExtensionReader.read_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (Array<StorageConnectionExtension>) list(opts = {})

Returns the representation of the object managed by this service.

Parameters:

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

    Additional options.

Options Hash (opts):

  • :max (Integer)

    Sets the maximum number of extensions to return. If not specified all the extensions are returned.

Returns:



20331
20332
20333
20334
20335
20336
20337
20338
20339
20340
20341
20342
20343
20344
20345
20346
20347
20348
20349
20350
20351
# File 'lib/ovirtsdk4/services.rb', line 20331

def list(opts = {})
  query = {}
  value = opts[:max]
  unless value.nil?
    value = Writer.render_integer(value)
    query['max'] = value
  end
  request = Request.new(:method => :GET, :path => @path, :query => query)
  response = @connection.send(request)
  case response.code
  when 200
    begin
      reader = XmlReader.new(response.body)
      return StorageConnectionExtensionReader.read_many(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (Service) service(path)

Locates the service corresponding to the given path.

Parameters:

  • path (String)

    The path of the service.

Returns:

  • (Service)

    A reference to the service.



20371
20372
20373
20374
20375
20376
20377
20378
20379
20380
# File 'lib/ovirtsdk4/services.rb', line 20371

def service(path)
  if path.nil? || path == ''
    return self
  end
  index = path.index('/')
  if index.nil?
    return storage_connection_extension_service(path)
  end
  return storage_connection_extension_service(path[0..(index - 1)]).service(path[(index +1)..-1])
end

- (StorageServerConnectionExtensionService) storage_connection_extension_service(id)

Locates the storage_connection_extension service.

Parameters:

  • id (String)

    The identifier of the storage_connection_extension.

Returns:



20360
20361
20362
# File 'lib/ovirtsdk4/services.rb', line 20360

def storage_connection_extension_service(id)
  return StorageServerConnectionExtensionService.new(@connection, "#{@path}/#{id}")
end

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


20387
20388
20389
# File 'lib/ovirtsdk4/services.rb', line 20387

def to_s
  return "#<#{StorageServerConnectionExtensionsService}:#{@path}>"
end