Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add methods for for provider creation pluggable UI #14

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions app/models/manageiq/providers/azure_stack/manager_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,66 @@ def service_supported?(service)
end

module ClassMethods
def params_for_create
@params_for_create ||= {
:title => "Configure Azure Stack",
:fields => [
{
:component => "text-field",
:name => "endpoints.default.base_url",
:label => "URL",
:isRequired => true,
:validate => [{:type => "required-validator"}]
},
{
:component => "text-field",
:name => "endpoints.default.tenant",
:label => "Tenant",
: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.subscription",
:label => "Subscription",
:isRequired => true,
:validate => [{:type => "required-validator"}]
},
{
:component => "text-field",
:name => "endpoints.default.api_version",
:label => "API Version",
:isRequired => true,
:validate => [{:type => "required-validator"}]
}
]
}.freeze
end

def verify_credentials(args)
default_endpoint = args.dig("endpoints", "default")
base_url, tenant, username, password, subscription, api_version = default_endpoint.values_at(
"base_url", "tenant", "username", "password", "subscription", "api_version"
)

!!raw_connect(base_url, tenant, username, password, subscription, :Resources, api_version, :validate => true)
end

def raw_connect(base_url, tenant, username, password, subscription, service, api_version, ad_settings: nil, token: nil, validate: false)
require 'ms_rest_azure'
require 'azure_mgmt_resources'
Expand Down