class OvirtSDK4::AttachedStorageDomainService

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

Public Instance Methods

activate(opts = {}) click to toggle source

This operation activates an attached storage domain. Once the storage domain is activated it is ready for use with the data center.

source

POST /ovirt-engine/api/datacenters/123/storagedomains/456/activate


The activate action does not take any action specific parameters, so the request body should contain an empty `action`:

source,xml

<action/>


@param opts [Hash] Additional options.

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

# File lib/ovirtsdk4/services.rb, line 3591
def activate(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}/activate",
    body: body
  )
  response = @connection.send(request)
  case response.code
  when 200
    action = check_action(response)
  else
    check_action(response)
  end
end
deactivate(opts = {}) click to toggle source

This operation deactivates an attached storage domain. Once the storage domain is deactivated it will not be used with the data center.

source

POST /ovirt-engine/api/datacenters/123/storagedomains/456/deactivate


The deactivate action does not take any action specific parameters, so the request body should contain an empty `action`:

source,xml

<action/>


@param opts [Hash] Additional options.

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

# File lib/ovirtsdk4/services.rb, line 3632
def deactivate(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}/deactivate",
    body: body
  )
  response = @connection.send(request)
  case response.code
  when 200
    action = check_action(response)
  else
    check_action(response)
  end
end
disks_service() click to toggle source

Locates the `disks` service.

@return [DisksService] A reference to `disks` service.

# File lib/ovirtsdk4/services.rb, line 3701
def disks_service
  DisksService.new(@connection, "#{@path}/disks")
end
get(opts = {}) click to toggle source

Returns the representation of the object managed by this service.

@param opts [Hash] Additional options.

@return [StorageDomain]

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

Deletes the object managed by this service.

@param opts [Hash] Additional options.

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

# File lib/ovirtsdk4/services.rb, line 3682
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
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 3712
def service(path)
  if path.nil? || path == ''
    return self
  end
  if path == 'disks'
    return disks_service
  end
  if path.start_with?('disks/')
    return disks_service.service(path[6..-1])
  end
  raise Error.new("The path \"#{path}\" doesn't correspond to any service")
end
to_s() click to toggle source

Returns an string representation of this service.

@return [String]

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