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

Fixes #23699 - Remediation Support for Host Status #6690

Closed
Closed
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
46 changes: 29 additions & 17 deletions app/assets/javascripts/host_edit_interfaces.js
Expand Up @@ -52,6 +52,9 @@ function save_interface_modal() {
if (modal_form.find('.interface_provision').is(':checked')) {
$('#interfaceForms .interface_provision:checked').attr("checked", false);
}
if (modal_form.find('.interface_managed').is(':checked')) {
$('#interfaceForms .interface_managed:checked').attr("checked", false);
}

var interface_hidden = get_interface_hidden(interface_id);
interface_hidden.html('');
Expand Down Expand Up @@ -163,20 +166,24 @@ function update_interface_row(row, interface_form) {
row.find('.ip').text(interface_form.find('.interface_ip').val());
row.find('.ip6').text(interface_form.find('.interface_ip6').val());

var flags = '', primary_class = '', provision_class = '';
var flags = '', primary_class = '', provision_class = '', managed_class = '';
if (interface_form.find('.interface_primary').is(':checked'))
primary_class = 'active'

if (interface_form.find('.interface_provision').is(':checked'))
provision_class = 'active'

if (interface_form.find('.interface_managed').is(':checked'))
managed_class = 'active'

if (primary_class == '' && provision_class == '')
row.find('.removeInterface').removeAttr('disabled');
else
row.find('.removeInterface').attr('disabled', 'disabled');

flags += '<i class="glyphicon glyphicon glyphicon-tag primary-flag '+ primary_class +'" title="" data-original-title="'+ __('Primary') +'"></i>';
flags += '<i class="glyphicon glyphicon glyphicon-hdd provision-flag '+ provision_class +'" title="" data-original-title="'+ __('Provisioning') +'"></i>';
flags += '<i class="glyphicon glyphicon glyphicon-home managed-flag '+ managed_class +'" title="" data-original-title="'+ __('Managed') +'"></i>';

row.find('.flags').html(flags);

Expand All @@ -187,6 +194,7 @@ function update_interface_row(row, interface_form) {

$('.primary-flag').tooltip();
$('.provision-flag').tooltip();
$('.managed-flag').tooltip();
}

function update_interface_table() {
Expand Down Expand Up @@ -256,24 +264,28 @@ $(document).on('change', '#host_name', function () {
update_fqdn();
});

$(document).on('click', '.primary-flag', function () {
$(document).on('click', '.provision-flag, .managed-flag, .primary-flag', function () {
var interface_class_substring;
var interface_id = $(this).closest('tr').data('interface-id');

$('#interfaceForms .interface_primary:checked').prop('checked', false);
get_interface_hidden(interface_id).find('.interface_primary').prop('checked', true);

sync_primary_name(true);
update_interface_table();
update_fqdn();
});

$(document).on('click', '.provision-flag', function () {
var interface_id = $(this).closest('tr').data('interface-id');

$('#interfaceForms .interface_provision:checked').prop('checked', false);
get_interface_hidden(interface_id).find('.interface_provision').prop('checked', true);

update_interface_table();
// checking which icon clicked
if ($(this).hasClass('provision-flag')) {
interface_class_substring = '.interface_provision';
} else if ($(this).hasClass('managed-flag')) {
interface_class_substring = '.interface_managed';
} else if ($(this).hasClass('primary-flag')) {
interface_class_substring = '.interface_primary';
}
$('#interfaceForms ' + interface_class_substring + ':checked').prop('checked', false);
get_interface_hidden(interface_id).find(interface_class_substring).prop('checked', true);

if ($(this).hasClass('primary-flag')) {
sync_primary_name(true);
update_interface_table();
update_fqdn();
} else if ($(this).hasClass('managed-flag') || $(this).hasClass('provision-flag')){
update_interface_table();
}
});

var providerSpecificNICInfo = null;
Expand Down
1 change: 1 addition & 0 deletions app/assets/stylesheets/base.scss
Expand Up @@ -395,6 +395,7 @@ table {
}

.primary-flag,
.managed-flag,
.provision-flag {
color: #bbb;
cursor: pointer;
Expand Down
4 changes: 3 additions & 1 deletion app/helpers/hosts_helper.rb
Expand Up @@ -293,8 +293,10 @@ def host_detailed_status_list(host)
next unless status.relevant? && !status.substatus?
[
_(status.name),
content_tag(:span, ' '.html_safe, :class => host_global_status_icon_class(status.to_global)) +
content_tag(:span, (
content_tag(:span, ' '.html_safe, :class => host_global_status_icon_class(status.to_global)) +
content_tag(:span, _(status.to_label), :class => host_global_status_class(status.to_global))
), { :'data-original-title' => _(status.remediation_help_text), :rel => 'twipsy' })
]
end.compact
end
Expand Down
15 changes: 15 additions & 0 deletions app/models/host_status/build_status.rb
Expand Up @@ -64,6 +64,21 @@ def token_expired?
def build_errors?
host && host.build_errors.present?
end

def remediation_help_text
case to_status
Copy link
Member

Choose a reason for hiding this comment

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

This should use status. to_status can call expensive (external services). status just used the cached version in the database.

when PENDING
N_("Installation haven't started yet or in progress")
when TOKEN_EXPIRED
N_("Build token is no longer valid, cancel build mode and enter it again to generate new token")
when BUILT
N_("OS installer reported end of installation and rebooted the system")
when BUILD_FAILED
N_("OS installer post script reported failure, check logs")
else
N_("The host was not scheduled for build yet")
end
end
end
end

Expand Down
4 changes: 4 additions & 0 deletions app/models/host_status/status.rb
Expand Up @@ -72,6 +72,10 @@ def update_timestamp
def update_status
self.status = to_status
end

def remediation_help_text
nil
end
end
end

Expand Down
1 change: 1 addition & 0 deletions app/views/nic/_base_form.html.erb
Expand Up @@ -65,6 +65,7 @@
<% if SETTINGS[:unattended] %>
<%= checkbox_f f, :managed,
:label_help => _("If the Managed flag is enabled, external services such as DHCP, DNS, and TFTP will be configured according to the information provided.") + '<br/>' + _("The services to be configured are determined by the subnet and domain that are selected for this interface. If you want to manage<br/> only a subset of these services, change the %{subnet} and %{domain} proxies configuration. When a proxy is set to 'None', the corresponding") + '<br/>' + _("service configuration will be skipped.") + '<br/><br/>' + _("If the Managed flag is disabled, none of the services will be configured for this interface, even if it is configured for the subnet and domain.") + '<br/><br/>' + _("The Managed flag also determines whether the interface should be configured during host provisioning, so that the configuration remains after reboot.") % { :subnet => link_to(_('subnet'), subnets_path, :target => :blank), :domain => link_to(_('domain'), domains_path, :target => :blank)},
:class => :interface_managed,
:label_help_options => { :rel => 'popover-modal' },
:size => "col-md-8", :label_size => "col-md-3" %>
<% end %>
Expand Down