Class: OvirtSDK4::InstanceTypeService

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

Instance Method Summary (collapse)

Instance Method Details

- (InstanceType) get(opts = {})

Returns the representation of the object managed by this service.

Parameters:

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

    Additional options.

Returns:



10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
# File 'lib/ovirtsdk4/services.rb', line 10584

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 InstanceTypeReader.read_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (GraphicsConsolesService) graphics_consoles_service

Locates the graphics_consoles service.

Returns:



10656
10657
10658
# File 'lib/ovirtsdk4/services.rb', line 10656

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

- (InstanceTypeNicsService) nics_service

Locates the nics service.

Returns:



10664
10665
10666
# File 'lib/ovirtsdk4/services.rb', line 10664

def nics_service
  return InstanceTypeNicsService.new(@connection, "#{@path}/nics")
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.



10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
# File 'lib/ovirtsdk4/services.rb', line 10608

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)


10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
# File 'lib/ovirtsdk4/services.rb', line 10683

def service(path)
  if path.nil? || path == ''
    return self
  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 == '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

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


10713
10714
10715
# File 'lib/ovirtsdk4/services.rb', line 10713

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

- (Object) update(instance_type)

Updates the object managed by this service.



10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
# File 'lib/ovirtsdk4/services.rb', line 10625

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

- (InstanceTypeWatchdogsService) watchdogs_service

Locates the watchdogs service.

Returns:



10672
10673
10674
# File 'lib/ovirtsdk4/services.rb', line 10672

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