Class: OvirtSDK4::InstanceTypeWatchdogsService

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:



11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
# File 'lib/ovirtsdk4/services.rb', line 11094

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:



11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
# File 'lib/ovirtsdk4/services.rb', line 11129

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.



11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
# File 'lib/ovirtsdk4/services.rb', line 11169

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)


11185
11186
11187
# File 'lib/ovirtsdk4/services.rb', line 11185

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

- (InstanceTypeWatchdogService) watchdog_service(id)

Locates the watchdog service.

Parameters:

  • id (String)

    The identifier of the watchdog.

Returns:



11158
11159
11160
# File 'lib/ovirtsdk4/services.rb', line 11158

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