Class: OvirtSDK4::SnapshotService

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

Instance Method Summary (collapse)

Instance Method Details

- (SnapshotCdromsService) cdroms_service

Locates the cdroms service.

Returns:



17299
17300
17301
# File 'lib/ovirtsdk4/services.rb', line 17299

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

- (SnapshotDisksService) disks_service

Locates the disks service.

Returns:



17307
17308
17309
# File 'lib/ovirtsdk4/services.rb', line 17307

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

- (Snapshot) get(opts = {})

Returns the representation of the object managed by this service.

Parameters:

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

    Additional options.

Returns:



17234
17235
17236
17237
17238
17239
17240
17241
17242
17243
17244
17245
17246
17247
17248
17249
# File 'lib/ovirtsdk4/services.rb', line 17234

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

- (SnapshotNicsService) nics_service

Locates the nics service.

Returns:



17315
17316
17317
# File 'lib/ovirtsdk4/services.rb', line 17315

def nics_service
  return SnapshotNicsService.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.



17258
17259
17260
17261
17262
17263
17264
17265
17266
17267
17268
17269
17270
# File 'lib/ovirtsdk4/services.rb', line 17258

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

- (Object) restore(opts = {})

Executes the restore method.



17275
17276
17277
17278
17279
17280
17281
17282
17283
17284
17285
17286
17287
17288
17289
17290
17291
17292
17293
# File 'lib/ovirtsdk4/services.rb', line 17275

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

Raises:

  • (Error)


17326
17327
17328
17329
17330
17331
17332
17333
17334
17335
17336
17337
17338
17339
17340
17341
17342
17343
17344
17345
17346
17347
17348
17349
# File 'lib/ovirtsdk4/services.rb', line 17326

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 == 'nics'
    return nics_service
  end
  if path.start_with?('nics/')
    return nics_service.service(path[5..-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)


17356
17357
17358
# File 'lib/ovirtsdk4/services.rb', line 17356

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