Class: OvirtSDK4::VmPoolService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::VmPoolService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (Object) allocate_vm(opts = {})
Executes the
allocate_vm
method. -
- (VmPool) get(opts = {})
Returns the representation of the object managed by this service.
-
- (AssignedPermissionsService) permissions_service
Locates the
permissions
service. -
- (Object) remove(opts = {})
Deletes 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.
-
- (Object) update(pool)
Updates the object managed by this service.
Instance Method Details
- (Object) allocate_vm(opts = {})
Executes the allocate_vm
method.
25829 25830 25831 25832 25833 25834 25835 25836 25837 25838 25839 25840 25841 25842 25843 25844 25845 25846 25847 |
# File 'lib/ovirtsdk4/services.rb', line 25829 def allocate_vm(opts = {}) action = Action.new(opts) writer = XmlWriter.new(nil, true) ActionWriter.write_one(action, writer) body = writer.string writer.close request = Request.new({ :method => :POST, :path => "#{@path}/allocatevm", :body => body, }) response = @connection.send(request) case response.code when 200 action = check_action(response) else check_fault(response) end end |
- (VmPool) get(opts = {})
Returns the representation of the object managed by this service.
25858 25859 25860 25861 25862 25863 25864 25865 25866 25867 25868 25869 25870 25871 25872 25873 25874 25875 25876 25877 25878 |
# File 'lib/ovirtsdk4/services.rb', line 25858 def get(opts = {}) query = {} value = opts[:filter] unless value.nil? value = Writer.render_boolean(value) query['filter'] = 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 VmPoolReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (AssignedPermissionsService) permissions_service
Locates the permissions
service.
25935 25936 25937 |
# File 'lib/ovirtsdk4/services.rb', line 25935 def return AssignedPermissionsService.new(@connection, "#{@path}/permissions") end |
- (Object) remove(opts = {})
Deletes the object managed by this service.
25887 25888 25889 25890 25891 25892 25893 25894 25895 25896 25897 25898 25899 |
# File 'lib/ovirtsdk4/services.rb', line 25887 def remove(opts = {}) query = {} value = opts[:async] unless value.nil? value = Writer.render_boolean(value) query['async'] = 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.
25946 25947 25948 25949 25950 25951 25952 25953 25954 25955 25956 25957 |
# File 'lib/ovirtsdk4/services.rb', line 25946 def service(path) if path.nil? || path == '' return self end if path == 'permissions' return end if path.start_with?('permissions/') return .service(path[12..-1]) end raise Error.new("The path \"#{path}\" doesn't correspond to any service") end |
- (String) to_s
Returns an string representation of this service.
25964 25965 25966 |
# File 'lib/ovirtsdk4/services.rb', line 25964 def to_s return "#<#{VmPoolService}:#{@path}>" end |
- (Object) update(pool)
Updates the object managed by this service.
25904 25905 25906 25907 25908 25909 25910 25911 25912 25913 25914 25915 25916 25917 25918 25919 25920 25921 25922 25923 25924 25925 25926 25927 25928 25929 |
# File 'lib/ovirtsdk4/services.rb', line 25904 def update(pool) if pool.is_a?(Hash) pool = OvirtSDK4::VmPool.new(pool) end request = Request.new(:method => :PUT, :path => @path) begin writer = XmlWriter.new(nil, true) VmPoolWriter.write_one(pool, writer, 'pool') request.body = writer.string ensure writer.close end response = @connection.send(request) case response.code when 200 begin reader = XmlReader.new(response.body) return VmPoolReader.read_one(reader) ensure reader.close end return result else check_fault(response) end end |