-
Notifications
You must be signed in to change notification settings - Fork 990
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
db1a98d
commit bfa1967
Showing
21 changed files
with
388 additions
and
55 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 check_all_statuses | ||
host_status | ||
templates_status | ||
smart_proxies_status | ||
end | ||
|
||
private | ||
|
||
def host_status | ||
return 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? | ||
errors = errors.is_a?(Array) ? errors.to_sentence : errors | ||
fail!(:proxies, _('Failure deploying via smart proxy %s: %s.') % [proxy, errors], 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module PowerManager | ||
SUPPORTED_ACTIONS = [N_('start'), N_('stop'), N_('poweroff'), N_('reboot'), N_('reset'), N_('state'), | ||
N_('on'), N_('off'), N_('soft'), N_('cycle'), N_('status')] | ||
N_('on'), N_('off'), N_('soft'), N_('cycle'), N_('status'), N_('ready?')] | ||
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 |
---|---|---|
|
@@ -12,6 +12,10 @@ def initialize(opts = {}) | |
end # end | ||
end | ||
|
||
def ready? | ||
status == 'on' | ||
end | ||
|
||
private | ||
attr_reader :proxy | ||
|
||
|
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
Oops, something went wrong.