diff --git a/app/models/manageiq/providers/kubevirt/infra_manager.rb b/app/models/manageiq/providers/kubevirt/infra_manager.rb index 340ceb8..2557436 100644 --- a/app/models/manageiq/providers/kubevirt/infra_manager.rb +++ b/app/models/manageiq/providers/kubevirt/infra_manager.rb @@ -53,6 +53,54 @@ def self.description @description ||= ManageIQ::Providers::Kubevirt::Constants::PRODUCT end + def self.params_for_create + @params_for_create ||= { + :title => "Configure #{description}", + :fields => [ + { + :component => "text-field", + :name => "endpoints.default.server", + :label => "Hostname", + :isRequired => true, + :validate => [{:type => "required-validator"}] + }, + { + :component => "text-field", + :name => "endpoints.default.port", + :type => "number", + :isRequired => true, + :validate => [ + { + :type => "required-validator" + }, + { + :type => "validatorTypes.MIN_NUMBER_VALUE", + :includeThreshold => true, + :value => 1 + }, + { + :type => "validatorTypes.MAX_NUMBER_VALUE", + :includeThreshold => true, + :value => 65_535 + } + ] + }, + { + :component => "text-field", + :name => "endpoints.default.token", + :label => "Token", + :type => "password", + :isRequired => true, + :validate => [{:type => "required-validator"}] + } + ] + }.freeze + end + + def self.verify_credentials(args) + !!raw_connect(args.dig("endpoints", "default")&.slice("server", "port", "token")&.symbolize_keys) + end + # # This method from the dialog that adds a provider, to verify the connection details and the # credentials. @@ -61,16 +109,13 @@ def self.description # @option opts [String] :server The Kubernetes API server host name or IP address. # @option opts [Integer] :port The Kubernetes API port number. # @option opts [String] :token The Kubernetes authentication token. - # @option opts [Integer] :verify_ssl Integer indicating if the Kubernetes API server certificate - # should be verified. - # @option opts [Integer] :ca_certs Trusted CA certificates, in PEM format. # def self.raw_connect(opts) # Create the connection: connection = Connection.new( :host => opts[:server], :port => opts[:port], - :token => opts[:token], + :token => MiqPassword.try_decrypt(opts[:token]) ) # Verify that the connection works: