Class: OvirtSDK4::AttachedStorageDomainsService

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

Instance Method Summary (collapse)

Instance Method Details

- (StorageDomain) add(storage_domain, opts = {})

Adds a new storage_domain.

Parameters:

Returns:



3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
# File 'lib/ovirtsdk4/services.rb', line 3446

def add(storage_domain, opts = {})
  if storage_domain.is_a?(Hash)
    storage_domain = OvirtSDK4::StorageDomain.new(storage_domain)
  end
  request = Request.new(:method => :POST, :path => @path)
  begin
    writer = XmlWriter.new(nil, true)
    StorageDomainWriter.write_one(storage_domain, writer, 'storage_domain')
    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 StorageDomainReader.read_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (Array<StorageDomain>) 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 storage domains to return. If not specified all the storage domains are returned.

Returns:



3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
# File 'lib/ovirtsdk4/services.rb', line 3481

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 StorageDomainReader.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.



3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
# File 'lib/ovirtsdk4/services.rb', line 3521

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

- (AttachedStorageDomainService) storage_domain_service(id)

Locates the storage_domain service.

Parameters:

  • id (String)

    The identifier of the storage_domain.

Returns:



3510
3511
3512
# File 'lib/ovirtsdk4/services.rb', line 3510

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

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


3537
3538
3539
# File 'lib/ovirtsdk4/services.rb', line 3537

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