Class: OvirtSDK4::OpenstackNetworksService

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

Instance Method Summary (collapse)

Instance Method Details

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

Returns:



14131
14132
14133
14134
14135
14136
14137
14138
14139
14140
14141
14142
14143
14144
14145
14146
14147
14148
14149
14150
14151
# File 'lib/ovirtsdk4/services.rb', line 14131

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

- (OpenstackNetworkService) network_service(id)

Locates the network service.

Parameters:

  • id (String)

    The identifier of the network.

Returns:



14160
14161
14162
# File 'lib/ovirtsdk4/services.rb', line 14160

def network_service(id)
  return OpenstackNetworkService.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.



14171
14172
14173
14174
14175
14176
14177
14178
14179
14180
# File 'lib/ovirtsdk4/services.rb', line 14171

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

- (String) to_s

Returns an string representation of this service.

Returns:

  • (String)


14187
14188
14189
# File 'lib/ovirtsdk4/services.rb', line 14187

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