Class: OvirtSDK4::StorageDomainTemplateService

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

Instance Method Summary (collapse)

Instance Method Details

- (StorageDomainContentDisksService) disks_service

Locates the disks service.

Returns:



19543
19544
19545
# File 'lib/ovirtsdk4/services.rb', line 19543

def disks_service
  return StorageDomainContentDisksService.new(@connection, "#{@path}/disks")
end

- (Template) get(opts = {})

Returns the representation of the object managed by this service.

Parameters:

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

    Additional options.

Returns:



19455
19456
19457
19458
19459
19460
19461
19462
19463
19464
19465
19466
19467
19468
19469
19470
# File 'lib/ovirtsdk4/services.rb', line 19455

def get(opts = {})
  query = {}
  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 TemplateReader.read_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (Object) import(opts = {})

Executes the import method.



19475
19476
19477
19478
19479
19480
19481
19482
19483
19484
19485
19486
19487
19488
19489
19490
19491
19492
19493
# File 'lib/ovirtsdk4/services.rb', line 19475

def import(opts = {})
  action = Action.new(opts)
  writer = XmlWriter.new(nil, true)
  ActionWriter.write_one(action, writer)
  body = writer.string
  writer.close
  request = Request.new({
  :method => :POST,
  :path => "#{@path}/import",
  :body => body,
  })
  response = @connection.send(request)
  case response.code
  when 200
    action = check_action(response)
  else
    check_fault(response)
  end
end

- (Object) register(opts = {})

Executes the register method.



19498
19499
19500
19501
19502
19503
19504
19505
19506
19507
19508
19509
19510
19511
19512
19513
19514
19515
19516
# File 'lib/ovirtsdk4/services.rb', line 19498

def register(opts = {})
  action = Action.new(opts)
  writer = XmlWriter.new(nil, true)
  ActionWriter.write_one(action, writer)
  body = writer.string
  writer.close
  request = Request.new({
  :method => :POST,
  :path => "#{@path}/register",
  :body => body,
  })
  response = @connection.send(request)
  case response.code
  when 200
    action = check_action(response)
  else
    check_fault(response)
  end
end

- (Object) remove(opts = {})

Deletes the object managed by this service.

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the remove should be performed asynchronously.



19525
19526
19527
19528
19529
19530
19531
19532
19533
19534
19535
19536
19537
# File 'lib/ovirtsdk4/services.rb', line 19525

def remove(opts = {})
  query = {}
  value = opts[:async]
  unless value.nil?
    value = Writer.render_boolean(value)
    query['async'] = value
  end
  request = Request.new(:method => :DELETE, :path => @path, :query => query)
  response = @connection.send(request)
  unless response.code == 200
    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.

Raises:

  • (Error)


19554
19555
19556
19557
19558
19559
19560
19561
19562
19563
19564
19565
# File 'lib/ovirtsdk4/services.rb', line 19554

def service(path)
  if path.nil? || path == ''
    return self
  end
  if path == 'disks'
    return disks_service
  end
  if path.start_with?('disks/')
    return disks_service.service(path[6..-1])
  end
  raise Error.new("The path \"#{path}\" doesn't correspond to any service")
end

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


19572
19573
19574
# File 'lib/ovirtsdk4/services.rb', line 19572

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