Mohammed Morsi
2009-Aug-04 20:30 UTC
[Ovirt-devel] [PATCH server] require at least one vm network if pxe booting
--- src/app/models/vm.rb | 2 ++ src/app/views/vm/_form.rhtml | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 0 deletions(-) diff --git a/src/app/models/vm.rb b/src/app/models/vm.rb index 3e0a6fa..9d326ac 100644 --- a/src/app/models/vm.rb +++ b/src/app/models/vm.rb @@ -464,6 +464,8 @@ class Vm < ActiveRecord::Base self.storage_volumes=@storage_volumes_pending @storage_volumes_pending = [] end + errors.add("nics", "must specify at least one network if pxe booting off a network") unless boot_device == BOOT_DEV_NETWORK && nics.size > 0 + end end diff --git a/src/app/views/vm/_form.rhtml b/src/app/views/vm/_form.rhtml index 5f519fc..39ce55e 100644 --- a/src/app/views/vm/_form.rhtml +++ b/src/app/views/vm/_form.rhtml @@ -51,6 +51,9 @@ <div class="vm_form_section" style="display:none;"> <div class="clear_row"></div> + <%# display network errors at the top of the section %> + <div class="field_title"><label for="vm_nics" /></div> + <% if @nics.size > 0 %> <div id="vm_network_config_header"> <div id="vm_network_config_header_network">Network:</div> @@ -313,5 +316,25 @@ ${htmlList(pools, id)} $('#vm_network_config_select_<%= i %>').val("<%= @vm.nics[i].network_id %>").trigger('change'); <% } end %> + + // wire up provision select box to autoselect a network if necessary + $('#vm_provisioning_and_boot_settings').bind('change', function(e){ + + // if at least one network is already selected do nothing + for(i = 0; i < nics.length; ++i){ + if(nics[i].selected){ + return; + } + } + + // only set value if we have a network to set it to and we've + // selected a provision type requiring a net + if(nics.length > 0 && + (e.target.value == "<%= Vm::PXE_OPTION_VALUE %>" || + e.target.value.indexOf("<%= Vm::PROFILE_PREFIX %>@<%= Vm::COBBLER_PREFIX %>") == 0)){ + $('#vm_network_config_select_0').val(nics[0].network_id).trigger('change'); + } + }).trigger('change'); // make sure whatever we have at first is handled + }); </script> -- 1.6.0.6
Jason Guiditta
2009-Aug-04 22:54 UTC
[Ovirt-devel] Re: [PATCH server] require at least one vm network if pxe booting
On Tue, 2009-08-04 at 16:30 -0400, Mohammed Morsi wrote:> --- > src/app/models/vm.rb | 2 ++ > src/app/views/vm/_form.rhtml | 23 +++++++++++++++++++++++ > 2 files changed, 25 insertions(+), 0 deletions(-)Almost ACK. Tried to hit you in irc, but must have missed you. Ping me later when you are back, I'll check in from time to time. So, I do get the proper error back in the json response, and selecting pxe from the os menu does set default to use a network in Networks section. The only thing off is I do not get the error back in the form itself, so something is off with that mapping there. If we can figure that out, I can fully ACK. -j
The following patch: [PATCH server] fix error display for no nics on pxe. displays the error returned from previous patch if no networks are selected and you are trying to pxe the vm.
Jason Guiditta
2009-Aug-05 00:54 UTC
[Ovirt-devel] [PATCH server] fix error display for no nics on pxe.
Signed-off-by: Jason Guiditta <jason.guiditta at gmail.com> --- src/app/views/vm/_form.rhtml | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/app/views/vm/_form.rhtml b/src/app/views/vm/_form.rhtml index 39ce55e..adb75d2 100644 --- a/src/app/views/vm/_form.rhtml +++ b/src/app/views/vm/_form.rhtml @@ -52,7 +52,7 @@ <div class="clear_row"></div> <%# display network errors at the top of the section %> - <div class="field_title"><label for="vm_nics" /></div> + <%= text_field_with_label "", "vm", "nics", {:style=>"display:none;"} %> <% if @nics.size > 0 %> <div id="vm_network_config_header"> -- 1.6.2.5
Possibly Parallel Threads
- [PATCH server] fixes to the multiple vm/nets component
- [PATCH server] add toggable sections to vm form
- [PATCH server] permit many-to-many vms / networks relationship
- [PATCH 1/1] Introduce an option to always pxe-boot a vm.
- [PATCH server] add collapsable sections to vm form