Skip to content

Commit

Permalink
Merge pull request #2531 from gasper-vrhovsek/feature/nuage-events-ui
Browse files Browse the repository at this point in the history
Add fallback hostname form input fields for Nuage Network Provider
  • Loading branch information
h-kataria committed Oct 30, 2017
2 parents 20f1b41 + 829d3a9 commit 5760f28
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 3 deletions.
Expand Up @@ -108,6 +108,8 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
$scope.emsCommonModel.hostname = data.hostname;
$scope.emsCommonModel.default_hostname = data.default_hostname;
$scope.emsCommonModel.amqp_hostname = data.amqp_hostname;
$scope.emsCommonModel.amqp_fallback_hostname1 = data.amqp_fallback_hostname1;
$scope.emsCommonModel.amqp_fallback_hostname2 = data.amqp_fallback_hostname2;
$scope.emsCommonModel.metrics_selection = data.metrics_selection;
$scope.emsCommonModel.metrics_hostname = data.metrics_hostname;
$scope.emsCommonModel.project = data.project;
Expand Down
19 changes: 17 additions & 2 deletions app/controllers/mixins/ems_common_angular.rb
Expand Up @@ -288,6 +288,11 @@ def ems_form_fields
service_account_auth_status = @ems.authentication_status_ok?
end

if @ems.kind_of?(ManageIQ::Providers::Nuage::NetworkManager)
amqp_fallback_hostname1 = @ems.connection_configurations.amqp_fallback1 ? @ems.connection_configurations.amqp_fallback1.endpoint.hostname : ""
amqp_fallback_hostname2 = @ems.connection_configurations.amqp_fallback2 ? @ems.connection_configurations.amqp_fallback2.endpoint.hostname : ""
end

render :json => {:name => @ems.name,
:emstype => @ems.emstype,
:zone => zone,
Expand Down Expand Up @@ -319,7 +324,9 @@ def ems_form_fields
: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
: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 : ""
} if controller_name == "ems_cloud" || controller_name == "ems_network"

render :json => { :name => @ems.name,
Expand Down Expand Up @@ -448,6 +455,8 @@ def set_ems_record_vars(ems, mode = nil)
hostname = params[:default_hostname].strip if params[:default_hostname]
port = params[:default_api_port].strip if params[:default_api_port]
amqp_hostname = params[:amqp_hostname].strip if params[:amqp_hostname]
amqp_fallback_hostname1 = params[:amqp_fallback_hostname1].strip if params[:amqp_fallback_hostname1]
amqp_fallback_hostname2 = params[:amqp_fallback_hostname2].strip if params[:amqp_fallback_hostname2]
amqp_port = params[:amqp_api_port].strip if params[:amqp_api_port]
amqp_security_protocol = params[:amqp_security_protocol].strip if params[:amqp_security_protocol]
metrics_hostname = params[:metrics_hostname].strip if params[:metrics_hostname]
Expand All @@ -462,6 +471,8 @@ def set_ems_record_vars(ems, mode = nil)
prometheus_alerts_security_protocol = params[:prometheus_alerts_security_protocol].strip if params[:prometheus_alerts_security_protocol]
default_endpoint = {}
amqp_endpoint = {}
amqp_fallback_endpoint1 = {}
amqp_fallback_endpoint2 = {}
ceilometer_endpoint = {}
ssh_keypair_endpoint = {}
metrics_endpoint = {}
Expand Down Expand Up @@ -556,6 +567,8 @@ def set_ems_record_vars(ems, mode = nil)
if ems.kind_of?(ManageIQ::Providers::Nuage::NetworkManager)
default_endpoint = {:role => :default, :hostname => hostname, :port => port, :security_protocol => ems.security_protocol}
amqp_endpoint = {:role => :amqp, :hostname => amqp_hostname, :port => amqp_port, :security_protocol => amqp_security_protocol}
amqp_fallback_endpoint1 = {:role => :amqp_fallback1, :hostname => amqp_fallback_hostname1, :port => amqp_port, :security_protocol => amqp_security_protocol}
amqp_fallback_endpoint2 = {:role => :amqp_fallback2, :hostname => amqp_fallback_hostname2, :port => amqp_port, :security_protocol => amqp_security_protocol}
end

if ems.kind_of?(ManageIQ::Providers::Lenovo::PhysicalInfraManager)
Expand Down Expand Up @@ -585,6 +598,8 @@ def set_ems_record_vars(ems, mode = nil)
:ceilometer => ceilometer_endpoint,
:amqp => amqp_endpoint,
:smartstate_docker => default_endpoint,
:amqp_fallback1 => amqp_fallback_endpoint1,
:amqp_fallback2 => amqp_fallback_endpoint2,
:ssh_keypair => ssh_keypair_endpoint,
:metrics => metrics_endpoint,
:hawkular => hawkular_endpoint,
Expand All @@ -606,7 +621,7 @@ def build_connection(ems, endpoints, mode)
authentications = build_credentials(ems, mode)
configurations = []

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

Expand Down
44 changes: 44 additions & 0 deletions app/views/layouts/angular-bootstrap/_endpoints_angular.html.haml
Expand Up @@ -96,6 +96,50 @@
:xs => 'true',
:primary => 'true'}
%div{"ng-if" => (defined?(hostname_hide) ? false : true) && (defined?(fallback_hostnames) ? fallback_hostnames : false)}
.form-group{"ng-class" => "{'has-error': angularForm.#{prefix}_fallback_hostname1.$invalid}"}
%label.col-md-2.control-label{"for" => "#{prefix}_fallback_hostname1"}
= _('Fallback Hostname 1')
.col-md-4
%input.form-control{"type" => "text",
"id" => "#{prefix}_fallback_hostname1",
"name" => "#{prefix}_fallback_hostname1",
"ng-model" => "#{ng_model}.#{prefix}_fallback_hostname1",
"maxlength" => ViewHelper::MAX_NAME_LEN.to_s,
"ng-required" => "#{ng_model}.#{prefix}_fallback_hostname2",
"ng-trim" => false,
"detect-spaces" => "",
"checkchange" => "",
"prefix" => prefix.to_s,
"reset-validation-status" => "#{prefix}_auth_status",
"placeholder" => "Hostname or IPv4 or IPv6 address"}
%span.help-block{"ng-show" => "angularForm.#{prefix}_fallback_hostname1.$error.required"}
= _("Required")
%span.help-block{"ng-show" => "angularForm.#{prefix}_fallback_hostname1.$error.detectedSpaces"}
= _("Spaces are prohibited")

