diff --git a/app/assets/javascripts/controllers/ems_common/ems_common_form_controller.js b/app/assets/javascripts/controllers/ems_common/ems_common_form_controller.js index cadeedc1b0c..50b467e324f 100644 --- a/app/assets/javascripts/controllers/ems_common/ems_common_form_controller.js +++ b/app/assets/javascripts/controllers/ems_common/ems_common_form_controller.js @@ -309,8 +309,8 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', ' ($scope.emsCommonModel.emstype == "ec2" || ['kubevirt', 'nuage_network', 'openstack', 'openstack_infra', 'rhevm', 'scvmm', 'vmwarews', 'vmware_cloud'].includes($scope.emsCommonModel.emstype) && $scope.emsCommonModel.default_hostname) && - ($scope.emsCommonModel.default_userid != '' && $scope.angularForm.default_userid.$valid && - $scope.emsCommonModel.default_password != '' && $scope.angularForm.default_password.$valid)) { + ($scope.emsCommonModel.default_userid != '' && $scope.angularForm.default_userid !== undefined && $scope.angularForm.default_userid.$valid && + $scope.emsCommonModel.default_password != '' && $scope.angularForm.default_password !== undefined && $scope.angularForm.default_password.$valid)) { return true; } else if(($scope.currentTab == "amqp") && ($scope.emsCommonModel.amqp_hostname) && @@ -331,7 +331,8 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', ' $scope.emsCommonModel.default_password != '' && $scope.angularForm.default_password.$valid) && ($scope.newRecord && $scope.angularForm.provider_region.$valid || ! $scope.newRecord)) { return true; - } else if(($scope.currentTab == "ssh_keypair" && $scope.emsCommonModel.emstype == "openstack_infra") && + } else if(($scope.currentTab == "ssh_keypair" && + ($scope.emsCommonModel.emstype == "openstack" || $scope.emsCommonModel.emstype == "openstack_infra")) && ($scope.emsCommonModel.ssh_keypair_userid != '' && $scope.angularForm.ssh_keypair_userid.$valid && $scope.emsCommonModel.ssh_keypair_password != '' && $scope.angularForm.ssh_keypair_password.$valid)) { return true; diff --git a/app/assets/javascripts/controllers/ems_keypair/ems_keypair_controller.js b/app/assets/javascripts/controllers/ems_keypair/ems_keypair_controller.js index 004bf7e1ad1..034e7b29460 100644 --- a/app/assets/javascripts/controllers/ems_keypair/ems_keypair_controller.js +++ b/app/assets/javascripts/controllers/ems_keypair/ems_keypair_controller.js @@ -63,9 +63,10 @@ }; EmsKeypairController.prototype.showValidate = function(tab) { - var openstackAndNew = (this.model.emstype === 'openstack_infra') && this.newRecord; + var openstackInfraAndNew = (this.model.emstype === 'openstack_infra') && this.newRecord; + var openstackCloud = this.model.emstype === 'openstack'; var rhevm = this.model.emstype === 'rhevm'; - return ! ((openstackAndNew || rhevm) && tab === 'ssh_keypair'); + return ! ((openstackInfraAndNew || openstackCloud || rhevm) && tab === 'ssh_keypair'); }; EmsKeypairController.$inject = ["$scope"]; diff --git a/app/controllers/mixins/ems_common_angular.rb b/app/controllers/mixins/ems_common_angular.rb index f00cf37cc1b..a544e76384d 100644 --- a/app/controllers/mixins/ems_common_angular.rb +++ b/app/controllers/mixins/ems_common_angular.rb @@ -374,6 +374,7 @@ def ems_form_fields :openstack_infra_providers_exist => retrieve_openstack_infra_providers.length.positive?, :default_userid => @ems.authentication_userid.to_s, :amqp_userid => amqp_userid, + :ssh_keypair_userid => ssh_keypair_userid, :smartstate_docker_userid => smartstate_docker_userid, :service_account => service_account.to_s, :azure_tenant_id => azure_tenant_id.to_s, @@ -387,6 +388,7 @@ def ems_form_fields :ems_controller => controller_name, :default_auth_status => default_auth_status, :amqp_auth_status => amqp_auth_status, + :ssh_keypair_auth_status => ssh_keypair_auth_status.nil? ? true : ssh_keypair_auth_status, :service_account_auth_status => service_account_auth_status, :amqp_fallback_hostname1 => amqp_fallback_hostname1 ? amqp_fallback_hostname1 : "", :amqp_fallback_hostname2 => amqp_fallback_hostname2 ? amqp_fallback_hostname2 : "", @@ -563,7 +565,7 @@ def set_ems_record_vars(ems, mode = nil) end end - if ems.kind_of?(ManageIQ::Providers::Openstack::InfraManager) || ems.kind_of?(ManageIQ::Providers::Redhat::InfraManager) + if ems.kind_of?(ManageIQ::Providers::Openstack::CloudManager) || ems.kind_of?(ManageIQ::Providers::Openstack::InfraManager) || ems.kind_of?(ManageIQ::Providers::Redhat::InfraManager) ssh_keypair_endpoint = {:role => :ssh_keypair} end @@ -754,12 +756,9 @@ def build_credentials(ems, mode) 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} end - if ems.kind_of?(ManageIQ::Providers::Openstack::InfraManager) && - ems.supports_authentication?(:ssh_keypair) && params[:ssh_keypair_userid] - ssh_keypair_password = params[:ssh_keypair_password] ? params[:ssh_keypair_password].gsub(/\r\n/, "\n") : ems.authentication_key(:ssh_keypair) - creds[:ssh_keypair] = {:userid => params[:ssh_keypair_userid], :auth_key => ssh_keypair_password, :save => (mode != :validate)} - end - if ems.kind_of?(ManageIQ::Providers::Redhat::InfraManager) && + if (ems.kind_of?(ManageIQ::Providers::Openstack::InfraManager) || + ems.kind_of?(ManageIQ::Providers::Openstack::CloudManager) || + ems.kind_of?(ManageIQ::Providers::Redhat::InfraManager)) && ems.supports_authentication?(:ssh_keypair) && params[:ssh_keypair_userid] ssh_keypair_password = params[:ssh_keypair_password] ? params[:ssh_keypair_password].gsub(/\r\n/, "\n") : ems.authentication_key(:ssh_keypair) creds[:ssh_keypair] = {:userid => params[:ssh_keypair_userid], :auth_key => ssh_keypair_password, :save => (mode != :validate)} diff --git a/app/views/layouts/angular/_multi_auth_credentials.html.haml b/app/views/layouts/angular/_multi_auth_credentials.html.haml index e1463d64280..064e9b6a4dc 100644 --- a/app/views/layouts/angular/_multi_auth_credentials.html.haml +++ b/app/views/layouts/angular/_multi_auth_credentials.html.haml @@ -301,7 +301,7 @@ = _("Disable event monitoring.") = miq_tab_content('ssh_keypair', 'default') do .form-group - .col-md-12.col-md-12{"ng-if" => "#{ng_model}" == "emsCommonModel" && ("#{ng_model}.emstype == 'openstack_infra' || #{ng_model}.emstype == 'rhevm'") } + .col-md-12.col-md-12{"ng-if" => "#{ng_model}" == "emsCommonModel" && ("#{ng_model}.emstype == 'openstack' || #{ng_model}.emstype == 'openstack_infra' || #{ng_model}.emstype == 'rhevm'") } = render :partial => "layouts/angular-bootstrap/auth_keypair_angular_bootstrap", :locals => {:ng_show => true, :ng_model => "#{ng_model}", @@ -531,7 +531,7 @@ miq_tabs_show_hide("#ssh_keypair_tab", false); miq_tabs_init('#auth_tabs'); $('#auth_tabs').show(); -%div{"ng-if" => "#{ng_model}.emstype == 'openstack' || #{ng_model}.emstype == 'vmware_cloud'"} +%div{"ng-if" => "#{ng_model}.emstype == 'vmware_cloud'"} :javascript miq_tabs_show_hide("#amqp_tab", true); miq_tabs_show_hide("#metrics_tab", false); @@ -540,7 +540,7 @@ miq_tabs_show_hide("#smartstate_docker_tab", false); miq_tabs_init('#auth_tabs'); $('#auth_tabs').show(); -%div{"ng-if" => "#{ng_model}.emstype == 'openstack_infra'"} +%div{"ng-if" => "#{ng_model}.emstype == 'openstack' || #{ng_model}.emstype == 'openstack_infra'"} :javascript miq_tabs_show_hide("#amqp_tab", true); miq_tabs_show_hide("#metrics_tab", false); diff --git a/spec/javascripts/controllers/ems_keypair/ems_keypair_controller_spec.js b/spec/javascripts/controllers/ems_keypair/ems_keypair_controller_spec.js index bb6b63a2732..399f0d10944 100644 --- a/spec/javascripts/controllers/ems_keypair/ems_keypair_controller_spec.js +++ b/spec/javascripts/controllers/ems_keypair/ems_keypair_controller_spec.js @@ -72,6 +72,10 @@ describe('emsKeypairController', function() { describe('#showValidate', function() { var combinations = [ + { emstype: 'openstack', newRecord: true, tab: 'ssh_keypair', value: false }, + { emstype: 'openstack', newRecord: true, tab: 'other_tab', value: true }, + { emstype: 'openstack', newRecord: false, tab: 'tab', value: true }, + { emstype: 'openstack_infra', newRecord: true, tab: 'ssh_keypair', value: false }, { emstype: 'openstack_infra', newRecord: true, tab: 'other_tab', value: true }, { emstype: 'openstack_infra', newRecord: false, tab: 'tab', value: true },