class OvirtSDK4::StorageDomainService

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

Public Instance Methods

disk_profiles_service() click to toggle source

Locates the `disk_profiles` service.

@return [AssignedDiskProfilesService] A reference to `disk_profiles` service.

# File lib/ovirtsdk4/services.rb, line 18666
def disk_profiles_service
  return AssignedDiskProfilesService.new(@connection, "#{@path}/diskprofiles")
end
disk_snapshots_service() click to toggle source

Locates the `disk_snapshots` service.

@return [DiskSnapshotsService] A reference to `disk_snapshots` service.

# File lib/ovirtsdk4/services.rb, line 18674
def disk_snapshots_service
  return DiskSnapshotsService.new(@connection, "#{@path}/disksnapshots")
end
disks_service() click to toggle source

Locates the `disks` service.

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

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

Locates the `files` service.

@return [FilesService] A reference to `files` service.

# File lib/ovirtsdk4/services.rb, line 18690
def files_service
  return FilesService.new(@connection, "#{@path}/files")
end
get(opts = {}) click to toggle source

Returns the representation of the object managed by this service.

@param opts [Hash] Additional options.

@option opts [Boolean] :filter Indicates if the results should be filtered according to the permissions of the user.

@return [StorageDomain]

# File lib/ovirtsdk4/services.rb, line 18504
def get(opts = {})
  query = {}
  value = opts[:filter]
  unless value.nil?
    value = Writer.render_boolean(value)
    query['filter'] = value
  end
  request = Request.new(:method => :GET, :path => @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
images_service() click to toggle source

Locates the `images` service.

@return [ImagesService] A reference to `images` service.

# File lib/ovirtsdk4/services.rb, line 18698
def images_service
  return ImagesService.new(@connection, "#{@path}/images")
end
is_attached(opts = {}) click to toggle source

Executes the `is_attached` method.

# File lib/ovirtsdk4/services.rb, line 18529
def is_attached(opts = {})
  action = Action.new(opts)
  writer = XmlWriter.new(nil, true)
  ActionWriter.write_one(action, writer)
  body = writer.string
  writer.close
  request = Request.new({
  :method => :POST,
  :path => "#{@path}/isattached",
  :body => body,
  })
  response = @connection.send(request)
  case response.code
  when 200
    action = check_action(response)
    return action.is_attached
  else
    check_fault(response)
  end
end
permissions_service() click to toggle source

Locates the `permissions` service.

@return [AssignedPermissionsService] A reference to `permissions` service.

# File lib/ovirtsdk4/services.rb, line 18706
def permissions_service
  return AssignedPermissionsService.new(@connection, "#{@path}/permissions")
end
refresh_luns(opts = {}) click to toggle source

Executes the `refresh_luns` method.

# File lib/ovirtsdk4/services.rb, line 18553
def refresh_luns(opts = {})
  action = Action.new(opts)
  writer = XmlWriter.new(nil, true)
  ActionWriter.write_one(action, writer)
  body = writer.string
  writer.close
  request = Request.new({
  :method => :POST,
  :path => "#{@path}/refreshluns",
  :body => body,
  })
  response = @connection.send(request)
  case response.code
  when 200
    action = check_action(response)
  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 18580
def remove(opts = {})
  query = {}
  value = opts[:async]
  unless value.nil?
    value = Writer.render_boolean(value)
    query['async'] = value
  end
  request = Request.new(:method => :DELETE, :path => @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 18741
def service(path)
  if path.nil? || path == ''
    return self
  end
  if path == 'diskprofiles'
    return disk_profiles_service
  end
  if path.start_with?('diskprofiles/')
    return disk_profiles_service.service(path[13..-1])
  end
  if path == 'disksnapshots'
    return disk_snapshots_service
  end
  if path.start_with?('disksnapshots/')
    return disk_snapshots_service.service(path[14..-1])
  end
  if path == 'disks'
    return disks_service
  end
  if path.start_with?('disks/')
    return disks_service.service(path[6..-1])
  end
  if path == 'files'
    return files_service
  end
  if path.start_with?('files/')
    return files_service.service(path[6..-1])
  end
  if path == 'images'
    return images_service
  end
  if path.start_with?('images/')
    return images_service.service(path[7..-1])
  end
  if path == 'permissions'
    return permissions_service
  end
  if path.start_with?('permissions/')
    return permissions_service.service(path[12..-1])
  end
  if path == 'storageconnections'
    return storage_connections_service
  end
  if path.start_with?('storageconnections/')
    return storage_connections_service.service(path[19..-1])
  end
  if path == 'templates'
    return templates_service
  end
  if path.start_with?('templates/')
    return templates_service.service(path[10..-1])
  end
  if path == 'vms'
    return vms_service
  end
  if path.start_with?('vms/')
    return vms_service.service(path[4..-1])
  end
  raise Error.new("The path \"#{path}\" doesn't correspond to any service")
end
storage_connections_service() click to toggle source

Locates the `storage_connections` service.

@return [StorageDomainServerConnectionsService] A reference to `storage_connections` service.

# File lib/ovirtsdk4/services.rb, line 18714
def storage_connections_service
  return StorageDomainServerConnectionsService.new(@connection, "#{@path}/storageconnections")
end
templates_service() click to toggle source

Locates the `templates` service.

@return [StorageDomainTemplatesService] A reference to `templates` service.

# File lib/ovirtsdk4/services.rb, line 18722
def templates_service
  return StorageDomainTemplatesService.new(@connection, "#{@path}/templates")
end
to_s() click to toggle source

Returns an string representation of this service.

@return [String]

# File lib/ovirtsdk4/services.rb, line 18807
def to_s
  return "#<#{StorageDomainService}:#{@path}>"
end
update(storage_domain) click to toggle source

Updates the object managed by this service.

# File lib/ovirtsdk4/services.rb, line 18597
def update(storage_domain)
  if storage_domain.is_a?(Hash)
    storage_domain = OvirtSDK4::StorageDomain.new(storage_domain)
  end
  request = Request.new(:method => :PUT, :path => @path)
  begin
    writer = XmlWriter.new(nil, true)
    StorageDomainWriter.write_one(storage_domain, writer, 'storage_domain')
    request.body = writer.string
  ensure
    writer.close
  end
  response = @connection.send(request)
  case response.code
  when 200
    begin
      reader = XmlReader.new(response.body)
      return StorageDomainReader.read_one(reader)
    ensure
      reader.close
    end
    return result
  else
    check_fault(response)
  end
end
update_ovf_store(opts = {}) click to toggle source

This operation forces the update of the `OVF_STORE` of this storage domain.

The `OVF_STORE` is a disk image that contains the meta-data of virtual machines and disks that reside in the storage domain. This meta-data is used in case the domain is imported or exported to or from a different data center or a different installation.

By default the `OVF_STORE` is updated periodically (set by default to 60 minutes) but users might want to force an update after an important change, or when the they believe the `OVF_STORE` is corrupt.

When initiated by the user, `OVF_STORE` update will be performed whether an update is needed or not.

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

Locates the `vms` service.

@return [StorageDomainVmsService] A reference to `vms` service.

# File lib/ovirtsdk4/services.rb, line 18730
def vms_service
  return StorageDomainVmsService.new(@connection, "#{@path}/vms")
end