Class: OvirtSDK4::OpenstackVolumeProvidersService

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

Instance Method Summary (collapse)

Instance Method Details

- (OpenStackVolumeProvider) add(provider, opts = {})

Adds a new provider.

Parameters:

Returns:



14862
14863
14864
14865
14866
14867
14868
14869
14870
14871
14872
14873
14874
14875
14876
14877
14878
14879
14880
14881
14882
14883
14884
14885
14886
# File 'lib/ovirtsdk4/services.rb', line 14862

def add(provider, opts = {})
  if provider.is_a?(Hash)
    provider = OvirtSDK4::OpenStackVolumeProvider.new(provider)
  end
  request = Request.new(:method => :POST, :path => @path)
  begin
    writer = XmlWriter.new(nil, true)
    OpenStackVolumeProviderWriter.write_one(provider, writer, 'provider')
    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 OpenStackVolumeProviderReader.read_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

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

Returns the representation of the object managed by this service.

Parameters:

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

    Additional options.

Options Hash (opts):

  • :max (Integer)

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

Returns:



14897
14898
14899
14900
14901
14902
14903
14904
14905
14906
14907
14908
14909
14910
14911
14912
14913
14914
14915
14916
14917
# File 'lib/ovirtsdk4/services.rb', line 14897

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

- (OpenstackVolumeProviderService) provider_service(id)

Locates the provider service.

Parameters:

  • id (String)

    The identifier of the provider.

Returns:



14926
14927
14928
# File 'lib/ovirtsdk4/services.rb', line 14926

def provider_service(id)
  return OpenstackVolumeProviderService.new(@connection, "#{@path}/#{id}")
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.



14937
14938
14939
14940
14941
14942
14943
14944
14945
14946
# File 'lib/ovirtsdk4/services.rb', line 14937

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

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


14953
14954
14955
# File 'lib/ovirtsdk4/services.rb', line 14953

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