Class: OvirtSDK4::StorageServerConnectionService

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

Instance Method Summary (collapse)

Instance Method Details

- (StorageConnection) get(opts = {})

Returns the representation of the object managed by this service.

Parameters:

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

    Additional options.

Returns:



20064
20065
20066
20067
20068
20069
20070
20071
20072
20073
20074
20075
20076
20077
20078
20079
# File 'lib/ovirtsdk4/services.rb', line 20064

def get(opts = {})
  query = {}
  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 StorageConnectionReader.read_one(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
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.



20088
20089
20090
20091
20092
20093
20094
20095
20096
20097
20098
20099
20100
# File 'lib/ovirtsdk4/services.rb', line 20088

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)


20139
20140
20141
20142
20143
20144
# File 'lib/ovirtsdk4/services.rb', line 20139

def service(path)
  if path.nil? || path == ''
    return self
  end
  raise Error.new("The path \"#{path}\" doesn't correspond to any service")
end

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


20151
20152
20153
# File 'lib/ovirtsdk4/services.rb', line 20151

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

- (Object) update(connection)

Updates the object managed by this service.



20105
20106
20107
20108
20109
20110
20111
20112
20113
20114
20115
20116
20117
20118
20119
20120
20121
20122
20123
20124
20125
20126
20127
20128
20129
20130
# File 'lib/ovirtsdk4/services.rb', line 20105

def update(connection)
  if connection.is_a?(Hash)
    connection = OvirtSDK4::StorageConnection.new(connection)
  end
  request = Request.new(:method => :PUT, :path => @path)
  begin
    writer = XmlWriter.new(nil, true)
    StorageConnectionWriter.write_one(connection, writer, 'connection')
    request.body = writer.string
  ensure
    writer.close
  end
  response = @connection.send(request)
  case response.code
  when 200
    begin
      reader = XmlReader.new(response.body)
      return StorageConnectionReader.read_one(reader)
    ensure
      reader.close
    end
    return result
  else
    check_fault(response)
  end
end