Skip to content

Commit

Permalink
other approach
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderZagaynov committed Sep 6, 2019
1 parent 0e880a4 commit fc9d55a
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
ssh_keypair_userid: '',
ssh_keypair_password: '',
service_account: '',
default_service_account: '',
emstype_vm: false,
ems_common: true,
azure_tenant_id: '',
Expand Down Expand Up @@ -158,6 +159,7 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
$scope.emsCommonModel.ssh_keypair_userid = data.ssh_keypair_userid;

$scope.emsCommonModel.service_account = data.service_account;
$scope.emsCommonModel.default_service_account = data.service_account;
$scope.emsCommonModel.azure_tenant_id = data.azure_tenant_id;
$scope.emsCommonModel.keystone_v3_domain_id = data.keystone_v3_domain_id;
$scope.emsCommonModel.subscription = data.subscription;
Expand Down Expand Up @@ -637,6 +639,7 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
default_userid: $scope.emsCommonModel.default_userid,
default_password: default_password,
default_url: $scope.emsCommonModel.default_url,
default_service_account: $scope.emsCommonModel.default_service_account,
realm: $scope.emsCommonModel.realm,
azure_tenant_id: $scope.emsCommonModel.azure_tenant_id,
subscription: $scope.emsCommonModel.subscription,
Expand Down Expand Up @@ -739,8 +742,6 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '

$scope.updateAuthStatus = function(updatedValue) {
$scope.angularForm[$scope.currentTab + '_auth_status'].$setViewValue(updatedValue);
$scope.angularForm.$valid = updatedValue;
$scope.angularForm.$invalid = !updatedValue;
};

$scope.updateHostname = function(value) {
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/mixins/ems_common/angular.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def get_task_args(ems)
ems.http_proxy_uri,
true,
uri,
:assume_role => params[:service_account].presence,
:assume_role => params[:default_service_account].presence,
]
when 'ManageIQ::Providers::Azure::CloudManager'
uri = URI.parse(WEBrick::HTTPUtils.escape(params[:default_url]))
Expand Down Expand Up @@ -808,7 +808,7 @@ def build_credentials(ems, mode)
creds[:smartstate_docker] = {:userid => params[:smartstate_docker_userid], :password => smartstate_docker_password, :save => true}
end
if ems.supports?(:assume_role)
(creds[:default] ||= {})[:service_account] = params[:service_account]
(creds[:default] ||= {})[:service_account] = params[:default_service_account]
end
if (ems.kind_of?(ManageIQ::Providers::Openstack::InfraManager) ||
ems.kind_of?(ManageIQ::Providers::Openstack::CloudManager) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,8 @@
- vm_scope ||= false
- validate_button ||= true
- main_scope = vm_scope ? "$parent.vm" : "$parent"
- ng_show_service_account ||= false
- service_account_label ||= _("Service account")

%div{"ng-controller" => "CredentialsController as vm", "vm-scope" => "$parent.vm.model ? $parent.vm : $parent"}
%div{"ng-show" => "#{ng_show} && #{ng_show_service_account}"}
.form-group{"ng-class" => "{'has-error': angularForm.service_account.$invalid}"}
%label.col-md-2.control-label{"for" => "#{prefix}_service_account"}
= service_account_label
.col-md-4
- hash_for_service_account = {"type" => "text",
"id" => "#{prefix}_service_account",
"ng-required" => false,
"ng-disabled" => false,
"name" => "service_account",
"ng-model" => "#{main_scope}.#{ng_model}.service_account",
"checkchange" => "",
"ng-trim" => false,
"detect_spaces" => "",
"prefix" => "#{prefix}",
"main-scope" => "#{main_scope}",
"reset-validation-status" => "#{prefix}_auth_status"}
%input.form-control{hash_for_service_account}

%div{"ng-show" => "#{ng_show} && #{ng_show_userid}"}
.form-group{"ng-class" => "{'has-error': angularForm.#{prefix}_userid.$invalid}"}
%label.col-md-2.control-label{"for" => "#{prefix}_userid"}
Expand Down Expand Up @@ -97,7 +75,6 @@
= change_stored_password
%a{:href => "", "ng-show" => "vm.bChangeStoredPassword", "ng-click" => "vm.cancelPasswordChange()"}
= cancel_password_change

%div{"ng-show" => "#{ng_show}", "ng-if" => "#{validate_button}"}
.form-group
%label.col-md-2
Expand Down
48 changes: 31 additions & 17 deletions app/views/layouts/angular/_multi_auth_credentials.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,38 @@
.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}"}
%div
.form-group{"ng-class" => "{'has-error': angularForm.default_service_account.$invalid}"}
%label.col-md-2.control-label{"for" => "default_service_account"}
= _("Assume role ARN")
.col-md-4
%input.form-control{"type" => "text",
"id" => "default_service_account",
"ng-required" => "false",
"ng-disabled" => "false",
"name" => "default_service_account",
"ng-model" => "#{main_scope}.#{ng_model}.default_service_account",
"checkchange" => "",
"ng-trim" => false,
"detect_spaces" => "",
"prefix" => "default",
"reset-validation-status" => "default_auth_status"}
= render :partial => "layouts/angular-bootstrap/auth_credentials_angular_bootstrap",
:locals => {:ng_show => true,
:ng_model => "#{ng_model}",
:ng_reqd_userid => true,
:ng_reqd_password => true,
:validate_url => validate_url,
:userid_label => _("Access Key ID"),
:password_label => _("Secret Access Key"),
:verify_label => _("Confirm Secret Access Key"),
:passwd_mismatch => _("Secret Access Keys do not match"),
:change_stored_password => _("Change stored secret access key"),
:cancel_password_change => _("Cancel secret access key change"),
:ng_show_service_account => true,
:service_account_label => _("Assume role ARN"),
:id => record.id,
:prefix => "default",
:verify_title_off => _("Access Key ID and matching Secret Access Key fields are needed to perform verification of credentials"),
:basic_info_needed => true}
:locals => {:ng_show => true,
:ng_model => "#{ng_model}",
:ng_reqd_userid => true,
:ng_reqd_password => true,
:validate_url => validate_url,
:userid_label => _("Access Key ID"),
:password_label => _("Secret Access Key"),
:verify_label => _("Confirm Secret Access Key"),
:passwd_mismatch => _("Secret Access Keys do not match"),
:change_stored_password => _("Change stored secret access key"),
:cancel_password_change => _("Cancel secret access key change"),
:id => record.id,
:prefix => "default",
:verify_title_off => _("Access Key ID and matching Secret Access Key fields are needed to perform verification of credentials"),
:basic_info_needed => true}
.col-md-12{"ng-if" => "#{ng_model}" == "emsCommonModel" && "#{ng_model}.emstype == 'gce'"}
= render :partial => "layouts/angular/auth_service_account_angular",
:locals => {:ng_show => true,
Expand Down
8 changes: 4 additions & 4 deletions spec/controllers/mixins/ems_common/angular_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,10 @@
before do
@ems_cloud_controller = EmsCloudController.new
@params = {
:default_userid => "abc",
:default_password => "abc",
:default_url => "http://abc.test/mypath",
:service_account => "test_arn",
:default_userid => "abc",
:default_password => "abc",
:default_url => "http://abc.test/mypath",
:default_service_account => "test_arn",
}
@ems = FactoryBot.create(:ems_amazon)
allow(@ems).to receive(:to_s).and_return('ManageIQ::Providers::Amazon::CloudManager')
Expand Down

0 comments on commit fc9d55a

Please sign in to comment.