Class: OvirtSDK4::SnapshotsService

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

Instance Method Summary collapse

Methods inherited from Service

#inspect, #to_s

Instance Method Details

#add(snapshot, opts = {}) ⇒ Snapshot

Creates a virtual machine snapshot.

For example, to create a new snapshot for virtual machine 123 send a request like this:

POST /ovirt-engine/api/vms/123/snapshots

With a request body like this:

<snapshot>
  <description>My snapshot</description>
</snapshot>

For including only a sub-set of disks in the snapshots, add disk_attachments element to the request body. Note that disks which are not specified in disk_attachments element will not be a part of the snapshot. If an empty disk_attachments element is passed, the snapshot will include only the virtual machine configuration. If no disk_attachments element is passed, then all the disks will be included in the snapshot.

For each disk, image_id element can be specified for setting the new active image id. This is used in order to restore a chain of images from backup. I.e. when restoring a disk with snapshots, the relevant image_id should be specified for each snapshot (so the identifiers of the disk snapshots are identical to the backup).

<snapshot>
  <description>My snapshot</description>
  <disk_attachments>
    <disk_attachment>
      <disk id="123">
        <image_id>456</image_id>
      </disk>
    </disk_attachment>
  </disk_attachments>
</snapshot>
Important

When a snapshot is created, the default value for the persist_memorystate attribute is true. That means that the content of the memory of the virtual machine will be included in the snapshot, and it also means that the virtual machine will be paused for a longer time. That can negatively affect applications that are very sensitive to timing (NTP servers, for example). In those cases make sure that you set the attribute to false:

<snapshot>
  <description>My snapshot</description>
  <persist_memorystate>false</persist_memorystate>
</snapshot>

Parameters:

  • snapshot (Snapshot)

    The snapshot to add.

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

    Additional options.

Options Hash (opts):

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: nil

    The timeout for this request, in seconds. If no value is explicitly given then the timeout set globally for the connection will be used.

  • :wait (Boolean) — default: true

    If true wait for the response.

Returns:



21428
21429
21430
# File 'lib/ovirtsdk4/services.rb', line 21428

def add(snapshot, opts = {})
  internal_add(snapshot, Snapshot, ADD, opts)
end

#list(opts = {}) ⇒ Array<Snapshot>

Returns the list of snapshots of the storage domain or virtual machine.

The order of the returned list of snapshots isn’t guaranteed.

Parameters:

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

    Additional options.

Options Hash (opts):

  • :all_content (Boolean)

    Indicates if all the attributes of the virtual machine snapshot should be included in the response.

    By default the attribute initialization.configuration.data is excluded.

    For example, to retrieve the complete representation of the virtual machine with id 123 snapshots send a request like this:

    GET /ovirt-engine/api/vms/123/snapshots?all_content=true
  • :follow (String)

    Indicates which inner links should be followed. The objects referenced by these links will be fetched as part of the current request. See here for details.

  • :max (Integer)

    Sets the maximum number of snapshots to return. If not specified all the snapshots are returned.

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: nil

    The timeout for this request, in seconds. If no value is explicitly given then the timeout set globally for the connection will be used.

  • :wait (Boolean) — default: true

    If true wait for the response.

Returns:



21474
21475
21476
# File 'lib/ovirtsdk4/services.rb', line 21474

def list(opts = {})
  internal_get(LIST, opts)
end

#service(path) ⇒ Service

Locates the service corresponding to the given path.

Parameters:

  • path (String)

    The path of the service.

Returns:

  • (Service)

    A reference to the service.



21496
21497
21498
21499
21500
21501
21502
21503
21504
21505
# File 'lib/ovirtsdk4/services.rb', line 21496

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

#snapshot_service(id) ⇒ SnapshotService

Locates the snapshot service.

Parameters:

  • id (String)

    The identifier of the snapshot.

Returns:



21485
21486
21487
# File 'lib/ovirtsdk4/services.rb', line 21485

def snapshot_service(id)
  SnapshotService.new(self, id)
end