Class: OvirtSDK4::AffinityGroupService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::AffinityGroupService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (AffinityGroup) get(opts = {})
Returns the representation of the object managed by this 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(group)
Updates the object managed by this service.
-
- (AffinityGroupVmsService) vms_service
Locates the
vms
service.
Instance Method Details
- (AffinityGroup) get(opts = {})
Returns the representation of the object managed by this service.
751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 |
# File 'lib/ovirtsdk4/services.rb', line 751 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 AffinityGroupReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (Object) remove(opts = {})
Deletes the object managed by this service.
775 776 777 778 779 780 781 782 783 784 785 786 787 |
# File 'lib/ovirtsdk4/services.rb', line 775 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.
834 835 836 837 838 839 840 841 842 843 844 845 |
# File 'lib/ovirtsdk4/services.rb', line 834 def service(path) if path.nil? || path == '' return self end if path == 'vms' return vms_service end if path.start_with?('vms/') return vms_service.service(path[4..-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.
852 853 854 |
# File 'lib/ovirtsdk4/services.rb', line 852 def to_s return "#<#{AffinityGroupService}:#{@path}>" end |
- (Object) update(group)
Updates the object managed by this service.
792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 |
# File 'lib/ovirtsdk4/services.rb', line 792 def update(group) if group.is_a?(Hash) group = OvirtSDK4::AffinityGroup.new(group) end request = Request.new(:method => :PUT, :path => @path) begin writer = XmlWriter.new(nil, true) AffinityGroupWriter.write_one(group, writer, 'group') request.body = writer.string ensure writer.close end response = @connection.send(request) case response.code when 200 begin reader = XmlReader.new(response.body) return AffinityGroupReader.read_one(reader) ensure reader.close end return result else check_fault(response) end end |
- (AffinityGroupVmsService) vms_service
Locates the vms
service.
823 824 825 |
# File 'lib/ovirtsdk4/services.rb', line 823 def vms_service return AffinityGroupVmsService.new(@connection, "#{@path}/vms") end |