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 9f3a87b commit 6f2a379
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions app/models/manageiq/providers/azure/manager_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,82 @@ def verify_credentials(_auth_type = nil, options = {})
end

module ClassMethods
def params_for_create
@params_for_create ||= {
:title => "Configure #{description}",
:fields => [
{
:component => "text-field",
:name => "region",
:label => "Region",
:isRequired => true,
:validate => [{:type => "required-validator"}]
},
{
:component => "text-field",
:name => "endpoints.default.client_id",
:label => "Client ID",
:isRequired => true,
:validate => [{:type => "required-validator"}]
},
{
:component => "text-field",
:name => "endpoints.default.client_key",
:label => "Client Key",
:type => "password",
:isRequired => true,
:validate => [{:type => "required-validator"}]
},
{
:component => "text-field",
:name => "endpoints.default.azure_tenant_id",
:label => "Azure Tenant ID",
:isRequired => true,
:validate => [{:type => "required-validator"}]
},
{
:component => "text-field",
:name => "endpoints.default.subscription",
:label => "Subscription",
:isRequired => true,
:validate => [{:type => "required-validator"}]
},
{
:component => "text-field",
:name => "endpoints.default.endpoint_url",
:label => "URL",
:isRequired => true,
:validate => [{:type => "required-validator"}]
}
]
}.freeze
end

# Verify Credentials
# args:
# {
# "region" => "",
# "endpoints" => {
# "default" => {
# "client_id" => "",
# "client_key" => "",
# "azure_tenant_id" => "",
# "subscription" => "",
# "endpoint_url" => ""
# }
# }
# }
def verify_credentials(args)
region = args["region"]
default_endpoint = args.dig("endpoints", "default")

client_id, client_key, azure_tenant_id, subscription, endpoint_url = default_endpoint&.values_at(
"client_id", "client_key", "azure_tenant_id", "subscription", "endpoint_url"
)

!!raw_connect(client_id, client_key, azure_tenant_id, subscription, http_proxy_uri, region, endpoint_url)
end

def raw_connect(client_id, client_key, azure_tenant_id, subscription, proxy_uri = nil, provider_region = nil, endpoint = nil)
require 'azure-armrest'

Expand Down

0 comments on commit 6f2a379

Please sign in to comment.