Class: OvirtSDK4::GraphicsConsolesService

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

Instance Method Summary (collapse)

Instance Method Details

- (GraphicsConsole) add(console, opts = {})

Adds a new console.

Parameters:

Returns:



9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
# File 'lib/ovirtsdk4/services.rb', line 9118

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

- (GraphicsConsoleService) console_service(id)

Locates the console service.

Parameters:

  • id (String)

    The identifier of the console.

Returns:



9182
9183
9184
# File 'lib/ovirtsdk4/services.rb', line 9182

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

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

Returns:



9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
# File 'lib/ovirtsdk4/services.rb', line 9153

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



9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
# File 'lib/ovirtsdk4/services.rb', line 9193

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

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


9209
9210
9211
# File 'lib/ovirtsdk4/services.rb', line 9209

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