Class: OvirtSDK4::DiskAttachmentService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::DiskAttachmentService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (DiskAttachment) get(opts = {})
Returns the details of the attachment, including the bootable flag and link to the disk.
-
- (Object) remove(opts = {})
Removes the disk attachment.
-
- (Service) service(path)
Locates the service corresponding to the given path.
-
- (String) to_s
Returns an string representation of this service.
-
- (Object) update(disk_attachment)
Update the disk attachment and the disk properties within it.
Instance Method Details
- (DiskAttachment) get(opts = {})
Returns the details of the attachment, including the bootable flag and link to the disk.
5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 |
# File 'lib/ovirtsdk4/services.rb', line 5230 def get(opts = {}) query = {} 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 DiskAttachmentReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (Object) remove(opts = {})
Removes the disk attachment. This will only detach the disk from the virtual machine, but won’t remove it from
the system, unless the detach_only
parameter is false
.
5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 |
# File 'lib/ovirtsdk4/services.rb', line 5256 def remove(opts = {}) query = {} value = opts[:detach_only] unless value.nil? value = Writer.render_boolean(value) query['detach_only'] = value end request = Request.new(:method => :DELETE, :path => @path, :query => query) response = @connection.send(request) unless response.code == 200 check_fault(response) end end |
- (Service) service(path)
Locates the service corresponding to the given path.
5321 5322 5323 5324 5325 5326 |
# File 'lib/ovirtsdk4/services.rb', line 5321 def service(path) if path.nil? || path == '' return self end raise Error.new("The path \"#{path}\" doesn't correspond to any service") end |
- (String) to_s
Returns an string representation of this service.
5333 5334 5335 |
# File 'lib/ovirtsdk4/services.rb', line 5333 def to_s return "#<#{DiskAttachmentService}:#{@path}>" end |
- (Object) update(disk_attachment)
Update the disk attachment and the disk properties within it.
PUT /vms/{vm:id}/disksattachments/{attachment:id}
<disk_attachment>
<bootable>true</bootable>
<interface>ide</interface>
<disk>
<name>mydisk</name>
<provisioned_size>1024</provisioned_size>
...
</disk>
</disk_attachment>
5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 |
# File 'lib/ovirtsdk4/services.rb', line 5287 def update() if .is_a?(Hash) = OvirtSDK4::DiskAttachment.new() end request = Request.new(:method => :PUT, :path => @path) begin writer = XmlWriter.new(nil, true) DiskAttachmentWriter.write_one(, writer, 'disk_attachment') request.body = writer.string ensure writer.close end response = @connection.send(request) case response.code when 200 begin reader = XmlReader.new(response.body) return DiskAttachmentReader.read_one(reader) ensure reader.close end return result else check_fault(response) end end |