class OvirtSDK4::GlusterVolumeService

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 35106
def initialize(connection, path)
  @connection = connection
  @path = path
end

Public Instance Methods

get(opts = {}) click to toggle source

Get the gluster volume details.

For example, to get details of a gluster volume with identifier `123` in cluster `456`, send a request like this:

source

GET /ovirt-engine/api/clusters/456/glustervolumes/123


This GET request will return the following output:

source,xml

<gluster_volume id=“123”>

<name>data</name>
<link href="/ovirt-engine/api/clusters/456/glustervolumes/123/glusterbricks" rel="glusterbricks"/>
<disperse_count>0</disperse_count>
<options>
  <option>
    <name>storage.owner-gid</name>
    <value>36</value>
  </option>
  <option>
    <name>performance.io-cache</name>
    <value>off</value>
  </option>
  <option>
    <name>cluster.data-self-heal-algorithm</name>
    <value>full</value>
  </option>
</options>
<redundancy_count>0</redundancy_count>
<replica_count>3</replica_count>
<status>up</status>
<stripe_count>0</stripe_count>
<transport_types>
  <transport_type>tcp</transport_type>
</transport_types>
<volume_type>replicate</volume_type>
</gluster_volume>

@param opts [Hash] Additional options.

@return [GlusterVolume]

# File lib/ovirtsdk4/services.rb, line 35158
def get(opts = {})
  query = {}
  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 GlusterVolumeReader.read_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end
get_profile_statistics(opts = {}) click to toggle source

Get gluster volume profile statistics.

For example, to get profile statistics for a gluster volume with identifier `123` in cluster `456`, send a request like this:

source

POST /ovirt-engine/api/clusters/456/glustervolumes/123/getprofilestatistics


@param opts [Hash] Additional options.

@option opts [GlusterVolumeProfileDetails] :details Gluster volume profiling information returned from the action.

# File lib/ovirtsdk4/services.rb, line 35190
def get_profile_statistics(opts = {})
  action = Action.new(opts)
  writer = XmlWriter.new(nil, true)
  ActionWriter.write_one(action, writer)
  body = writer.string
  writer.close
  request = HttpRequest.new(
    method: :POST,
    url: "#{@path}/getprofilestatistics",
    body: body
  )
  response = @connection.send(request)
  case response.code
  when 200
    action = check_action(response)
    return action.details
  else
    check_action(response)
  end
end
gluster_bricks_service() click to toggle source

Reference to a service managing gluster bricks.

@return [GlusterBricksService] A reference to `gluster_bricks` service.

# File lib/ovirtsdk4/services.rb, line 35597
def gluster_bricks_service
  GlusterBricksService.new(@connection, "#{@path}/glusterbricks")
end
rebalance(opts = {}) click to toggle source

Rebalance the gluster volume.

Rebalancing a gluster volume helps to distribute the data evenly across all the bricks. After expanding or shrinking a gluster volume (without migrating data), we need to rebalance the data among the bricks. In a non-replicated volume, all bricks should be online to perform the rebalance operation. In a replicated volume, at least one of the bricks in the replica should be online.

For example, to rebalance a gluster volume with identifier `123` in cluster `456`, send a request like this:

source

POST /ovirt-engine/api/clusters/456/glustervolumes/123/rebalance


@param opts [Hash] Additional options.

@option opts [Boolean] :async Indicates if the rebalance should be performed asynchronously.

@option opts [Boolean] :fix_layout If set to true, rebalance will only fix the layout so that new data added to the volume is distributed

across all the hosts. But it will not migrate/rebalance the existing data. Default is `false`.

@option opts [Boolean] :force Indicates if the rebalance should be force started. The rebalance command can be executed with the force

option even when the older clients are connected to the cluster. However, this could lead to a data loss
situation. Default is `false`.
# File lib/ovirtsdk4/services.rb, line 35237
def rebalance(opts = {})
  action = Action.new(opts)
  writer = XmlWriter.new(nil, true)
  ActionWriter.write_one(action, writer)
  body = writer.string
  writer.close
  request = HttpRequest.new(
    method: :POST,
    url: "#{@path}/rebalance",
    body: body
  )
  response = @connection.send(request)
  case response.code
  when 200
    action = check_action(response)
  else
    check_action(response)
  end
end
remove(opts = {}) click to toggle source

Removes the gluster volume.

For example, to remove a volume with identifier `123` in cluster `456`, send a request like this:

source

