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

Add fallback hostname form input fields for Nuage Network Provider #2531

Merged
merged 1 commit into from Oct 30, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -285,6 +285,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 @@ -316,7 +321,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 @@ -445,6 +452,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 @@ -459,6 +468,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 @@ -553,6 +564,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 @@ -582,6 +595,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 @@ -603,7 +618,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
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')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be 'Fallback AMQP Hostname 1'? (Same for 'Fallback Hostname 2' below).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @blomquisg. As discussed in gitter, the reason for Fallback Hostname 1 was because this is already on the AMQP tab and the main input field is entitled Hostname.

The reason for adding the hostname, ipv4 or ipv6 as a placeholder text is that with this long name, the field label is broken into two rows which looks ugly.

.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
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