Skip to content

Commit

Permalink
Merge pull request #4388 from sseago/v2v_sshkey
Browse files Browse the repository at this point in the history
add sshkey support to OpenStack Cloud
  • Loading branch information
himdel authored Aug 29, 2018
2 parents 69f4f9b + cdc619f commit 3f140ac
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) &&
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down
13 changes: 6 additions & 7 deletions app/controllers/mixins/ems_common_angular.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 : "",
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)}
Expand Down
6 changes: 3 additions & 3 deletions app/views/layouts/angular/_multi_auth_credentials.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down

0 comments on commit 3f140ac

Please sign in to comment.