Skip to content

Commit

Permalink
add sshkey support to OpenStack Cloud
Browse files Browse the repository at this point in the history
Add sshkey support to OpenStack Cloud needed for v2v.
  • Loading branch information
sseago committed Aug 22, 2018
1 parent a46f071 commit 4a89279
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
$scope.emsCommonModel.emstype === "kubevirt" && $scope.emsCommonModel.default_hostname ||
$scope.emsCommonModel.emstype == "vmwarews" && $scope.emsCommonModel.default_hostname ||
$scope.emsCommonModel.emstype == "vmware_cloud" && $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 @@ -337,7 +337,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
9 changes: 8 additions & 1 deletion app/controllers/mixins/ems_common_angular.rb
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ def ems_form_fields
:openstack_infra_providers_exist => retrieve_openstack_infra_providers.length > 0,
: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 @@ -388,6 +389,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 @@ -564,7 +566,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 @@ -760,6 +762,11 @@ def build_credentials(ems, mode)
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::Openstack::CloudManager) &&
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) &&
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)
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 4a89279

Please sign in to comment.