Skip to content

Commit

Permalink
Merge pull request #532 from agrare/add_params_for_create_and_verify_…
Browse files Browse the repository at this point in the history
…credentials

Add params_for_create and verify_credentials
  • Loading branch information
gtanzillo authored Nov 13, 2019
2 parents 57ff346 + 6d9b5db commit 90903a5
Showing 1 changed file with 134 additions and 0 deletions.
134 changes: 134 additions & 0 deletions app/models/manageiq/providers/openstack/manager_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,140 @@ def ems_connect?(password, params, service)
end
private :ems_connect?

def params_for_create
@params_for_create ||= {
:title => "Configure OpenStack",
:fields => [
{
:component => "text-field",
:name => "name",
:label => "Name",
:isRequired => true,
:validate => [{:type => "required-validator"}]
},
{
:component => "text-field",
:name => "provider_region",
:label => "Provider Region",
:isRequired => true,
:validate => [{:type => "required-validator"}]
},
{
:component => "text-field",
:name => "api_version",
:label => "API Version",
:isRequired => true,
:validate => [{:type => "required-validator"}]
},
{
:component => "text-field",
:name => "endpoints.default.default_userid",
:label => "Username",
:isRequired => true,
:validate => [{:type => "required-validator"}]
},
{
:component => "text-field",
:name => "endpoints.default.default_hostname",
:label => "Server Hostname",
:isRequired => true,
:validate => [{:type => "required-validator"}]
},
{
:component => "text-field",
:name => "endpoints.default.default_api_port",
:label => "Port",
:type => "number",
:initialValue => 13_000,
:isRequired => true,
:validate => [{:type => "required-validator"}]
},
{
:component => "select-field",
:name => "endpoints.default.security_protocol",
:label => "Security Protocol",
:placeholder => "ssl-no-validation", # TODO: This should be a dropdown
:options => [
{
:label => "SSL without validation",
:value => "ssl-no-validation"
},
{
:label => "SSL",
:value => "ssl-with-validation"
},
{
:label => "Non SSL",
:value => "non-ssl"
}
]
},
{
:component => "text-field",
:name => "endpoints.default.password",
:label => "Password",
:type => "password",
:isRequired => true,
:validate => [{:type => "required-validator"}]
},
{
:component => "radio",
:name => "endpoints.events.type",
:label => "Events",
:options => [
{
:label => "Ceilometer",
:value => "ceilometer"
},
{
:label => "AMQP",
:value => "amqp"
}
]
},
{
:component => "text-field",
:name => "endpoints.rsa.username",
:label => "Username",
},
{
:component => "text-field",
:name => "endpoints.rsa.private_key",
:label => "Private Key",
:type => "password"
}
]
}
end

# Verify Credentials
#
# args: {
# "name" => String,
# "provider_region" => String,
# "api_version" => String,
# "endpoints" => {
# "default" => {
# "default_userid" => String,
# "default_hostname" => String,
# "default_api_port" => Integer,
# "security_protocol" => String,
# "password" => String,
# }
# }
def verify_credentials(args)
root_params = %w[name provider_region api_version]
params = args.sice(root_params).symbolize_keys

default_endpoint = args.dig("endpoints", "default")
password = default_endpoint&.dig("password")

endpoint_params = %w[default_userid default_hostname default_api_port security_protocol]
params.merge(default_endpoint&.slice(endpoint_params)&.symbolize_keys || {})

!!raw_connect(password, params)
end

def raw_connect(password, params, service = "Compute")
if params[:event_stream_selection] == 'amqp'
amqp_available?(password, params)
Expand Down

0 comments on commit 90903a5

Please sign in to comment.