Class: OvirtSDK4::DataCenterService

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

Instance Method Summary (collapse)

Instance Method Details

- (ClustersService) clusters_service

Locates the clusters service.

Returns:



4946
4947
4948
# File 'lib/ovirtsdk4/services.rb', line 4946

def clusters_service
  return ClustersService.new(@connection, "#{@path}/clusters")
end

- (DataCenter) get(opts = {})

Returns the representation of the object managed by this service.

Parameters:

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

    Additional options.

Options Hash (opts):

  • :filter (Boolean)

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

Returns:



4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
# File 'lib/ovirtsdk4/services.rb', line 4869

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

- (IscsiBondsService) iscsi_bonds_service

Locates the iscsi_bonds service.

Returns:



4954
4955
4956
# File 'lib/ovirtsdk4/services.rb', line 4954

def iscsi_bonds_service
  return IscsiBondsService.new(@connection, "#{@path}/iscsibonds")
end

- (NetworksService) networks_service

Locates the networks service.

Returns:



4962
4963
4964
# File 'lib/ovirtsdk4/services.rb', line 4962

def networks_service
  return NetworksService.new(@connection, "#{@path}/networks")
end

- (AssignedPermissionsService) permissions_service

Locates the permissions service.

Returns:



4970
4971
4972
# File 'lib/ovirtsdk4/services.rb', line 4970

def permissions_service
  return AssignedPermissionsService.new(@connection, "#{@path}/permissions")
end

- (QossService) qoss_service

Locates the qoss service.

Returns:



4978
4979
4980
# File 'lib/ovirtsdk4/services.rb', line 4978

def qoss_service
  return QossService.new(@connection, "#{@path}/qoss")
end

- (QuotasService) quotas_service

Locates the quotas service.

Returns:



4986
4987
4988
# File 'lib/ovirtsdk4/services.rb', line 4986

def quotas_service
  return QuotasService.new(@connection, "#{@path}/quotas")
end

- (Object) remove(opts = {})

Deletes the object managed by this service.

Parameters:

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

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the remove should be performed asynchronously.



4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
# File 'lib/ovirtsdk4/services.rb', line 4898

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) 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.

Raises:

  • (Error)


5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
# File 'lib/ovirtsdk4/services.rb', line 5005

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

- (AttachedStorageDomainsService) storage_domains_service

Locates the storage_domains service.

Returns:



4994
4995
4996
# File 'lib/ovirtsdk4/services.rb', line 4994

def storage_domains_service
  return AttachedStorageDomainsService.new(@connection, "#{@path}/storagedomains")
end

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


5059
5060
5061
# File 'lib/ovirtsdk4/services.rb', line 5059

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

- (Object) update(data_center)

Updates the object managed by this service.



4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
# File 'lib/ovirtsdk4/services.rb', line 4915

def update(data_center)
  if data_center.is_a?(Hash)
    data_center = OvirtSDK4::DataCenter.new(data_center)
  end
  request = Request.new(:method => :PUT, :path => @path)
  begin
    writer = XmlWriter.new(nil, true)
    DataCenterWriter.write_one(data_center, writer, 'data_center')
    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