Class: OvirtSDK4::MacPoolsService

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

Instance Method Summary (collapse)

Instance Method Details

- (MacPool) add(pool, opts = {})

Adds a new pool.

Parameters:

Returns:



12111
12112
12113
12114
12115
12116
12117
12118
12119
12120
12121
12122
12123
12124
12125
12126
12127
12128
12129
12130
12131
12132
12133
12134
12135
# File 'lib/ovirtsdk4/services.rb', line 12111

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

- (Array<MacPool>) 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 pools to return. If not specified all the pools are returned.

Returns:



12146
12147
12148
12149
12150
12151
12152
12153
12154
12155
12156
12157
12158
12159
12160
12161
12162
12163
12164
12165
12166
# File 'lib/ovirtsdk4/services.rb', line 12146

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 MacPoolReader.read_many(reader)
    ensure
      reader.close
    end
  else
    check_fault(response)
  end
end

- (MacPoolService) mac_pool_service(id)

Locates the mac_pool service.

Parameters:

  • id (String)

    The identifier of the mac_pool.

Returns:



12175
12176
12177
# File 'lib/ovirtsdk4/services.rb', line 12175

def mac_pool_service(id)
  return MacPoolService.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.



12186
12187
12188
12189
12190
12191
12192
12193
12194
12195
# File 'lib/ovirtsdk4/services.rb', line 12186

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

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


12202
12203
12204
# File 'lib/ovirtsdk4/services.rb', line 12202

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