-
Notifications
You must be signed in to change notification settings - Fork 983
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #746 - Generate all the Host template when click on Build to av…
…oid errors during installation.
- Loading branch information
1 parent
54141ab
commit b0a441a
Showing
18 changed files
with
366 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
$(function () { | ||
$("#build-review").click(function() { | ||
$("#review_before_build .modal-body #build_status").html(''); | ||
$('.loading').addClass('visible'); | ||
$.ajax({ | ||
type:'get', | ||
url: $(this).attr('data-url'), | ||
success: function(result){ | ||
$("#review_before_build .modal-body #build_status").html(result); | ||
}, | ||
complete: function(){ | ||
$('.loading').removeClass('visible'); | ||
} | ||
}) | ||
}); | ||
$('#review_before_build').on('change', "#host_build", function () { | ||
$('#build_form').find('input.submit').val((this.checked) ? (__("Reboot and build")) : (__("Build"))); | ||
}); | ||
|
||
$('#review_before_build').on('click', "#recheck_review", function () { | ||
$("#build-review").click(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#review_before_build { | ||
#build_form { | ||
padding: 0px; | ||
border: none; | ||
.modal-footer { | ||
border-top: none; | ||
padding: 0px; | ||
} | ||
} | ||
.list-group { | ||
float: left; | ||
clear: both; | ||
width: 100%; | ||
.list-group-item { | ||
background: transparent; | ||
border: none; | ||
font-size: 90%; | ||
width: 90%; | ||
} | ||
} | ||
|
||
.build_state { | ||
max-height: 400px; | ||
overflow: auto; | ||
} | ||
|
||
.loading { | ||
display: none; | ||
width: 100%; | ||
text-align: center; | ||
&.visible { | ||
display: block; | ||
img { | ||
width: 22px; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ def poweroff | |
end | ||
|
||
def reset | ||
poweroff && start | ||
poweroff && start | ||
end | ||
|
||
def vm_description | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
class HostBuildStatus | ||
attr_reader :host, :state, :errors | ||
delegate :available_template_kinds, :smart_proxies, :to => :host | ||
VALIDATION_TYPES = [:host, :templates, :proxies] | ||
|
||
def initialize(host) | ||
@host = host | ||
@errors = {} | ||
@state = true # default to true state | ||
VALIDATION_TYPES.each {|type| @errors[type] = []} | ||
end | ||
|
||
def host_build_status | ||
host_status | ||
templates_status | ||
smart_proxies_status | ||
self | ||
end | ||
|
||
private | ||
|
||
def host_status | ||
self if host.valid? | ||
host.errors.full_messages.each do |error| | ||
fail!(:host, error.to_s, host.to_label) | ||
end | ||
rescue => error | ||
fail!(:host, _('Failed to validate %s: %s') % [host, error.to_s], host.to_label) | ||
end | ||
|
||
def templates_status | ||
fail!(:templates, _('No templates found for this host.')) if available_template_kinds.empty? | ||
|
||
available_template_kinds.each do |template| | ||
begin | ||
valid_template = host.render_template(template.template) | ||
fail!(:templates, _('Template %s is empty.') % template.name, template.name) if valid_template.blank? | ||
rescue => exception | ||
fail!(:templates, (_('Failure parsing %s: %s.') % [template.name, exception]), template.name) | ||
end | ||
end | ||
end | ||
|
||
def smart_proxies_status | ||
fail!(:proxies, _('No smart proxies found.')) if smart_proxies.empty? | ||
|
||
smart_proxies.each do |proxy| | ||
begin | ||
errors = proxy.refresh.messages.any? | ||
fail!(:proxies, _('Failure deploying via smart proxy %s: %s.') % [proxy, errors.to_sentence], proxy.id) if errors | ||
rescue => error | ||
fail!(:proxies, _('Error connecting to %s: %s.') % [proxy, error], proxy.id) | ||
end | ||
end | ||
end | ||
|
||
def fail!(type, message, id = nil) | ||
@state = false | ||
@errors[type] << {:message => message, :edit_id => id} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<%= build_error_link(type, error[:edit_id]) if error[:edit_id] %> | ||
<li class="list-group-item"> | ||
<%= icon_text('minus') %><%= error[:message] %> | ||
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<% unless @build.state %> | ||
<div class="alert alert-<%= build_state(@build) %> build_state"> | ||
<h4> | ||
<%= icon_text('remove', _('The following errors may prevent a successful build:')) %> | ||
<%= button_tag(icon_text('refresh'), :title => _('Check again'), :class => 'btn btn-default btn-sm pull-right', | ||
:id => 'recheck_review', :data => { :url => review_before_build_host_path(:id => @host) }) %> | ||
</h4> | ||
|
||
<%= link_to_if_authorized(_("Edit"), hash_for_edit_host_path(:id => @host.id).merge(:auth_object => @host.id), | ||
:class => "btn btn-default btn-xs pull-right", :title => _('Edit Host')) unless @build.errors[:host].blank? %> | ||
<% HostBuildStatus::VALIDATION_TYPES.each do |type| %> | ||
<% if @build.errors[type].any? %> | ||
<p><b><%= _(type.to_s.capitalize) %></b></p> | ||
<ul class="list-group"> | ||
<% @build.errors[type].each do |error| %> | ||
<%= render :partial => 'hosts/build_review_status', :locals => { :error => error, :type => type } %> | ||
<% end %> | ||
</ul> | ||
<% end %> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
<%= form_for :host, | ||
:method => :put, | ||
:url => hash_for_setBuild_host_path(:id => @host).merge(:auth_object => @host, :permission => 'build_hosts'), | ||
:html => { :id => 'build_form' } do |form| | ||
%> | ||
<%= checkbox_f(form, :build, :help_text => _('Reboot now') % @host) if supports_power(@host) %> | ||
<div class="modal-footer"> | ||
<%= modal_close %> | ||
<%= review_build_button(form, build_state(@build)) %> | ||
</div> | ||
<% end %> | ||
|
||
|
Oops, something went wrong.