From 26eb2e30a05ede92453e552ee27310c8566474ed Mon Sep 17 00:00:00 2001 From: nimrodshn Date: Thu, 8 Jun 2017 17:38:08 +0300 Subject: [PATCH] further changes to ui for support refactoring --- .../ems_common/ems_common_form_controller.js | 19 +++--- app/controllers/mixins/ems_common_angular.rb | 62 +++++++++++-------- .../angular/_multi_auth_credentials.html.haml | 2 +- 3 files changed, 48 insertions(+), 35 deletions(-) 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 69b196d5fff..1b666519821 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 @@ -15,6 +15,12 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', ' project: '', default_api_port: '', amqp_api_port: '', + prometheus_hostname: '', + prometheus_api_port: '', + monitoring_selection: '', + prometheus_tls_ca_certs: '', + prometheus_auth_status: '', + prometheus_security_protocol: '', hawkular_api_port: '', metrics_api_port: '', api_version: '', @@ -48,7 +54,6 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', ' host_default_vnc_port_start: '', host_default_vnc_port_end: '', event_stream_selection: '', - metrics_selection: '', bearer_token_exists: false, ems_controller: '', default_auth_status: '', @@ -138,8 +143,6 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', ' $scope.emsCommonModel.host_default_vnc_port_end = data.host_default_vnc_port_end; $scope.emsCommonModel.event_stream_selection = data.event_stream_selection; - $scope.emsCommonModel.metrics_selection = data.metrics_selection; - $scope.emsCommonModel.metrics_selection_default = data.metrics_selection_default; $scope.emsCommonModel.bearer_token_exists = data.bearer_token_exists; @@ -186,7 +189,6 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', ' $scope.emsCommonModel.openstack_infra_providers_exist = data.openstack_infra_providers_exist; $scope.emsCommonModel.default_api_port = ''; $scope.emsCommonModel.amqp_api_port = '5672'; - $scope.emsCommonModel.metrics_selection = data.metrics_selection; $scope.emsCommonModel.hawkular_api_port = '443'; $scope.emsCommonModel.prometheus_api_port = '80'; $scope.emsCommonModel.prometheus_auth_status = data.prometheus_auth_status; @@ -196,6 +198,8 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', ' $scope.emsCommonModel.monitoring_selection = data.monitoring_selection; $scope.emsCommonModel.default_security_protocol = data.default_security_protocol; $scope.emsCommonModel.hawkular_security_protocol = data.hawkular_security_protocol; + $scope.emsCommonModel.prometheus_security_protocol = data.prometheus_security_protocol; + $scope.emsCommonModel.prometheus_tls_ca_certs = data.prometheus_tls_ca_certs; $scope.emsCommonModel.default_tls_ca_certs = data.default_tls_ca_certs; $scope.emsCommonModel.hawkular_tls_ca_certs = data.hawkular_tls_ca_certs; $scope.emsCommonModel.default_auth_status = data.default_auth_status; @@ -203,6 +207,7 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', ' $scope.emsCommonModel.service_account_auth_status = data.service_account_auth_status; $scope.emsCommonModel.metrics_auth_status = true; $scope.emsCommonModel.ssh_keypair_auth_status = true; + $scope.emsCommonModel.prometheus_auth_status = data.prometheus_auth_status; $scope.emsCommonModel.hawkular_auth_status = data.hawkular_auth_status; $scope.emsCommonModel.vmware_cloud_api_version = '9.0'; miqService.sparkleOff(); @@ -325,10 +330,6 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', ' $scope.$broadcast('clearErrorOnTab', {tab: "amqp"}); } - if ($scope.emsCommonModel.metrics_selection === "hawkular_disabled") { - $scope.$broadcast('clearErrorOnTab', {tab: "hawkular"}); - } - var authStatus = $scope.currentTab + "_auth_status"; if ($scope.emsCommonModel[authStatus] === true) { $scope.postValidationModelRegistry($scope.currentTab); @@ -368,7 +369,7 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', ' $scope.providerTypeChanged = function() { if ($scope.emsCommonModel.ems_controller === 'ems_container') { $scope.emsCommonModel.default_api_port = "8443"; // TODO: correct per-type port - $scope.emsCommonModel.metrics_selection = "hawkular_".concat($scope.emsCommonModel.metrics_selection_default); + // Should we revert to emsCommonModel.monitoring_selection == "disabled" ? // Container types are nearly identical, no point resetting most fields on type change. return; } diff --git a/app/controllers/mixins/ems_common_angular.rb b/app/controllers/mixins/ems_common_angular.rb index 8e1b5b2f02b..e09052a0136 100644 --- a/app/controllers/mixins/ems_common_angular.rb +++ b/app/controllers/mixins/ems_common_angular.rb @@ -180,6 +180,15 @@ def ems_form_fields hawkular_tls_ca_certs = @ems.connection_configurations.hawkular.endpoint.certificate_authority end + if @ems.connection_configurations.prometheus.try(:endpoint) + prometheus_hostname = @ems.connection_configurations.prometheus.endpoint.hostname + prometheus_api_port = @ems.connection_configurations.prometheus.endpoint.port + prometheus_auth_status = @ems.authentication_status_ok?(:prometheus) + prometheus_security_protocol = @ems.connection_configurations.prometheus.endpoint.security_protocol + prometheus_security_protocol ||= security_protocol_default + prometheus_tls_ca_certs = @ems.connection_configurations.prometheus.endpoint.certificate_authority + end + if @ems.connection_configurations.default.try(:endpoint) default_hostname = @ems.connection_configurations.default.endpoint.hostname default_api_port = @ems.connection_configurations.default.endpoint.port @@ -273,30 +282,33 @@ def ems_form_fields :ssh_keypair_auth_status => ssh_keypair_auth_status.nil? ? true : ssh_keypair_auth_status } if controller_name == "ems_infra" - render :json => {:name => @ems.name, - :emstype => @ems.emstype, - :zone => zone, - :hostname => @ems.hostname, - :default_hostname => @ems.connection_configurations.default.endpoint.hostname, - :monitoring_selection => retrieve_monitoring_selection, - :metrics_selection_default => @ems.emstype == 'kubernetes' ? 'disabled' : 'enabled', - :hawkular_hostname => hawkular_hostname, - :default_api_port => @ems.connection_configurations.default.endpoint.port, - :hawkular_api_port => hawkular_api_port, - :prometheus_hostname => prometheus_hostname, - :prometheus_api_port => prometheus_api_port, - :api_version => @ems.api_version ? @ems.api_version : "v2", - :default_security_protocol => default_security_protocol, - :hawkular_security_protocol => hawkular_security_protocol, - :default_tls_ca_certs => default_tls_ca_certs, - :hawkular_tls_ca_certs => hawkular_tls_ca_certs, - :provider_region => @ems.provider_region, - :default_userid => @ems.authentication_userid ? @ems.authentication_userid : "", - :service_account => service_account ? service_account : "", - :bearer_token_exists => @ems.authentication_token(:bearer).nil? ? false : true, - :ems_controller => controller_name, - :default_auth_status => default_auth_status, - :hawkular_auth_status => hawkular_auth_status, + render :json => { :name => @ems.name, + :emstype => @ems.emstype, + :zone => zone, + :hostname => @ems.hostname, + :default_hostname => @ems.connection_configurations.default.endpoint.hostname, + :monitoring_selection => retrieve_monitoring_selection, + :metrics_selection_default => @ems.emstype == 'kubernetes' ? 'disabled' : 'enabled', + :hawkular_hostname => hawkular_hostname, + :default_api_port => @ems.connection_configurations.default.endpoint.port, + :hawkular_api_port => hawkular_api_port, + :prometheus_hostname => prometheus_hostname, + :prometheus_api_port => prometheus_api_port, + :prometheus_tls_ca_certs => prometheus_tls_ca_certs, + :prometheus_security_protocol => prometheus_security_protocol, + :api_version => @ems.api_version ? @ems.api_version : "v2", + :default_security_protocol => default_security_protocol, + :hawkular_security_protocol => hawkular_security_protocol, + :default_tls_ca_certs => default_tls_ca_certs, + :hawkular_tls_ca_certs => hawkular_tls_ca_certs, + :provider_region => @ems.provider_region, + :default_userid => @ems.authentication_userid ? @ems.authentication_userid : "", + :service_account => service_account ? service_account : "", + :bearer_token_exists => @ems.authentication_token(:bearer).nil? ? false : true, + :ems_controller => controller_name, + :default_auth_status => default_auth_status, + :prometheus_auth_status => prometheus_auth_status, + :hawkular_auth_status => hawkular_auth_status, } if controller_name == "ems_container" if controller_name == "ems_middleware" @@ -373,7 +385,7 @@ def set_ems_record_vars(ems, mode = nil) hawkular_security_protocol = params[:hawkular_security_protocol].strip if params[:hawkular_security_protocol] default_tls_ca_certs = params[:default_tls_ca_certs].strip if params[:default_tls_ca_certs] hawkular_tls_ca_certs = params[:hawkular_tls_ca_certs].strip if params[:hawkular_tls_ca_certs] - prometheus_tls_ca_certs = params[:hawkular_tls_ca_certs].strip if params[:hawkular_tls_ca_certs] + prometheus_tls_ca_certs = params[:prometheus_tls_ca_certs].strip if params[:prometheus_tls_ca_certs] default_endpoint = {} amqp_endpoint = {} ceilometer_endpoint = {} diff --git a/app/views/layouts/angular/_multi_auth_credentials.html.haml b/app/views/layouts/angular/_multi_auth_credentials.html.haml index a066985666d..363b46e95b3 100644 --- a/app/views/layouts/angular/_multi_auth_credentials.html.haml +++ b/app/views/layouts/angular/_multi_auth_credentials.html.haml @@ -265,7 +265,7 @@ %label.col-md-2.control-label{"for" => "prov_monitoring"} = _("Monitoring") .col-md-8 - = select_tag('monitoring_selection', options_for_select([["<#{_('Choose>')}", nil] ,[_("Disabled"), "disabled"], [_("Hawkular"), "hawkular"], + = select_tag('monitoring_selection', options_for_select([[_("Disabled"), "disabled"], [_("Hawkular"), "hawkular"], [_("Prometheus"), "prometheus"]]), "ng-model" => "emsCommonModel.monitoring_selection", "checkchange" => "",