Skip to content

Commit

Permalink
Add DDF based verify_credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
Fryguy committed Oct 1, 2019
1 parent 04bc517 commit 7285258
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions app/models/manageiq/providers/google/manager_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,47 @@ def gce
end

module ClassMethods
def params_for_create
@params_for_create ||= {
:title => "Configure #{description}",
:fields => [
{
:component => "text-field",
:name => "endpoints.default.google_project",
:label => "Project",
:isRequired => true,
:validate => [{:type => "required-validator"}]
},
{
:component => "text-field",
:name => "endpoints.default.google_json_key",
:label => "JSON Key",
:type => "password",
:isRequired => true,
:validate => [{:type => "required-validator"}]
}
]
}.freeze
end

# Verify Credentials
# args:
# {
# "endpoints" => {
# "default" => {
# "google_project" => "",
# "google_json_key" => "",
# }
# }
# }
def verify_credentials(args)
default_endpoint = args.dig("endpoints", "default")

google_project, google_json_key = default_endpoint&.values_at("google_project", "google_json_key")

!!raw_connect(google_project, google_json_key, {:service => "compute"}, http_proxy_uri, true)
end

def raw_connect(google_project, google_json_key, options, proxy_uri = nil, validate = false)
require 'fog/google'

Expand Down

0 comments on commit 7285258

Please sign in to comment.