Class: OvirtSDK4::FenceAgentService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::FenceAgentService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (Agent) 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(agent)
Updates the object managed by this service.
Instance Method Details
- (Agent) get(opts = {})
Returns the representation of the object managed by this service.
7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 |
# File 'lib/ovirtsdk4/services.rb', line 7799 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 AgentReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (Object) remove(opts = {})
Deletes the object managed by this service.
7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 |
# File 'lib/ovirtsdk4/services.rb', line 7823 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.
7874 7875 7876 7877 7878 7879 |
# File 'lib/ovirtsdk4/services.rb', line 7874 def service(path) if path.nil? || path == '' return self end raise Error.new("The path \"#{path}\" doesn't correspond to any service") end |
- (String) to_s
Returns an string representation of this service.
7886 7887 7888 |
# File 'lib/ovirtsdk4/services.rb', line 7886 def to_s return "#<#{FenceAgentService}:#{@path}>" end |
- (Object) update(agent)
Updates the object managed by this service.
7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 |
# File 'lib/ovirtsdk4/services.rb', line 7840 def update(agent) if agent.is_a?(Hash) agent = OvirtSDK4::Agent.new(agent) end request = Request.new(:method => :PUT, :path => @path) begin writer = XmlWriter.new(nil, true) AgentWriter.write_one(agent, writer, 'agent') request.body = writer.string ensure writer.close end response = @connection.send(request) case response.code when 200 begin reader = XmlReader.new(response.body) return AgentReader.read_one(reader) ensure reader.close end return result else check_fault(response) end end |