class OvirtSDK4::ExternalHostProviderService
Public Class Methods
Creates a new implementation of the service.
@param connection [Connection] The connection to be used by this service.
@param path [String] The relative path of this service, for example `vms/123/disks`.
@api private
# File lib/ovirtsdk4/services.rb, line 27920 def initialize(connection, path) @connection = connection @path = path end
Public Instance Methods
Locates the `certificates` service.
@return [ExternalProviderCertificatesService] A reference to `certificates` service.
# File lib/ovirtsdk4/services.rb, line 28050 def certificates_service return ExternalProviderCertificatesService.new(@connection, "#{@path}/certificates") end
Locates the `compute_resources` service.
@return [ExternalComputeResourcesService] A reference to `compute_resources` service.
# File lib/ovirtsdk4/services.rb, line 28058 def compute_resources_service return ExternalComputeResourcesService.new(@connection, "#{@path}/computeresources") end
Locates the `discovered_hosts` service.
@return [ExternalDiscoveredHostsService] A reference to `discovered_hosts` service.
# File lib/ovirtsdk4/services.rb, line 28066 def discovered_hosts_service return ExternalDiscoveredHostsService.new(@connection, "#{@path}/discoveredhosts") end
Returns the representation of the object managed by this service.
@param opts [Hash] Additional options.
@return [ExternalHostProvider]
# File lib/ovirtsdk4/services.rb, line 27932 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 ExternalHostProviderReader.read_one(reader) ensure reader.close end else check_fault(response) end end
Locates the `host_groups` service.
@return [ExternalHostGroupsService] A reference to `host_groups` service.
# File lib/ovirtsdk4/services.rb, line 28074 def host_groups_service return ExternalHostGroupsService.new(@connection, "#{@path}/hostgroups") end
Locates the `hosts` service.
@return [ExternalHostsService] A reference to `hosts` service.
# File lib/ovirtsdk4/services.rb, line 28082 def hosts_service return ExternalHostsService.new(@connection, "#{@path}/hosts") end
Executes the `import_certificates` method.
# File lib/ovirtsdk4/services.rb, line 27952 def import_certificates(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}/importcertificates", :body => body, }) response = @connection.send(request) case response.code when 200 action = check_action(response) else check_fault(response) end end
Deletes the object managed by this service.
@param opts [Hash] Additional options.
@option opts [Boolean] :async Indicates if the remove should be performed asynchronously.
# File lib/ovirtsdk4/services.rb, line 27979 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
Locates the service corresponding to the given path.
@param path [String] The path of the service.
@return [Service] A reference to the service.
# File lib/ovirtsdk4/services.rb, line 28093 def service(path) if path.nil? || path == '' return self end if path == 'certificates' return certificates_service end if path.start_with?('certificates/') return certificates_service.service(path[13..-1]) end if path == 'computeresources' return compute_resources_service end if path.start_with?('computeresources/') return compute_resources_service.service(path[17..-1]) end if path == 'discoveredhosts' return discovered_hosts_service end if path.start_with?('discoveredhosts/') return discovered_hosts_service.service(path[16..-1]) end if path == 'hostgroups' return host_groups_service end if path.start_with?('hostgroups/') return host_groups_service.service(path[11..-1]) end if path == 'hosts' return hosts_service end if path.start_with?('hosts/') return hosts_service.service(path[6..-1]) end raise Error.new("The path \"#{path}\" doesn't correspond to any service") end
Executes the `test_connectivity` method.
# File lib/ovirtsdk4/services.rb, line 27996 def test_connectivity(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}/testconnectivity", :body => body, }) response = @connection.send(request) case response.code when 200 action = check_action(response) else check_fault(response) end end
Returns an string representation of this service.
@return [String]
# File lib/ovirtsdk4/services.rb, line 28135 def to_s return "#<#{ExternalHostProviderService}:#{@path}>" end
Updates the object managed by this service.
# File lib/ovirtsdk4/services.rb, line 28019 def update(provider) if provider.is_a?(Hash) provider = OvirtSDK4::ExternalHostProvider.new(provider) end request = Request.new(:method => :PUT, :path => @path) begin writer = XmlWriter.new(nil, true) ExternalHostProviderWriter.write_one(provider, writer) request.body = writer.string ensure writer.close end response = @connection.send(request) case response.code when 200 begin reader = XmlReader.new(response.body) return ExternalHostProviderReader.read_one(reader) ensure reader.close end return result else check_fault(response) end end