Class: OvirtSDK4::FenceAgentsService
- Inherits:
-
Service
- Object
- Service
- OvirtSDK4::FenceAgentsService
- Defined in:
- lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb
Instance Method Summary (collapse)
-
- (Agent) add(agent, opts = {})
Adds a new
agent
. -
- (FenceAgentService) agent_service(id)
Locates the
agent
service. -
- (Array<Agent>) 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
- (Agent) add(agent, opts = {})
Adds a new agent
.
7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 |
# File 'lib/ovirtsdk4/services.rb', line 7915 def add(agent, opts = {}) if agent.is_a?(Hash) agent = OvirtSDK4::Agent.new(agent) end request = Request.new(:method => :POST, :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 201, 202 begin reader = XmlReader.new(response.body) return AgentReader.read_one(reader) ensure reader.close end else check_fault(response) end end |
- (FenceAgentService) agent_service(id)
Locates the agent
service.
7979 7980 7981 |
# File 'lib/ovirtsdk4/services.rb', line 7979 def agent_service(id) return FenceAgentService.new(@connection, "#{@path}/#{id}") end |
- (Array<Agent>) list(opts = {})
Returns the representation of the object managed by this service.
7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 |
# File 'lib/ovirtsdk4/services.rb', line 7950 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 AgentReader.read_many(reader) ensure reader.close end else check_fault(response) end end |
- (Service) service(path)
Locates the service corresponding to the given path.
7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 |
# File 'lib/ovirtsdk4/services.rb', line 7990 def service(path) if path.nil? || path == '' return self end index = path.index('/') if index.nil? return agent_service(path) end return agent_service(path[0..(index - 1)]).service(path[(index +1)..-1]) end |
- (String) to_s
Returns an string representation of this service.
8006 8007 8008 |
# File 'lib/ovirtsdk4/services.rb', line 8006 def to_s return "#<#{FenceAgentsService}:#{@path}>" end |