%div{"ng-if" => (defined?(hostname_hide) ? false : true) && (defined?(fallback_hostnames) ? fallback_hostnames : false)}
.form-group{"ng-class" => "{'has-error': angularForm.#{prefix}_fallback_hostname2.$invalid}"}
%label.col-md-2.control-label{"for" => "#{prefix}_fallback_hostname2"}
= _('Fallback Hostname 2')
.col-md-4
%input.form-control{"type" => "text",
"id" => "#{prefix}_fallback_hostname2",
"name" => "#{prefix}_fallback_hostname2",
"ng-model" => "#{ng_model}.#{prefix}_fallback_hostname2",
"maxlength" => ViewHelper::MAX_NAME_LEN.to_s,
"ng-required" => "#{ng_model}.#{prefix}_fallback_hostname1",
"ng-trim" => false,
"detect-spaces" => "",
"checkchange" => "",
"prefix" => prefix.to_s,
"reset-validation-status" => "#{prefix}_auth_status",
"placeholder" => "Hostname or IPv4 or IPv6 address"}
%span.help-block{"ng-show" => "angularForm.#{prefix}_fallback_hostname2.$error.required"}
= _("Required")
%span.help-block{"ng-show" => "angularForm.#{prefix}_fallback_hostname2.$error.detectedSpaces"}
= _("Spaces are prohibited")

%div{"ng-if" => defined?(apiport_hide) ? false : true}
.form-group{"ng-class" => "{'has-error': angularForm.#{prefix}_api_port.$invalid}",
"ng-if" => "emsCommonModel.emstype == 'openstack' || " + |
Expand Down
3 changes: 2 additions & 1 deletion app/views/layouts/angular/_multi_auth_credentials.html.haml
Expand Up @@ -244,7 +244,8 @@
:ng_model => "#{ng_model}",
:id => record.id,
:prefix => "amqp",
:ng_reqd_api_port => "false"}
:ng_reqd_api_port => "false",
:fallback_hostnames => "#{ng_model}.emstype == 'nuage_network'"}
= render :partial => "layouts/angular-bootstrap/auth_credentials_angular_bootstrap",
:locals => {:ng_show => true,
:ng_model => "#{ng_model}",
Expand Down

0 comments on commit 5760f28

Please sign in to comment.