Class: OvirtSDK4::VmWatchdogsService

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

Instance Method Summary (collapse)

Instance Method Details

- (Watchdog) add(watchdog, opts = {})

Adds a new watchdog.

Parameters:

Returns:



26555
26556
26557
26558
26559
26560
26561
26562
26563
26564
26565
26566
26567
26568
26569
26570
26571
26572
26573
26574
26575
26576
26577
26578
26579
# File 'lib/ovirtsdk4/services.rb', line 26555

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

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

Returns:



26590
26591
26592
26593
26594
26595
26596
26597
26598
26599
26600
26601
26602
26603
26604
26605
26606
26607
26608
26609
26610
# File 'lib/ovirtsdk4/services.rb', line 26590

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



26630
26631
26632
26633
26634
26635
26636
26637
26638
26639
# File 'lib/ovirtsdk4/services.rb', line 26630

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

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


26646
26647
26648
# File 'lib/ovirtsdk4/services.rb', line 26646

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

- (VmWatchdogService) watchdog_service(id)

Locates the watchdog service.

Parameters:

  • id (String)

    The identifier of the watchdog.

Returns:



26619
26620
26621
# File 'lib/ovirtsdk4/services.rb', line 26619

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