Class: OvirtSDK4::DisksService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::DisksService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (Disk) add(disk, opts = {})
Adds a new
disk
. -
- (DiskService) 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
.
5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 |
# File 'lib/ovirtsdk4/services.rb', line 5925 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 |
- (DiskService) disk_service(id)
Locates the disk
service.
6004 6005 6006 |
# File 'lib/ovirtsdk4/services.rb', line 6004 def disk_service(id) return DiskService.new(@connection, "#{@path}/#{id}") end |
- (Array<Disk>) list(opts = {})
Returns the representation of the object managed by this service.
5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 |
# File 'lib/ovirtsdk4/services.rb', line 5966 def list(opts = {}) query = {} value = opts[:case_sensitive] unless value.nil? value = Writer.render_boolean(value) query['case_sensitive'] = value end value = opts[:max] unless value.nil? value = Writer.render_integer(value) query['max'] = value end value = opts[:search] unless value.nil? query['search'] = 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.
6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 |
# File 'lib/ovirtsdk4/services.rb', line 6015 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.
6031 6032 6033 |
# File 'lib/ovirtsdk4/services.rb', line 6031 def to_s return "#<#{DisksService}:#{@path}>" end |