Class: OvirtSDK4::ClustersService

Inherits:
Service
  • Object
show all
Defined in:
lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb

Instance Method Summary (collapse)

Instance Method Details

- (Cluster) add(cluster, opts = {})

Adds a new cluster.

Parameters:

Returns:



4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
# File 'lib/ovirtsdk4/services.rb', line 4411

def add(cluster, opts = {})
  if cluster.is_a?(Hash)
    cluster = OvirtSDK4::Cluster.new(cluster)
  end
  request = Request.new(:method => :POST, :path => @path)
  begin
    writer = XmlWriter.new(nil, true)
    ClusterWriter.write_one(cluster, writer, 'cluster')
    request.body = writer.string
  ensure
    writer.close
  end
  response = @connection.send(request)
  case response.code
  when 201, 202
    begin
      reader = XmlReader.new(response.body)
      return ClusterReader.read_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (ClusterService) cluster_service(id)

Locates the cluster service.

Parameters:

  • id (String)

    The identifier of the cluster.

Returns:



4497
4498
4499
# File 'lib/ovirtsdk4/services.rb', line 4497

def cluster_service(id)
  return ClusterService.new(@connection, "#{@path}/#{id}")
end

- (Array<Cluster>) list(opts = {})

Returns the representation of the object managed by this service.

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :case_sensitive (Boolean)

    Indicates if the search performed using the search parameter should be performed taking case into account. The default value is true, which means that case is taken into account. If you want to search ignoring case set it to false.

  • :filter (Boolean)

    Indicates if the results should be filtered according to the permissions of the user.

  • :max (Integer)

    Sets the maximum number of clusters to return. If not specified all the clusters are returned.

  • :search (String)

    A query string used to restrict the returned clusters.

Returns:



4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
# File 'lib/ovirtsdk4/services.rb', line 4454

def list(opts = {})
  query = {}
  value = opts[:case_sensitive]
  unless value.nil?
    value = Writer.render_boolean(value)
    query['case_sensitive'] = value
  end
  value = opts[:filter]
  unless value.nil?
    value = Writer.render_boolean(value)
    query['filter'] = value
  end
  value = opts[:max]
  unless value.nil?
    value = Writer.render_integer(value)
    query['max'] = value
  end
  value = opts[:search]
  unless value.nil?
    query['search'] = 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 ClusterReader.read_many(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (Service) service(path)

Locates the service corresponding to the given path.

Parameters:

  • path (String)

    The path of the service.

Returns:

  • (Service)

    A reference to the service.



4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
# File 'lib/ovirtsdk4/services.rb', line 4508

def service(path)
  if path.nil? || path == ''
    return self
  end
  index = path.index('/')
  if index.nil?
    return cluster_service(path)
  end
  return cluster_service(path[0..(index - 1)]).service(path[(index +1)..-1])
end

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


4524
4525
4526
# File 'lib/ovirtsdk4/services.rb', line 4524

def to_s
  return "#<#{ClustersService}:#{@path}>"
end