class OvirtSDK4::HostStorageService

Public Class Methods

new(connection, path) click to toggle source

Creates a new implementation of the service.

@param connection [Connection] The connection to be used by this service.

@param path [String] The relative path of this service, for example `vms/123/disks`.

@api private

# File lib/ovirtsdk4/services.rb, line 11413
def initialize(connection, path)
  @connection = connection
  @path = path
end

Public Instance Methods

list(opts = {}) click to toggle source

Get list of storages.

source

GET /ovirt-engine/api/hosts/123/storage


The XML response you get will be like this one:

source,xml

<host_storages>

<host_storage id="123">
  ...
</host_storage>
...

</host_storages>


@param opts [Hash] Additional options.

@option opts [Boolean] :report_status Indicates if the status of the LUNs in the storage should be checked.

Checking the status of the LUN is an heavy weight operation and
this data is not always needed by the user.
This parameter will give the option to not perform the status check of the LUNs.

The default is `true` for backward compatibility.

Here an example with the LUN status :

[source,xml]
----
<host_storage id="123">
  <logical_units>
    <logical_unit id="123">
      <lun_mapping>0</lun_mapping>
      <paths>1</paths>
      <product_id>lun0</product_id>
      <serial>123</serial>
      <size>10737418240</size>
      <status>used</status>
      <vendor_id>LIO-ORG</vendor_id>
      <volume_group_id>123</volume_group_id>
    </logical_unit>
  </logical_units>
  <type>iscsi</type>
  <host id="123"/>
</host_storage>
----

Here an example without the LUN status :

[source,xml]
----
<host_storage id="123">
  <logical_units>
    <logical_unit id="123">
      <lun_mapping>0</lun_mapping>
      <paths>1</paths>
      <product_id>lun0</product_id>
      <serial>123</serial>
      <size>10737418240</size>
      <vendor_id>LIO-ORG</vendor_id>
      <volume_group_id>123</volume_group_id>
    </logical_unit>
  </logical_units>
  <type>iscsi</type>
  <host id="123"/>
</host_storage>
----

@return [Array<HostStorage>]

# File lib/ovirtsdk4/services.rb, line 11492
def list(opts = {})
  query = {}
  value = opts[:report_status]
  unless value.nil?
    value = Writer.render_boolean(value)
    query['report_status'] = value
  end
  request = HttpRequest.new(method: :GET, url: @path, query: query)
  response = @connection.send(request)
  case response.code
  when 200
    begin
      reader = XmlReader.new(response.body)
      return HostStorageReader.read_many(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end
service(path) click to toggle source

Locates the service corresponding to the given path.

@param path [String] The path of the service.

@return [Service] A reference to the service.

# File lib/ovirtsdk4/services.rb, line 11532
def service(path)
  if path.nil? || path == ''
    return self
  end
  index = path.index('/')
  if index.nil?
    return storage_service(path)
  end
  return storage_service(path[0..(index - 1)]).service(path[(index +1)..-1])
end
storage_service(id) click to toggle source

Reference to a service managing the storage.

@param id [String] The identifier of the `storage`.

@return [StorageService] A reference to the `storage` service.

# File lib/ovirtsdk4/services.rb, line 11521
def storage_service(id)
  StorageService.new(@connection, "#{@path}/#{id}")
end
to_s() click to toggle source

Returns an string representation of this service.

@return [String]

# File lib/ovirtsdk4/services.rb, line 11548
def to_s
  "#<#{HostStorageService}:#{@path}>"
end