Class: OvirtSDK4::VmDisksService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::VmDisksService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (Disk) add(disk, opts = {})
Adds a new
disk
. -
- (VmDiskService) disk_service(id)
Locates the
disk
service. -
- (Array<Disk>) 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
- (Disk) add(disk, opts = {})
Adds a new disk
.
24851 24852 24853 24854 24855 24856 24857 24858 24859 24860 24861 24862 24863 24864 24865 24866 24867 24868 24869 24870 24871 24872 24873 24874 24875 |
# File 'lib/ovirtsdk4/services.rb', line 24851 def add(disk, opts = {}) if disk.is_a?(Hash) disk = OvirtSDK4::Disk.new(disk) end request = Request.new(:method => :POST, :path => @path) begin writer = XmlWriter.new(nil, true) DiskWriter.write_one(disk, writer, 'disk') 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 DiskReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (VmDiskService) disk_service(id)
Locates the disk
service.
24915 24916 24917 |
# File 'lib/ovirtsdk4/services.rb', line 24915 def disk_service(id) return VmDiskService.new(@connection, "#{@path}/#{id}") end |
- (Array<Disk>) list(opts = {})
Returns the representation of the object managed by this service.
24886 24887 24888 24889 24890 24891 24892 24893 24894 24895 24896 24897 24898 24899 24900 24901 24902 24903 24904 24905 24906 |
# File 'lib/ovirtsdk4/services.rb', line 24886 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 DiskReader.read_many(reader) ensure reader.close end else check_fault(response) end end |
- (Service) service(path)
Locates the service corresponding to the given path.
24926 24927 24928 24929 24930 24931 24932 24933 24934 24935 |
# File 'lib/ovirtsdk4/services.rb', line 24926 def service(path) if path.nil? || path == '' return self end index = path.index('/') if index.nil? return disk_service(path) end return disk_service(path[0..(index - 1)]).service(path[(index +1)..-1]) end |
- (String) to_s
Returns an string representation of this service.
24942 24943 24944 |
# File 'lib/ovirtsdk4/services.rb', line 24942 def to_s return "#<#{VmDisksService}:#{@path}>" end |