class OvirtSDK4::GlusterBrickService

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

Public Instance Methods

get(opts = {}) click to toggle source

Get details of a brick.

Retrieves status details of brick from underlying gluster volume with header `All-Content` set to `true`. This is the equivalent of running `gluster volume status <volumename> <brickname> detail`.

For example, to get the details of brick `234` of gluster volume `123`, send a request like this:

source

GET /ovirt-engine/api/clusters/567/glustervolumes/123/glusterbricks/234


Which will return a response body like this:

source,xml

<brick id=“234”>

<name>host1:/rhgs/data/brick1</name>
<brick_dir>/rhgs/data/brick1</brick_dir>
<server_id>111</server_id>
<status>up</status>
<device>/dev/mapper/RHGS_vg1-lv_vmaddldisks</device>
<fs_name>xfs</fs_name>
<gluster_clients>
  <gluster_client>
    <bytes_read>2818417648</bytes_read>
    <bytes_written>1384694844</bytes_written>
    <client_port>1011</client_port>
    <host_name>client2</host_name>
  </gluster_client>
</gluster_clients>
<memory_pools>
  <memory_pool>
    <name>data-server:fd_t</name>
    <alloc_count>1626348</alloc_count>
    <cold_count>1020</cold_count>
    <hot_count>4</hot_count>
    <max_alloc>23</max_alloc>
    <max_stdalloc>0</max_stdalloc>
    <padded_size>140</padded_size>
    <pool_misses>0</pool_misses>
  </memory_pool>
</memory_pools>
<mnt_options>rw,seclabel,noatime,nodiratime,attr2,inode64,sunit=512,swidth=2048,noquota</mnt_options>
<pid>25589</pid>
<port>49155</port>

</brick>


@param opts [Hash] Additional options.

@return [GlusterBrick]

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

Removes a brick.

Removes a brick from the underlying gluster volume and deletes entries from database. This can be used only when removing a single brick without data migration. To remove multiple bricks and with data migration, use <<services/gluster_bricks/methods/migrate, migrate>> instead.

For example, to delete brick `234` from gluster volume `123`, send a request like this:

source

DELETE /ovirt-engine/api/clusters/567/glustervolumes/123/glusterbricks/234


@param opts [Hash] Additional options.

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

# File lib/ovirtsdk4/services.rb, line 35008
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
replace(opts = {}) click to toggle source

Replaces this brick with a new one.

IMPORTANT: This operation has been deprecated since version 3.5 of the engine and will be removed in the future. Use <<services/gluster_bricks/methods/add, add brick(s)>> and <<services/gluster_bricks/methods/migrate, migrate brick(s)>> instead.

@param opts [Hash] Additional options.

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

@option opts [Boolean] :force

# File lib/ovirtsdk4/services.rb, line 35035
def replace(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}/replace",
    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 35071
def service(path)
  if path.nil? || path == ''
    return self
  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
statistics_service() click to toggle source

Locates the `statistics` service.

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

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

Returns an string representation of this service.

@return [String]

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