Class: OvirtSDK4::TemplateService

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

Instance Method Summary (collapse)

Instance Method Details

- (TemplateCdromsService) cdroms_service

Locates the cdroms service.

Returns:



21582
21583
21584
# File 'lib/ovirtsdk4/services.rb', line 21582

def cdroms_service
  return TemplateCdromsService.new(@connection, "#{@path}/cdroms")
end

- (TemplateDisksService) disks_service

Locates the disks service.

Returns:



21590
21591
21592
# File 'lib/ovirtsdk4/services.rb', line 21590

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

- (Object) export(opts = {})

Executes the export method.



21476
21477
21478
21479
21480
21481
21482
21483
21484
21485
21486
21487
21488
21489
21490
21491
21492
21493
21494
# File 'lib/ovirtsdk4/services.rb', line 21476

def export(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}/export",
  :body => body,
  })
  response = @connection.send(request)
  case response.code
  when 200
    action = check_action(response)
  else
    check_fault(response)
  end
end

- (Template) get(opts = {})

Returns the representation of the object managed by this service.

Parameters:

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

    Additional options.

Options Hash (opts):

  • :filter (Boolean)

    Indicates if the results should be filtered according to the permissions of the user.

Returns:



21505
21506
21507
21508
21509
21510
21511
21512
21513
21514
21515
21516
21517
21518
21519
21520
21521
21522
21523
21524
21525
# File 'lib/ovirtsdk4/services.rb', line 21505

def get(opts = {})
  query = {}
  value = opts[:filter]
  unless value.nil?
    value = Writer.render_boolean(value)
    query['filter'] = 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 TemplateReader.read_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (GraphicsConsolesService) graphics_consoles_service

Locates the graphics_consoles service.

Returns:



21598
21599
21600
# File 'lib/ovirtsdk4/services.rb', line 21598

def graphics_consoles_service
  return GraphicsConsolesService.new(@connection, "#{@path}/graphicsconsoles")
end

- (TemplateNicsService) nics_service

Locates the nics service.

Returns:



21606
21607
21608
# File 'lib/ovirtsdk4/services.rb', line 21606

def nics_service
  return TemplateNicsService.new(@connection, "#{@path}/nics")
end

- (AssignedPermissionsService) permissions_service

Locates the permissions service.

Returns:



21614
21615
21616
# File 'lib/ovirtsdk4/services.rb', line 21614

def permissions_service
  return AssignedPermissionsService.new(@connection, "#{@path}/permissions")
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.



21534
21535
21536
21537
21538
21539
21540
21541
21542
21543
21544
21545
21546
# File 'lib/ovirtsdk4/services.rb', line 21534

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)


21641
21642
21643
21644
21645
21646
21647
21648
21649
21650
21651
21652
21653
21654
21655
21656
21657
21658
21659
21660
21661
21662
21663
21664
21665
21666
21667
21668
21669
21670
21671
21672
21673
21674
21675
21676
21677
21678
21679
21680
21681
21682
21683
21684
21685
21686
21687
21688
# File 'lib/ovirtsdk4/services.rb', line 21641

def service(path)
  if path.nil? || path == ''
    return self
  end
  if path == 'cdroms'
    return cdroms_service
  end
  if path.start_with?('cdroms/')
    return cdroms_service.service(path[7..-1])
  end
  if path == 'disks'
    return disks_service
  end
  if path.start_with?('disks/')
    return disks_service.service(path[6..-1])
  end
  if path == 'graphicsconsoles'
    return graphics_consoles_service
  end
  if path.start_with?('graphicsconsoles/')
    return graphics_consoles_service.service(path[17..-1])
  end
  if path == 'nics'
    return nics_service
  end
  if path.start_with?('nics/')
    return nics_service.service(path[5..-1])
  end
  if path == 'permissions'
    return permissions_service
  end
  if path.start_with?('permissions/')
    return permissions_service.service(path[12..-1])
  end
  if path == 'tags'
    return tags_service
  end
  if path.start_with?('tags/')
    return tags_service.service(path[5..-1])
  end
  if path == 'watchdogs'
    return watchdogs_service
  end
  if path.start_with?('watchdogs/')
    return watchdogs_service.service(path[10..-1])
  end
  raise Error.new("The path \"#{path}\" doesn't correspond to any service")
end

- (AssignedTagsService) tags_service

Locates the tags service.

Returns:



21622
21623
21624
# File 'lib/ovirtsdk4/services.rb', line 21622

def tags_service
  return AssignedTagsService.new(@connection, "#{@path}/tags")
end

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


21695
21696
21697
# File 'lib/ovirtsdk4/services.rb', line 21695

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

- (Object) update(template)

Updates the object managed by this service.



21551
21552
21553
21554
21555
21556
21557
21558
21559
21560
21561
21562
21563
21564
21565
21566
21567
21568
21569
21570
21571
21572
21573
21574
21575
21576
# File 'lib/ovirtsdk4/services.rb', line 21551

def update(template)
  if template.is_a?(Hash)
    template = OvirtSDK4::Template.new(template)
  end
  request = Request.new(:method => :PUT, :path => @path)
  begin
    writer = XmlWriter.new(nil, true)
    TemplateWriter.write_one(template, writer, 'template')
    request.body = writer.string
  ensure
    writer.close
  end
  response = @connection.send(request)
  case response.code
  when 200
    begin
      reader = XmlReader.new(response.body)
      return TemplateReader.read_one(reader)
    ensure
      reader.close
    end
    return result
  else
    check_fault(response)
  end
end

- (TemplateWatchdogsService) watchdogs_service

Locates the watchdogs service.

Returns:



21630
21631
21632
# File 'lib/ovirtsdk4/services.rb', line 21630

def watchdogs_service
  return TemplateWatchdogsService.new(@connection, "#{@path}/watchdogs")
end