Class: OvirtSDK4::VmHostDevicesService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::VmHostDevicesService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (HostDevice) add(device, opts = {})
Adds a new
device
. -
- (VmHostDeviceService) device_service(id)
Locates the
device
service. -
- (Array<HostDevice>) list(opts = {})
Returns the representation of the object managed by this 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
- (HostDevice) add(device, opts = {})
Adds a new device
.
25167 25168 25169 25170 25171 25172 25173 25174 25175 25176 25177 25178 25179 25180 25181 25182 25183 25184 25185 25186 25187 25188 25189 25190 25191 |
# File 'lib/ovirtsdk4/services.rb', line 25167 def add(device, opts = {}) if device.is_a?(Hash) device = OvirtSDK4::HostDevice.new(device) end request = Request.new(:method => :POST, :path => @path) begin writer = XmlWriter.new(nil, true) HostDeviceWriter.write_one(device, writer, 'device') 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 HostDeviceReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (VmHostDeviceService) device_service(id)
Locates the device
service.
25231 25232 25233 |
# File 'lib/ovirtsdk4/services.rb', line 25231 def device_service(id) return VmHostDeviceService.new(@connection, "#{@path}/#{id}") end |
- (Array<HostDevice>) list(opts = {})
Returns the representation of the object managed by this service.
25202 25203 25204 25205 25206 25207 25208 25209 25210 25211 25212 25213 25214 25215 25216 25217 25218 25219 25220 25221 25222 |
# File 'lib/ovirtsdk4/services.rb', line 25202 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 HostDeviceReader.read_many(reader) ensure reader.close end else check_fault(response) end end |
- (Service) service(path)
Locates the service corresponding to the given path.
25242 25243 25244 25245 25246 25247 25248 25249 25250 25251 |
# File 'lib/ovirtsdk4/services.rb', line 25242 def service(path) if path.nil? || path == '' return self end index = path.index('/') if index.nil? return device_service(path) end return device_service(path[0..(index - 1)]).service(path[(index +1)..-1]) end |
- (String) to_s
Returns an string representation of this service.
25258 25259 25260 |
# File 'lib/ovirtsdk4/services.rb', line 25258 def to_s return "#<#{VmHostDevicesService}:#{@path}>" end |