Class: OvirtSDK4::DiskAttachmentsService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::DiskAttachmentsService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (DiskAttachment) add(attachment, opts = {})
Adds a new disk attachment to the virtual machine.
-
- (DiskAttachmentService) attachment_service(id)
Reference to the service that manages a specific attachment.
-
- (Array<DiskAttachment>) list(opts = {})
List the disk that are attached to the virtual machine.
-
- (Service) service(path)
Locates the service corresponding to the given path.
-
- (String) to_s
Returns an string representation of this service.
Instance Method Details
- (DiskAttachment) add(attachment, opts = {})
Adds a new disk attachment to the virtual machine. The attachment
parameter can contain just a reference, if
the disk already exists:
<disk_attachment>
<bootable>true</bootable>
<interface>ide</interface>
<disk id="123"/>
</disk_attachment>
Or it can contain the complete representation of the disk, if the disk doesn’t exist yet:
<disk_attachment>
<bootable>true</bootable>
<interface>ide</interface>
<disk>
<name>mydisk</name>
<provisioned_size>1024</provisioned_size>
...
</disk>
</disk_attachment>
In this case the disk will be created and then attached to the virtual machine.
5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 |
# File 'lib/ovirtsdk4/services.rb', line 5389 def add(, opts = {}) if .is_a?(Hash) = OvirtSDK4::DiskAttachment.new() end request = Request.new(:method => :POST, :path => @path) begin writer = XmlWriter.new(nil, true) DiskAttachmentWriter.write_one(, writer, 'attachment') 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 DiskAttachmentReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (DiskAttachmentService) attachment_service(id)
Reference to the service that manages a specific attachment.
5446 5447 5448 |
# File 'lib/ovirtsdk4/services.rb', line 5446 def (id) return DiskAttachmentService.new(@connection, "#{@path}/#{id}") end |
- (Array<DiskAttachment>) list(opts = {})
List the disk that are attached to the virtual machine.
5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 |
# File 'lib/ovirtsdk4/services.rb', line 5422 def list(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_many(reader) ensure reader.close end else check_fault(response) end end |
- (Service) service(path)
Locates the service corresponding to the given path.
5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 |
# File 'lib/ovirtsdk4/services.rb', line 5457 def service(path) if path.nil? || path == '' return self end index = path.index('/') if index.nil? return (path) end return (path[0..(index - 1)]).service(path[(index +1)..-1]) end |
- (String) to_s
Returns an string representation of this service.
5473 5474 5475 |
# File 'lib/ovirtsdk4/services.rb', line 5473 def to_s return "#<#{DiskAttachmentsService}:#{@path}>" end |