DELETE /ovirt-engine/api/clusters/456/glustervolumes/123


@param opts [Hash] Additional options.

@option opts [Boolean] :async Indicates if the remove should be performed asynchronously.

# File lib/ovirtsdk4/services.rb, line 35270
def remove(opts = {})
  query = {}
  value = opts[:async]
  unless value.nil?
    value = Writer.render_boolean(value)
    query['async'] = value
  end
  request = HttpRequest.new(method: :DELETE, url: @path, query: query)
  response = @connection.send(request)
  unless response.code == 200
    check_fault(response)
  end
end
reset_all_options(opts = {}) click to toggle source

Resets all the options set in the gluster volume.

For example, to reset all options in a gluster volume with identifier `123` in cluster `456`, send a request like this:

source

POST /ovirt-engine/api/clusters/456/glustervolumes/123/resetalloptions


@param opts [Hash] Additional options.

@option opts [Boolean] :async Indicates if the reset should be performed asynchronously.

# File lib/ovirtsdk4/services.rb, line 35299
def reset_all_options(opts = {})
  action = Action.new(opts)
  writer = XmlWriter.new(nil, true)
  ActionWriter.write_one(action, writer)
  body = writer.string
  writer.close
  request = HttpRequest.new(
    method: :POST,
    url: "#{@path}/resetalloptions",
    body: body
  )
  response = @connection.send(request)
  case response.code
  when 200
    action = check_action(response)
  else
    check_action(response)
  end
end
reset_option(opts = {}) click to toggle source

Resets a particular option in the gluster volume.

For example, to reset a particular option `option1` in a gluster volume with identifier `123` in cluster `456`, send a request like this:

source

POST /ovirt-engine/api/clusters/456/glustervolumes/123/resetoption


With the following request body:

source,xml

<action>

<option name="option1"/>

</action>


@param opts [Hash] Additional options.

@option opts [Boolean] :async Indicates if the reset should be performed asynchronously.

@option opts [Boolean] :force

@option opts [Option] :option Option to reset.

