Skip to content
This repository has been archived by the owner on Jul 25, 2023. It is now read-only.

Commit

Permalink
Add verify_credentials and params_for_create
Browse files Browse the repository at this point in the history
Add a method to return the parameters required to add an SCVMM provider
and a method to verity credentials with those parameters.
  • Loading branch information
agrare committed Oct 1, 2019
1 parent edb30c8 commit 9dbbf27
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions app/models/manageiq/providers/microsoft/infra_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,51 @@ def self.description
@description ||= "Microsoft System Center VMM".freeze
end

def self.params_for_create
@params_for_create ||= {
:title => "Configure #{description}",
:fields => [
{
:component => "text-field",
:name => "endpoints.default.server",
:label => "Server Hostname/IP Address",
:isRequired => true,
:validate => [{:type => "required-validator"}]
},
{
:component => "text-field",
:name => "endpoints.default.username",
:label => "Username",
:isRequired => true,
:validate => [{:type => "required-validator"}]
},
{
:component => "text-field",
:name => "endpoints.default.password",
:label => "Password",
:type => "password",
:isRequired => true,
:validate => [{:type => "required-validator"}]
},
{
:component => "text-field",
:name => "endpoints.default.port",
:label => "Port",
:type => "numberic",
}
]
}.freeze
end

def self.verify_credentials(args)
default_endpoint = args.dig("endpoints", "default")
username, password, server, port = default_endpoint&.values_at("username", "password", "server", "port")
connect_params = build_connect_params(:user => username, :password => password, :hostname => server, :port => port)

raw_connect(connect_params, validate = true)
true
end

def self.raw_connect(connect_params, validate = false)
require 'winrm'

Expand Down

0 comments on commit 9dbbf27

Please sign in to comment.