Class: OvirtSDK4::DiskAttachmentsService

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(attachment, opts = {}) ⇒ DiskAttachment

Adds a new disk attachment to the virtual machine. The attachment parameter can contain just a reference, if the disk already exists:

<disk_attachment>
  <bootable>true</bootable>
  <pass_discard>true</pass_discard>
  <interface>ide</interface>
  <active>true</active>
  <disk id="123"/>
</disk_attachment>

Or it can contain the complete representation of the disk, if the disk doesn’t exist yet:

<disk_attachment>
  <bootable>true</bootable>
  <pass_discard>true</pass_discard>
  <interface>ide</interface>
  <active>true</active>
  <disk>
    <name>mydisk</name>
    <provisioned_size>1024</provisioned_size>
    ...
  </disk>
</disk_attachment>

In this case the disk will be created and then attached to the virtual machine.

In both cases, use the following URL for a virtual machine with an id 345:

POST /ovirt-engine/api/vms/345/diskattachments
Important
The server accepts requests that don’t contain the active attribute, but the effect is undefined. In some cases the disk will be automatically activated and in other cases it won’t. To avoid issues it is strongly recommended to always include the active attribute with the desired value.

Parameters:

  • attachment (DiskAttachment)

    The attachment 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:



6486
6487
6488
# File 'lib/ovirtsdk4/services.rb', line 6486

def add(attachment, opts = {})
  internal_add(attachment, DiskAttachment, ADD, opts)
end

#add_providing_disk_id(attachment, opts = {}) ⇒ DiskAttachment

Adds a new attachment.

Parameters:

  • attachment (DiskAttachment)

    The attachment 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:



6544
6545
6546
# File 'lib/ovirtsdk4/services.rb', line 6544

def add_providing_disk_id(attachment, opts = {})
  internal_add(attachment, DiskAttachment, ADD_PROVIDING_DISK_ID, opts)
end

#add_signature1(attachment, opts = {}) ⇒ DiskAttachment

Adds a new attachment.

Parameters:

  • attachment (DiskAttachment)

    The attachment 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:



6571
6572
6573
# File 'lib/ovirtsdk4/services.rb', line 6571

def add_signature1(attachment, opts = {})
  internal_add(attachment, DiskAttachment, ADD_SIGNATURE1, opts)
end

#attachment_service(id) ⇒ DiskAttachmentService

Reference to the service that manages a specific attachment.

Parameters:

  • id (String)

    The identifier of the attachment.

Returns:



6582
6583
6584
# File 'lib/ovirtsdk4/services.rb', line 6582

def attachment_service(id)
  DiskAttachmentService.new(self, id)
end

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

List the disk that are attached to the virtual machine.

The order of the returned list of disks attachments isn’t guaranteed.

Parameters:

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

    Additional options.

Options Hash (opts):

  • :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.

  • :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:



6517
6518
6519
# File 'lib/ovirtsdk4/services.rb', line 6517

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.



6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
# File 'lib/ovirtsdk4/services.rb', line 6593

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