Class: OvirtSDK4::MacPoolsService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::MacPoolsService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (MacPool) add(pool, opts = {})
Adds a new
pool
. -
- (Array<MacPool>) list(opts = {})
Returns the representation of the object managed by this service.
-
- (MacPoolService) mac_pool_service(id)
Locates the
mac_pool
service. -
- (Service) service(path)
Locates the service corresponding to the given path.
-
- (String) to_s
Returns an string representation of this service.
Instance Method Details
- (MacPool) add(pool, opts = {})
Adds a new pool
.
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.
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.
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.
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.
12202 12203 12204 |
# File 'lib/ovirtsdk4/services.rb', line 12202 def to_s return "#<#{MacPoolsService}:#{@path}>" end |