Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SmartState Docker Creds for AWS #2525

Merged
merged 2 commits into from
Oct 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
default_password: '',
amqp_userid: '',
amqp_password: '',
smartstate_docker_userid: '',
smartstate_docker_password: '',
metrics_userid: '',
metrics_password: '',
metrics_database_name: '',
Expand Down Expand Up @@ -131,6 +133,7 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
$scope.emsCommonModel.default_userid = data.default_userid;
$scope.emsCommonModel.amqp_userid = data.amqp_userid;
$scope.emsCommonModel.metrics_userid = data.metrics_userid;
$scope.emsCommonModel.smartstate_docker_userid = data.smartstate_docker_userid;
$scope.emsCommonModel.vmware_cloud_api_version = data.api_version;

$scope.emsCommonModel.ssh_keypair_userid = data.ssh_keypair_userid;
Expand Down Expand Up @@ -170,6 +173,9 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
if ($scope.emsCommonModel.metrics_userid !== '') {
$scope.emsCommonModel.metrics_password = miqService.storedPasswordPlaceholder;
}
if ($scope.emsCommonModel.smartstate_docker_userid !== '') {
$scope.emsCommonModel.smartstate_docker_password = miqService.storedPasswordPlaceholder;
}
if ($scope.emsCommonModel.ssh_keypair_userid !== '') {
$scope.emsCommonModel.ssh_keypair_password = miqService.storedPasswordPlaceholder;
}
Expand Down Expand Up @@ -253,6 +259,10 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
($scope.emsCommonModel.amqp_userid != '' && $scope.angularForm.amqp_userid !== undefined && $scope.angularForm.amqp_userid.$valid &&
$scope.emsCommonModel.amqp_password != '' && $scope.angularForm.amqp_password !== undefined && $scope.angularForm.amqp_password.$valid)) {
return true;
} else if(($scope.currentTab == "smartstate_docker") &&
($scope.emsCommonModel.smartstate_docker_userid != '' && $scope.angularForm.smartstate_docker_userid !== undefined &&
$scope.emsCommonModel.smartstate_docker_password != '' && $scope.angularForm.smartstate_docker_password !== undefined)) {
return true;
} else if(($scope.currentTab == "default" && $scope.emsCommonModel.emstype == "azure") &&
($scope.emsCommonModel.azure_tenant_id != '' && $scope.angularForm.azure_tenant_id.$valid) &&
($scope.emsCommonModel.default_userid != '' && $scope.angularForm.default_userid.$valid &&
Expand Down Expand Up @@ -470,6 +480,9 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
if ($scope.emsCommonModel.amqp_auth_status === true) {
$scope.postValidationModelRegistry("amqp");
}
if ($scope.emsCommonModel.smartstate_docker_auth_status === true) {
$scope.postValidationModelRegistry("smartstate_docker");
}
if ($scope.emsCommonModel.service_account_auth_status === true) {
$scope.postValidationModelRegistry("service_account");
}
Expand All @@ -489,6 +502,7 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
$scope.postValidationModel = {
default: {},
amqp: {},
smartstate_docker: {},
metrics: {},
ssh_keypair: {},
prometheus_alerts: {},
Expand Down Expand Up @@ -526,6 +540,16 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
amqp_userid: $scope.emsCommonModel.amqp_userid,
amqp_password: amqp_password,
};
} else if (prefix === "smartstate_docker") {
if ($scope.newRecord) {
var smartstate_docker_password = $scope.emsCommonModel.smartstate_docker_password;
} else {
var smartstate_docker_password = $scope.emsCommonModel.smartstate_docker_password === "" ? "" : miqService.storedPasswordPlaceholder;
}
$scope.postValidationModel.smartstate_docker = {
smartstate_docker_userid: $scope.emsCommonModel.smartstate_docker_userid,
smartstate_docker_password: smartstate_docker_password,
};
} else if (prefix === "metrics") {
var metricsValidationModel = {
metrics_hostname: $scope.emsCommonModel.metrics_hostname,
Expand Down
16 changes: 15 additions & 1 deletion app/controllers/mixins/ems_common_angular.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ def ems_form_fields
amqp_hostname = ""
amqp_port = ""
amqp_security_protocol = ""
smartstate_docker_userid = ""
ssh_keypair_userid = ""
metrics_userid = ""
metrics_hostname = ""
Expand All @@ -206,6 +207,11 @@ def ems_form_fields
amqp_auth_status = @ems.authentication_status_ok?(:amqp)
end

if @ems.has_authentication_type?(:smartstate_docker)
smartstate_docker_userid = @ems.has_authentication_type?(:smartstate_docker) ? @ems.authentication_userid(:smartstate_docker).to_s : ""
smartstate_docker_auth_status = true
end

if @ems.has_authentication_type?(:ssh_keypair)
ssh_keypair_userid = @ems.has_authentication_type?(:ssh_keypair) ? @ems.authentication_userid(:ssh_keypair).to_s : ""
ssh_keypair_auth_status = @ems.authentication_status_ok?(:ssh_keypair)
Expand Down Expand Up @@ -296,6 +302,7 @@ def ems_form_fields
:openstack_infra_providers_exist => retrieve_openstack_infra_providers.length > 0,
:default_userid => @ems.authentication_userid ? @ems.authentication_userid : "",
:amqp_userid => amqp_userid,
:smartstate_docker_userid => smartstate_docker_userid,
:service_account => service_account ? service_account : "",
:azure_tenant_id => azure_tenant_id ? azure_tenant_id : "",
:keystone_v3_domain_id => keystone_v3_domain_id,
Expand All @@ -308,6 +315,7 @@ def ems_form_fields
:ems_controller => controller_name,
:default_auth_status => default_auth_status,
:amqp_auth_status => amqp_auth_status,
:smartstate_docker_auth_status => smartstate_docker_auth_status,
:service_account_auth_status => service_account_auth_status
} if controller_name == "ems_cloud" || controller_name == "ems_network"

Expand Down Expand Up @@ -574,6 +582,7 @@ def set_ems_record_vars(ems, mode = nil)
endpoints = {:default => default_endpoint,
:ceilometer => ceilometer_endpoint,
:amqp => amqp_endpoint,
:smartstate_docker => default_endpoint,
:ssh_keypair => ssh_keypair_endpoint,
:metrics => metrics_endpoint,
:hawkular => hawkular_endpoint,
Expand All @@ -595,7 +604,7 @@ def build_connection(ems, endpoints, mode)
authentications = build_credentials(ems, mode)
configurations = []

[:default, :ceilometer, :amqp, :ssh_keypair, :metrics, :hawkular, :prometheus, :prometheus_alerts].each do |role|
[:default, :ceilometer, :amqp, :smartstate_docker, :ssh_keypair, :metrics, :hawkular, :prometheus, :prometheus_alerts].each do |role|
configurations << build_configuration(ems, authentications, endpoints, role)
end

Expand All @@ -622,6 +631,11 @@ def build_credentials(ems, mode)
amqp_password = params[:amqp_password] ? params[:amqp_password] : ems.authentication_password(:amqp)
creds[:amqp] = {:userid => params[:amqp_userid], :password => amqp_password, :save => (mode != :validate)}
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}
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)
Expand Down
17 changes: 9 additions & 8 deletions app/helpers/textual_summary_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,15 @@ def textual_authentications(authentications)

authentications.collect do |auth|
label = case auth[:authtype]
when "default" then _("Default")
when "metrics" then _("C & U Database")
when "amqp" then _("AMQP")
when "ipmi" then _("IPMI")
when "remote" then _("Remote Login")
when "ws" then _("Web Services")
when "ssh_keypair" then _("SSH Key Pair")
else; _("<Unknown>")
when "default" then _("Default")
when "metrics" then _("C & U Database")
when "amqp" then _("AMQP")
when "ipmi" then _("IPMI")
when "remote" then _("Remote Login")
when "smartstate_docker" then _("SmartState Docker")
when "ws" then _("Web Services")
when "ssh_keypair" then _("SSH Key Pair")
else; _("<Unknown>")
end

{:label => _("%{label} Credentials") % {:label => label},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
- validate = "#{main_scope}.validateClicked({target: '.validate_button:visible'}, '#{valtype}', true, angularForm, '#{url_for_only_path(:action => validate_url, :id => id, :type => valtype, :button => "validate")}')"
- else
- validate = "#{main_scope}.validateClicked('#{url_for_only_path(:action => validate_url, :id => id, :type => valtype, :button => "validate")}')"
%div{"ng-show" => ng_show}
%div{"ng-if" => "#{main_scope}.currentTab != 'smartstate_docker'"}
%miq-button{:class => 'validate_button',
:name => _("Validate"),
"disabled-title" => verify_title_off,
Expand Down
44 changes: 42 additions & 2 deletions app/views/layouts/angular/_multi_auth_credentials.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
= miq_tab_header('ssh_keypair', nil, {'ng-click' => "changeAuthTab('ssh_keypair')"}) do
%i{"error-on-tab" => "ssh_keypair", :style => "color:#cc0000"}
= _("RSA key pair")
= miq_tab_header('smartstate_docker', nil, {'ng-click' => "changeAuthTab('smartstate_docker')"}) do
%i{"error-on-tab" => "smartstate_docker", :style => "color:#cc0000"}
= _("SmartState Docker")
- elsif controller_name == "ems_container"
= miq_tab_header('metrics', nil, 'ng-click' => "changeAuthTab('metrics')") do
%div{"ng-if" => "emsCommonModel.metrics_selection == 'prometheus' || emsCommonModel.metrics_selection == 'hawkular'"}
Expand Down Expand Up @@ -149,6 +152,32 @@
%span{:style => "color:black"}
= _("Required. Used to gather Utilization data.")

- if %w(ems_cloud).include?(params[:controller])
= miq_tab_content('smartstate_docker', 'default') do
.form-group
.col-md-12{"ng-if" => "#{ng_model}" == "emsCommonModel" && "#{ng_model}.emstype == 'ec2'"}
= render :partial => "layouts/angular-bootstrap/auth_credentials_angular_bootstrap",
:locals => {:ng_show => true,
:ng_model => "#{ng_model}",
:ng_reqd_userid => false,
:ng_reqd_password => false,
:ng_show_userid => "true",
:ng_show_password => "true",
:validate_url => validate_url,
:id => record.id,
:prefix => "smartstate_docker",
:userid_label => _("SmartState Docker User Name"),
:password_label => _("SmartState Docker Password"),
:verify_label => _("Confirm SmartState Password"),
:passwd_mismatch => _("SmartState Docker Passwords do not match"),
:change_stored_password => _("Change stored SmartState Docker password"),
:cancel_password_change => _("Cancel SmartState Docker password change"),
:verify_title_off => _("Docker Registry User Name and Password for SmartState Analysis on AWS"),
:basic_info_needed => true}
.form-group
.col-md-12
%span{:style => "color:black"}
= _("Used for Docker Registry credentials required to perform SmartState Analysis on AWS.")
- if %w(ems_cloud ems_infra ems_network).include?(params[:controller])
= miq_tab_content('metrics', 'default') do
.form-group
Expand Down Expand Up @@ -387,8 +416,7 @@
%div{"ng-if" => "#{ng_model}.emstype == ''"}
:javascript
$('#auth_tabs').hide();
%div{"ng-if" => "#{ng_model}.emstype == 'ec2' || " + |
"#{ng_model}.emstype == 'gce' || " + |
%div{"ng-if" => "#{ng_model}.emstype == 'gce' || " + |
"#{ng_model}.emstype == 'scvmm' || " + |
"#{ng_model}.emstype == 'vmwarews' || " + |
"#{ng_model}.emstype == 'lenovo_ph_infra' || " + |
Expand All @@ -398,27 +426,39 @@
miq_tabs_show_hide("#amqp_tab", false);
miq_tabs_show_hide("#metrics_tab", false);
miq_tabs_show_hide("#ssh_keypair_tab", false);
miq_tabs_show_hide("#smartstate_docker_tab", false);
miq_tabs_init('#auth_tabs');
$('#auth_tabs').show();
%div{"ng-if" => "#{ng_model}.emstype == 'ec2'"}
:javascript
miq_tabs_show_hide("#amqp_tab", false);
miq_tabs_show_hide("#metrics_tab", false);
miq_tabs_show_hide("#ssh_keypair_tab", false);
miq_tabs_show_hide("#smartstate_docker_tab", true);
miq_tabs_init('#auth_tabs');
$('#auth_tabs').show();
%div{"ng-if" => "#{ng_model}.emstype == 'rhevm'"}
:javascript
miq_tabs_show_hide("#amqp_tab", false);
miq_tabs_show_hide("#metrics_tab", true);
miq_tabs_show_hide("#ssh_keypair_tab", false);
miq_tabs_show_hide("#smartstate_docker_tab", false);
miq_tabs_init('#auth_tabs');
$('#auth_tabs').show();
%div{"ng-if" => "#{ng_model}.emstype == 'openstack' || #{ng_model}.emstype == 'vmware_cloud'"}
:javascript
miq_tabs_show_hide("#amqp_tab", true);
miq_tabs_show_hide("#metrics_tab", false);
miq_tabs_show_hide("#ssh_keypair_tab", false);
miq_tabs_show_hide("#smartstate_docker_tab", false);
miq_tabs_init('#auth_tabs');
$('#auth_tabs').show();
%div{"ng-if" => "#{ng_model}.emstype == 'openstack_infra'"}
:javascript
miq_tabs_show_hide("#amqp_tab", true);
miq_tabs_show_hide("#metrics_tab", false);
miq_tabs_show_hide("#ssh_keypair_tab", true);
miq_tabs_show_hide("#smartstate_docker_tab", false);
miq_tabs_init('#auth_tabs');
$('#auth_tabs').show();
%div{"ng-if" => "#{ng_model}.emstype == 'nuage_network'"}
Expand Down