Class: OvirtSDK4::InstanceTypesService

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

Creates a new instance type.

This requires only a name attribute and can include all hardware configurations of the virtual machine.

POST /ovirt-engine/api/instancetypes

With a request body like this:

<instance_type>
  <name>myinstancetype</name>
</template>

Creating an instance type with all hardware configurations with a request body like this:

<instance_type>
  <name>myinstancetype</name>
  <console>
    <enabled>true</enabled>
  </console>
  <cpu>
    <topology>
      <cores>2</cores>
      <sockets>2</sockets>
      <threads>1</threads>
    </topology>
  </cpu>
  <custom_cpu_model>AMD Opteron_G2</custom_cpu_model>
  <custom_emulated_machine>q35</custom_emulated_machine>
  <display>
    <monitors>1</monitors>
    <single_qxl_pci>true</single_qxl_pci>
    <smartcard_enabled>true</smartcard_enabled>
    <type>spice</type>
  </display>
  <high_availability>
    <enabled>true</enabled>
    <priority>1</priority>
  </high_availability>
  <io>
    <threads>2</threads>
  </io>
  <memory>4294967296</memory>
  <memory_policy>
    <ballooning>true</ballooning>
    <guaranteed>268435456</guaranteed>
  </memory_policy>
  <migration>
    <auto_converge>inherit</auto_converge>
    <compressed>inherit</compressed>
    <policy id="00000000-0000-0000-0000-000000000000"/>
  </migration>
  <migration_downtime>2</migration_downtime>
  <os>
    <boot>
      <devices>
        <device>hd</device>
      </devices>
    </boot>
  </os>
  <rng_device>
    <rate>
      <bytes>200</bytes>
      <period>2</period>
    </rate>
    <source>urandom</source>
  </rng_device>
  <soundcard_enabled>true</soundcard_enabled>
  <usb>
    <enabled>true</enabled>
    <type>native</type>
  </usb>
  <virtio_scsi>
    <enabled>true</enabled>
  </virtio_scsi>
</instance_type>

Parameters:

  • instance_type (InstanceType)

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



13197
13198
13199
# File 'lib/ovirtsdk4/services.rb', line 13197

def add(instance_type, opts = {})
  internal_add(instance_type, InstanceType, ADD, opts)
end

#instance_type_service(id) ⇒ InstanceTypeService

Locates the instance_type service.

Parameters:

  • id (String)

    The identifier of the instance_type.

Returns:



13251
13252
13253
# File 'lib/ovirtsdk4/services.rb', line 13251

def instance_type_service(id)
  InstanceTypeService.new(self, id)
end

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

Lists all existing instance types in the system.

The order of the returned list of instance types isn’t guaranteed.

Parameters:

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

    Additional options.

Options Hash (opts):

  • :case_sensitive (Boolean)

    Indicates if the search performed using the search parameter should be performed taking case into account. The default value is true, which means that case is taken into account. If you want to search ignoring case set it to false.

  • :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 instance types to return. If not specified all the instance types are returned.

  • :search (String)

    A query string used to restrict the returned templates.

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



13240
13241
13242
# File 'lib/ovirtsdk4/services.rb', line 13240

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.



13262
13263
13264
13265
13266
13267
13268
13269
13270
13271
# File 'lib/ovirtsdk4/services.rb', line 13262

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