Skip to content

Commit

Permalink
add assume role arn input
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderZagaynov committed May 28, 2019
1 parent 5bb1d4c commit abd99b5
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 10 deletions.
27 changes: 22 additions & 5 deletions app/controllers/mixins/ems_common/angular.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,16 @@ def get_task_args(ems)
end
when 'ManageIQ::Providers::Amazon::CloudManager'
uri = URI.parse(WEBrick::HTTPUtils.escape(params[:default_url]))
[user, password, :EC2, params[:provider_region], ems.http_proxy_uri, true, uri]
[
user,
password,
:EC2,
params[:provider_region],
ems.http_proxy_uri,
true,
uri,
:assume_role => params[:service_account].presence,
]
when 'ManageIQ::Providers::Azure::CloudManager'
uri = URI.parse(WEBrick::HTTPUtils.escape(params[:default_url]))
[user, password, params[:azure_tenant_id], params[:subscription], ems.http_proxy_uri, params[:provider_region], uri]
Expand Down Expand Up @@ -354,6 +363,10 @@ def ems_form_fields
host_default_vnc_port_end = @ems.host_default_vnc_port_end.to_s
end

if @ems.kind_of?(ManageIQ::Providers::Amazon::CloudManager)
service_account = @ems.authentication_service_account
end

if @ems.kind_of?(ManageIQ::Providers::Azure::CloudManager)
azure_tenant_id = @ems.azure_tenant_id
subscription = @ems.subscription
Expand Down Expand Up @@ -775,10 +788,14 @@ def build_credentials(ems, mode)
console_password = params[:console_password] ? params[:console_password] : ems.authentication_password(:console)
creds[:console] = {:userid => params[:console_userid], :password => console_password, :save => (mode != :validate)} # FIXME: skateman was here
end
if ems.kind_of?(ManageIQ::Providers::Amazon::CloudManager) &&
ems.supports_authentication?(:smartstate_docker) && params[:smartstate_docker_userid]
smartstate_docker_password = params[:smartstate_docker_password] ? params[:smartstate_docker_password] : ems.authentication_password(:smartstate_docker)
creds[:smartstate_docker] = {:userid => params[:smartstate_docker_userid], :password => smartstate_docker_password, :save => true}
if ems.kind_of?(ManageIQ::Providers::Amazon::CloudManager)
if ems.supports_authentication?(:smartstate_docker) && params[:smartstate_docker_userid]
smartstate_docker_password = params[:smartstate_docker_password] || ems.authentication_password(:smartstate_docker)
creds[:smartstate_docker] = {:userid => params[:smartstate_docker_userid], :password => smartstate_docker_password, :save => true}
else
creds[:default] ||= {}
creds[:default][:service_account] = params[:service_account]
end
end
if (ems.kind_of?(ManageIQ::Providers::Openstack::InfraManager) ||
ems.kind_of?(ManageIQ::Providers::Openstack::CloudManager) ||
Expand Down
27 changes: 22 additions & 5 deletions app/controllers/mixins/ems_common_angular.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,16 @@ def get_task_args(ems)
end
when 'ManageIQ::Providers::Amazon::CloudManager'
uri = URI.parse(WEBrick::HTTPUtils.escape(params[:default_url]))
[user, password, :EC2, params[:provider_region], ems.http_proxy_uri, true, uri]
[
user,
password,
:EC2,
params[:provider_region],
ems.http_proxy_uri,
true,
uri,
:assume_role => params[:service_account].presence,
]
when 'ManageIQ::Providers::Azure::CloudManager'
uri = URI.parse(WEBrick::HTTPUtils.escape(params[:default_url]))
[user, password, params[:azure_tenant_id], params[:subscription], ems.http_proxy_uri, params[:provider_region], uri]
Expand Down Expand Up @@ -349,6 +358,10 @@ def ems_form_fields
host_default_vnc_port_end = @ems.host_default_vnc_port_end.to_s
end

if @ems.kind_of?(ManageIQ::Providers::Amazon::CloudManager)
service_account = @ems.authentication_service_account
end

if @ems.kind_of?(ManageIQ::Providers::Azure::CloudManager)
azure_tenant_id = @ems.azure_tenant_id
subscription = @ems.subscription
Expand Down Expand Up @@ -766,10 +779,14 @@ def build_credentials(ems, mode)
console_password = params[:console_password] ? params[:console_password] : ems.authentication_password(:console)
creds[:console] = {:userid => params[:console_userid], :password => console_password, :save => (mode != :validate)} # FIXME: skateman was here
end
if ems.kind_of?(ManageIQ::Providers::Amazon::CloudManager) &&
ems.supports_authentication?(:smartstate_docker) && params[:smartstate_docker_userid]
smartstate_docker_password = params[:smartstate_docker_password] ? params[:smartstate_docker_password] : ems.authentication_password(:smartstate_docker)
creds[:smartstate_docker] = {:userid => params[:smartstate_docker_userid], :password => smartstate_docker_password, :save => true}
if ems.kind_of?(ManageIQ::Providers::Amazon::CloudManager)
if ems.supports_authentication?(:smartstate_docker) && params[:smartstate_docker_userid]
smartstate_docker_password = params[:smartstate_docker_password] || ems.authentication_password(:smartstate_docker)
creds[:smartstate_docker] = {:userid => params[:smartstate_docker_userid], :password => smartstate_docker_password, :save => true}
else
creds[:default] ||= {}
creds[:default][:service_account] = params[:service_account]
end
end
if (ems.kind_of?(ManageIQ::Providers::Openstack::InfraManager) ||
ems.kind_of?(ManageIQ::Providers::Openstack::CloudManager) ||
Expand Down
24 changes: 24 additions & 0 deletions app/views/layouts/angular-bootstrap/_any_field.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
- prefix ||= 'default'
- input_type ||= 'text'
- input_name ||= ''
- input_desc ||= ''
- input_emsg ||= ''
- input_id ||= [prefix, input_name].select(&:present?).join("_")

%div
.form-group{"ng-class" => "{'has-error': angularForm.#{input_id}.$invalid}"} |
%label.col-md-2.control-label{"for" => input_id}
= _(input_desc)
.col-md-4
%input.form-control{"type" => input_type,
"id" => input_id,
"ng-required" => false,
"name" => input_id,
"ng-model" => "#{ng_model}.#{input_id}",
"checkchange" => "",
"ng-trim" => false,
"detect_spaces" => "",
"prefix" => prefix,
"reset-validation-status" => "#{prefix}_auth_status"}
%span.help-block{"ng-show" => "angularForm.#{input_id}.$error.url"}
= _(input_emsg)
6 changes: 6 additions & 0 deletions app/views/layouts/angular/_multi_auth_credentials.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@
.col-md-12{"ng-if" => "#{ng_model}" == "emsCommonModel" && "#{ng_model}.emstype == 'ec2'"}
= render :partial => "layouts/angular-bootstrap/endpoints_for_url",
:locals => {:prefix => "default", :ng_model => "#{ng_model}"}
= render :partial => "layouts/angular-bootstrap/any_field",
:locals => {:prefix => "",
:input_name => "service_account",
:input_desc => "Assume role ARN",
:input_emsg => "Invalid ARN",
:ng_model => "#{ng_model}"}
= render :partial => "layouts/angular-bootstrap/auth_credentials_angular_bootstrap",
:locals => {:ng_show => true,
:ng_model => "#{ng_model}",
Expand Down

0 comments on commit abd99b5

Please sign in to comment.