Class: OvirtSDK4::AssignedVnicProfilesService

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

Instance Method Summary (collapse)

Instance Method Details

- (VnicProfile) add(profile, opts = {})

Adds a new profile.

Parameters:

Returns:



3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
# File 'lib/ovirtsdk4/services.rb', line 3180

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

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

Returns:



3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
# File 'lib/ovirtsdk4/services.rb', line 3215

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

- (AssignedVnicProfileService) profile_service(id)

Locates the profile service.

Parameters:

  • id (String)

    The identifier of the profile.

Returns:



3244
3245
3246
# File 'lib/ovirtsdk4/services.rb', line 3244

def profile_service(id)
  return AssignedVnicProfileService.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.



3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
# File 'lib/ovirtsdk4/services.rb', line 3255

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

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


3271
3272
3273
# File 'lib/ovirtsdk4/services.rb', line 3271

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