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 #746 - Generate all the Host template when click on Build to avoid... #1753

Closed
wants to merge 1 commit into from

Conversation

shlomizadok
Copy link
Member

Generate all the Host template when click on Build to avoid errors during installation.
Includes moving of template_used to Managed model so it can be used elsewhere.

@@ -786,6 +787,46 @@ def validate_media?
managed && pxe_build? && build?
end

def template_used(provisioning = nil)
kinds = if provisioning == 'image'
Copy link
Member

Choose a reason for hiding this comment

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

Please refactor into a separate method available_template_kinds or something like that.

@dLobatog
Copy link
Member

@shlomizadok There is some test that needs to be fixed and also the stuff I commented about.
Thanks for taking care of this one, we've been lacking this for 3 years no less. 😑

@shlomizadok
Copy link
Member Author

@elobato Thanks for the review. I will fix your comments and fix the tests. I am also extending the 'review before build' to: a) return a better explanation of what failed (as you have also commented) and b) to test if the smart proxy is available before building.

@@ -350,3 +350,7 @@ table.table thead .sorting_desc_disabled { background: #f9f9f9 url('sort_desc_di
.config_group, .selected_config_group {
min-height: 30px;
}

#fakepasswordremembered {
display: none;
Copy link
Member

Choose a reason for hiding this comment

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

please extracte to a different PR

@@ -93,4 +93,4 @@ def unattended_render_to_temp_file content, prefix = id.to_s, options = {}
end

end
end
end
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: No newline :-D

@lzap
Copy link
Member

lzap commented Sep 15, 2014

Nice, I like that a lot. Do folks think it is good time to add the rendered templates to audit now? Or would it make sense to add all template rendering to audit in more generic way?

@@ -187,10 +188,26 @@ def puppetrun
redirect_to host_path(@host)
end

def review_before_build
@build = HostBuildStatus.new(@host).host_build_status
Copy link
Member

Choose a reason for hiding this comment

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

you can avoid returning self if you change this line to

(@build = HostBuildStatus.new(@host)).host_build_status

another simple way, is to add a method on the host object similar to

def build_status
  build_status = HostBuildStatus.new(self)
  build_status.host_build_status # I would rename to method but thats another story
  build_status
end

build_status.check_all_statuses
build_status
end

Copy link
Member

Choose a reason for hiding this comment

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

why in host common? I don't think it is used in hostgroup?

@mmoll
Copy link
Contributor

mmoll commented Oct 22, 2014

tested (without a Compute Resource), works for me.
One thing I noted, when a proxy is not reachable, the mesage in the UI is:

Proxies
  Error connecting to smart.pro.xy: undefined method `to_sentence' for true:TrueClass.

@shlomizadok
Copy link
Member Author

@mmoll - Thanks for testing. I have fixed the error message (though error handling on smart_proxy api should be re-factored too [but that is for another pr])

def supports_power_and_running(host)
return false unless host.compute_resource_id || host.bmc_available?
host.power.ready?
rescue ProxyAPI::ProxyException
Copy link
Member

Choose a reason for hiding this comment

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

add an explanation ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Don't think so. Should return true or false. The rescue is in cases the Proxy is unavailable.

$('#review_before_build').on('click', "#recheck_review", function () {
$("#build-review").click();
});
});
Copy link
Member

Choose a reason for hiding this comment

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

a tidy bit more optimized jquery could be:

 $(function () {
-  $("#build-review").click(function() {
-    $("#review_before_build .modal-body #build_status").html('');
+  var dialog = $("#review_before_build");
+  $("#build-review").click(function () {
+    dialog.find(".modal-body #build_status").html('');
     $('.loading').addClass('visible');
     $.ajax({
-      type:'get',
+      type: 'get',
       url: $(this).attr('data-url'),
-      success: function(result){
-       $("#review_before_build .modal-body #build_status").html(result);
+      success: function (result) {
+        $("#review_before_build").find(".modal-body #build_status").html(result);
       },
-      complete: function(){
+      complete: function () {
         $('.loading').removeClass('visible');
       }
-    })
+    });
   });
-  $('#review_before_build').on('change', "#host_build", function () {
+  dialog.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 () {
+  dialog.on('click', "#recheck_review", function () {
     $("#build-review").click();
   });
 });

@shlomizadok
Copy link
Member Author

@ohadlevy tidied the js, rebased and tests are 💚

…uild to avoid errors during installation
@ohadlevy
Copy link
Member

merged as 6e916e5 thanks @shlomizadok!

@ohadlevy ohadlevy closed this Oct 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants