class OvirtSDK4::DataCenterService

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

Public Instance Methods

clusters_service() click to toggle source

Locates the `clusters` service.

@return [ClustersService] A reference to `clusters` service.

# File lib/ovirtsdk4/services.rb, line 5116
def clusters_service
  return ClustersService.new(@connection, "#{@path}/clusters")
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 [DataCenter]

# File lib/ovirtsdk4/services.rb, line 5010
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 DataCenterReader.read_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end
iscsi_bonds_service() click to toggle source

Locates the `iscsi_bonds` service.

@return [IscsiBondsService] A reference to `iscsi_bonds` service.

# File lib/ovirtsdk4/services.rb, line 5124
def iscsi_bonds_service
  return IscsiBondsService.new(@connection, "#{@path}/iscsibonds")
end
networks_service() click to toggle source

Locates the `networks` service.

@return [NetworksService] A reference to `networks` service.

# File lib/ovirtsdk4/services.rb, line 5132
def networks_service
  return NetworksService.new(@connection, "#{@path}/networks")
end
permissions_service() click to toggle source

Locates the `permissions` service.

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

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

Locates the `qoss` service.

@return [QossService] A reference to `qoss` service.

# File lib/ovirtsdk4/services.rb, line 5148
def qoss_service
  return QossService.new(@connection, "#{@path}/qoss")
end
quotas_service() click to toggle source

Locates the `quotas` service.

@return [QuotasService] A reference to `quotas` service.

# File lib/ovirtsdk4/services.rb, line 5156
def quotas_service
  return QuotasService.new(@connection, "#{@path}/quotas")
end
remove(opts = {}) click to toggle source

Removes the data center.

Without any special parameters, the storage domains attached to the data center are detached and then removed from the storage. If something fails when performing this operation, for example if there is no host available to remove the storage domains from the storage, the complete operation will fail.

If the `force` parameter is `true` then the operation will always succeed, even if something fails while removing one storage domain, for example. The failure is just ignored and the data center is removed from the database anyway.

@param opts [Hash] Additional options.

@option opts [Boolean] :async Indicates if the remove should be performed asynchronously. @option opts [Boolean] :force Indicates if the operation should succeed, and the storage domain removed from the database, even if

something fails during the operation.

This parameter is optional, and the default value is `false`.
# File lib/ovirtsdk4/services.rb, line 5050
def remove(opts = {})
  query = {}
  value = opts[:async]
  unless value.nil?
    value = Writer.render_boolean(value)
    query['async'] = value
  end
  value = opts[:force]
  unless value.nil?
    value = Writer.render_boolean(value)
    query['force'] = 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 5175
def service(path)
  if path.nil? || path == ''
    return self
  end
  if path == 'clusters'
    return clusters_service
  end
  if path.start_with?('clusters/')
    return clusters_service.service(path[9..-1])
  end
  if path == 'iscsibonds'
    return iscsi_bonds_service
  end
  if path.start_with?('iscsibonds/')
    return iscsi_bonds_service.service(path[11..-1])
  end
  if path == 'networks'
    return networks_service
  end
  if path.start_with?('networks/')
    return networks_service.service(path[9..-1])
  end
  if path == 'permissions'
    return permissions_service
  end
  if path.start_with?('permissions/')
    return permissions_service.service(path[12..-1])
  end
  if path == 'qoss'
    return qoss_service
  end
  if path.start_with?('qoss/')
    return qoss_service.service(path[5..-1])
  end
  if path == 'quotas'
    return quotas_service
  end
  if path.start_with?('quotas/')
    return quotas_service.service(path[7..-1])
  end
  if path == 'storagedomains'
    return storage_domains_service
  end
  if path.start_with?('storagedomains/')
    return storage_domains_service.service(path[15..-1])
  end
  raise Error.new("The path \"#{path}\" doesn't correspond to any service")
end
storage_domains_service() click to toggle source

Locates the `storage_domains` service.

@return [AttachedStorageDomainsService] A reference to `storage_domains` service.

# File lib/ovirtsdk4/services.rb, line 5164
def storage_domains_service
  return AttachedStorageDomainsService.new(@connection, "#{@path}/storagedomains")
end
to_s() click to toggle source

Returns an string representation of this service.

@return [String]

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

Updates the `data_center`.

@param data_center [DataCenter] The `data_center` to update. @param opts [Hash] Additional options.

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

@return [DataCenter]

# File lib/ovirtsdk4/services.rb, line 5079
def update(data_center)
  if data_center.is_a?(Hash)
    data_center = OvirtSDK4::DataCenter.new(data_center)
  end
  query = {}
  value = opts[:async]
  unless value.nil?
    value = Writer.render_boolean(value)
    query['async'] = value
  end
  request = Request.new(:method => :PUT, :path => @path, :query => query)
  begin
    writer = XmlWriter.new(nil, true)
    DataCenterWriter.write_one(data_center, writer)
    request.body = writer.string
  ensure
    writer.close
  end
  response = @connection.send(request)
  case response.code
  when 200
    begin
      reader = XmlReader.new(response.body)
      return DataCenterReader.read_one(reader)
    ensure
      reader.close
    end
    return result
  else
    check_fault(response)
  end
end