Skip to content

Commit

Permalink
fix(instance): fix for hard reset (#1433)
Browse files Browse the repository at this point in the history
  • Loading branch information
hgw77 authored Oct 15, 2024
1 parent 8b88cdb commit f1b1b68
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 21 deletions.
14 changes: 9 additions & 5 deletions plugins/compute/app/controllers/compute/instances_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,15 @@ def index
def console
@instance = services.compute.find_server(params[:id])
hypervisor = @instance.attributes["OS-EXT-SRV-ATTR:host"] || ""
if hypervisor.to_s.include?("nova-compute-ironic")
@console =
services.compute.remote_console(params[:id], "serial", "shellinabox")
else
@console = services.compute.remote_console(params[:id])
begin
if hypervisor.to_s.include?("nova-compute-ironic")
@console = services.compute.remote_console(params[:id], "serial", "shellinabox")
else
@console = services.compute.remote_console(params[:id])
end
rescue StandardError => e
@console_error = "Failed to get remote console: #{e.message}"
@console = nil
end
respond_to do |format|
format.html { render action: :console, layout: "compute/console" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
%li
= link_to 'Revert Resize', plugin('compute').revert_resize_instance_path(id: instance.id, action_from_show: show_view), method: :put, data: {loading_status: true}, remote: true
- if instance.power_state==Compute::Server::RUNNING
- hypervisor = instance.attributes['OS-EXT-SRV-ATTR:host'] || ''
%li.divider
%li
= link_to 'Stop', plugin('compute').stop_instance_path(id: instance.id, action_from_show: show_view), method: :put, data: { confirm: 'Are you sure you want to stop this instance?', ok: "Yes, stop it", confirmed: :loading_status}, remote: true
Expand All @@ -57,6 +58,9 @@
= link_to 'Pause', plugin('compute').pause_instance_path(id: instance.id, action_from_show: show_view), method: :put, data: { confirm: 'Are you sure you want to pause this instance?', ok: "Yes, stop it", confirmed: :loading_status }, remote: true
%li
= link_to 'Suspend', plugin('compute').suspend_instance_path(id: instance.id, action_from_show: show_view), method: :put, data: { confirm: 'Are you sure you want to suspend this instance?', ok: "Yes, stop it", confirmed: :loading_status}, remote: true
- if !hypervisor.to_s.include?('nova-compute-ironic') && current_user.is_allowed?("compute:instance_hard_reset",{target: { project: @active_project, scoped_domain_name: @scoped_domain_name}})
%li
= link_to 'Hard Reset', confirm_hard_reset_instance_path(id: instance.id), data: {modal:true}
- if current_user.is_allowed?("compute:instance_edit_securitygroups", {target: { project: @active_project, scoped_domain_name: @scoped_domain_name}})
%li.divider
%li
Expand All @@ -78,3 +82,4 @@
- if current_user.is_allowed?("compute:instance_unlock")
%li
= link_to 'Unlock', plugin('compute').unlock_instance_path(id: instance.id, action_from_show: show_view), method: :put, data: { confirm: 'Are you sure you want to unlock this instance?', ok: "Yes, unlock it", confirmed: :loading_status }, remote: true

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
?
%br
%br
Note: after the hardreset is triggered the web console will stop to work. It will reload automaticly after the countdown ends.
Note: after the hardreset is triggered the web console will stop to work if you have it opened. Please wait a short while and reload the web console 🚀.
.row
.col-md-6
%fieldset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
.modal-body.console
%iframe{src: @console.url, width: '100%', height: '650px'}
- else
%iframe{src: @console.url, width: '100%', height: '850px'}
- if @console_error
.alert.alert-error
#{@console_error}
- elsif @console.nil?
.alert.alert-warning
The console is not available 🙄
- else
%iframe{src: @console.url, width: '100%', height: '850px'}

- if modal?
.modal-footer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
= render "intro"


%form
.toolbar.toolbar-controlcenter
/ / seach form
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,5 @@ $.post("<%=plugin('compute').hard_reset_instance_path({id:@instance.id})%>");
//close the create request window
Dashboard.hideModal();

var cnt = 15;
// show countdown for reload
$('#console').html("<div class='countdown'/>");
$('.countdown').html('Hard Reset in process<br>Web Console will reload in '+cnt+'s');
var x = setInterval(function() {
cnt--;
if (cnt == 0) {
clearInterval(x);
$('.countdown').html('reloading Web Console');
window.location.replace("<%=plugin('compute').console_instance_path(id: @instance.id)%>");
} else {
$('.countdown').html('Hard Reset in process<br>Web Console will reload in '+cnt+'s');
}
}, 1000);
$('.countdown').html('Hard Reset was triggered 🚀<br>Please wait a short while and reload the web console if you had it opened');

0 comments on commit f1b1b68

Please sign in to comment.