# File lib/ovirtsdk4/services.rb, line 35347
def reset_option(opts = {})
  action = Action.new(opts)
  writer = XmlWriter.new(nil, true)
  ActionWriter.write_one(action, writer)
  body = writer.string
  writer.close
  request = HttpRequest.new(
    method: :POST,
    url: "#{@path}/resetoption",
    body: body
  )
  response = @connection.send(request)
  case response.code
  when 200
    action = check_action(response)
  else
    check_action(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 35617
def service(path)
  if path.nil? || path == ''
    return self
  end
  if path == 'glusterbricks'
    return gluster_bricks_service
  end
  if path.start_with?('glusterbricks/')
    return gluster_bricks_service.service(path[14..-1])
  end
  if path == 'statistics'
    return statistics_service
  end
  if path.start_with?('statistics/')
    return statistics_service.service(path[11..-1])
  end
  raise Error.new("The path \"#{path}\" doesn't correspond to any service")
end
set_option(opts = {}) click to toggle source

Sets a particular option in the gluster volume.

For example, to set `option1` with value `value1` in a gluster volume with identifier `123` in cluster `456`, send a request like this:

source

POST /ovirt-engine/api/clusters/456/glustervolumes/123/setoption


With the following request body:

source,xml

<action>

<option name="option1" value="value1"/>

</action>


@param opts [Hash] Additional options.

@option opts [Boolean] :async Indicates if the action should be performed asynchronously.

@option opts [Option] :option Option to set.

# File lib/ovirtsdk4/services.rb, line 35393
def set_option(opts = {})
  action = Action.new(opts)
  writer = XmlWriter.new(nil, true)
  ActionWriter.write_one(action, writer)
  body = writer.string
  writer.close
  request = HttpRequest.new(
    method: :POST,
    url: "#{@path}/setoption",
    body: body
  )
  response = @connection.send(request)
  case response.code
  when 200
    action = check_action(response)
  else
    check_action(response)
  end
end
start(opts = {}) click to toggle source

Starts the gluster volume.

A Gluster Volume should be started to read/write data. For example, to start a gluster volume with identifier `123` in cluster `456`, send a request like this:

source

POST /ovirt-engine/api/clusters/456/glustervolumes/123/start


@param opts [Hash] Additional options.

@option opts [Boolean] :async Indicates if the action should be performed asynchronously.

@option opts [Boolean] :force Indicates if the volume should be force started. If a gluster volume is started already but few/all bricks

are down then force start can be used to bring all the bricks up. Default is `false`.
# File lib/ovirtsdk4/services.rb, line 35431
def start(opts = {})
  action = Action.new(opts)
  writer = XmlWriter.new(nil, true)
  ActionWriter.write_one(action, writer)
  body = writer.string
  writer.close
  request = HttpRequest.new(
    method: :POST,
    url: "#{@path}/start",
    body: body
  )
  response = @connection.send(request)
  case response.code
  when 200
    action = check_action(response)
  else
    check_action(response)
  end
end
start_profile(opts = {}) click to toggle source

Start profiling the gluster volume.

For example, to start profiling a gluster volume with identifier `123` in cluster `456`, send a request like this:

source

POST /ovirt-engine/api/clusters/456/glustervolumes/123/startprofile


@param opts [Hash] Additional options.

@option opts [Boolean] :async Indicates if the action should be performed asynchronously.

# File lib/ovirtsdk4/services.rb, line 35465
def start_profile(opts = {})
  action = Action.new(opts)
  writer = XmlWriter.new(nil, true)
  ActionWriter.write_one(action, writer)
  body = writer.string
  writer.close
  request = HttpRequest.new(
    method: :POST,
    url: "#{@path}/startprofile",
    body: body
  )
  response = @connection.send(request)
  case response.code
  when 200
    action = check_action(response)
  else
    check_action(response)
  end
end
statistics_service() click to toggle source

Locates the `statistics` service.

@return [StatisticsService] A reference to `statistics` service.

# File lib/ovirtsdk4/services.rb, line 35606
def statistics_service
  StatisticsService.new(@connection, "#{@path}/statistics")
end
stop(opts = {}) click to toggle source

Stops the gluster volume.

Stopping a volume will make its data inaccessible.

For example, to stop a gluster volume with identifier `123` in cluster `456`, send a request like this:

source

POST /ovirt-engine/api/clusters/456/glustervolumes/123/stop


@param opts [Hash] Additional options.

@option opts [Boolean] :async Indicates if the action should be performed asynchronously.

@option opts [Boolean] :force

# File lib/ovirtsdk4/services.rb, line 35503
def stop(opts = {})
  action = Action.new(opts)
  writer = XmlWriter.new(nil, true)
  ActionWriter.write_one(action, writer)
  body = writer.string
  writer.close
  request = HttpRequest.new(
    method: :POST,
    url: "#{@path}/stop",
    body: body
  )
  response = @connection.send(request)
  case response.code
  when 200
    action = check_action(response)
  else
    check_action(response)
  end
end
stop_profile(opts = {}) click to toggle source

Stop profiling the gluster volume.

For example, to stop profiling a gluster volume with identifier `123` in cluster `456`, send a request like this:

source

POST /ovirt-engine/api/clusters/456/glustervolumes/123/stopprofile


@param opts [Hash] Additional options.

@option opts [Boolean] :async Indicates if the action should be performed asynchronously.

# File lib/ovirtsdk4/services.rb, line 35537
def stop_profile(opts = {})
  action = Action.new(opts)
  writer = XmlWriter.new(nil, true)
  ActionWriter.write_one(action, writer)
  body = writer.string
  writer.close
  request = HttpRequest.new(
    method: :POST,
    url: "#{@path}/stopprofile",
    body: body
  )
  response = @connection.send(request)
  case response.code
  when 200
    action = check_action(response)
  else
    check_action(response)
  end
end
stop_rebalance(opts = {}) click to toggle source

Stop rebalancing the gluster volume.

For example, to stop rebalancing a gluster volume with identifier `123` in cluster `456`, send a request like this:

source

POST /ovirt-engine/api/clusters/456/glustervolumes/123/stoprebalance


@param opts [Hash] Additional options.

@option opts [Boolean] :async Indicates if the action should be performed asynchronously.

# File lib/ovirtsdk4/services.rb, line 35572
def stop_rebalance(opts = {})
  action = Action.new(opts)
  writer = XmlWriter.new(nil, true)
  ActionWriter.write_one(action, writer)
  body = writer.string
  writer.close
  request = HttpRequest.new(
    method: :POST,
    url: "#{@path}/stoprebalance",
    body: body
  )
  response = @connection.send(request)
  case response.code
  when 200
    action = check_action(response)
  else
    check_action(response)
  end
end
to_s() click to toggle source

Returns an string representation of this service.

@return [String]

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