Skip to content

Commit

Permalink
Add methods for for provider creation pluggable UI
Browse files Browse the repository at this point in the history
Add a method indicating the properties required to create a Kubevirt
provider and implement the common self.verify_credentials interface
method.

ManageIQ/manageiq#18818
  • Loading branch information
agrare committed Oct 2, 2019
1 parent 05c6f00 commit c3df2f5
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion app/models/manageiq/providers/kubevirt/infra_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,41 @@ def self.description
@description ||= ManageIQ::Providers::Kubevirt::Constants::PRODUCT
end

def self.params_for_create
@params_for_create ||= {
:title => "Configure Kubevirt",
: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"}]
},
{
:component => "text-field",
:name => "endpoints.default.token",
:label => "Token",
:type => "password",
:isRequired => true,
:validate => [{:type => "required-validator"}]
}
]
}.freeze
end

def self.verify_credentials(args)
server, port, token = args.dig("endpoints", "default")&.values_at("server", "port", "token")
!!raw_connect(:server => server, :port => port, :token => token)
end

#
# This method from the dialog that adds a provider, to verify the connection details and the
# credentials.
Expand All @@ -70,7 +105,7 @@ def self.raw_connect(opts)
connection = Connection.new(
:host => opts[:server],
:port => opts[:port],
:token => opts[:token],
:token => MiqPassword.try_decrypt(opts[:token]),
)

# Verify that the connection works:
Expand Down

0 comments on commit c3df2f5

Please sign in to comment.