Class: OvirtSDK4::VnicProfilesService

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:



27110
27111
27112
27113
27114
27115
27116
27117
27118
27119
27120
27121
27122
27123
27124
27125
27126
27127
27128
27129
27130
27131
27132
27133
27134
# File 'lib/ovirtsdk4/services.rb', line 27110

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:



27145
27146
27147
27148
27149
27150
27151
27152
27153
27154
27155
27156
27157
27158
27159
27160
27161
27162
27163
27164
27165
# File 'lib/ovirtsdk4/services.rb', line 27145

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

- (VnicProfileService) profile_service(id)

Locates the profile service.

Parameters:

  • id (String)

    The identifier of the profile.

Returns:



27174
27175
27176
# File 'lib/ovirtsdk4/services.rb', line 27174

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



27185
27186
27187
27188
27189
27190
27191
27192
27193
27194
# File 'lib/ovirtsdk4/services.rb', line 27185

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)


27201
27202
27203
# File 'lib/ovirtsdk4/services.rb', line 27201

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