[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Ovirt-devel] [PATCH] added ability to reprovision vm via edit vm form



---
 wui/src/app/controllers/vm_controller.rb |   29 +++++++++++++++++------------
 wui/src/app/views/vm/_form.rhtml         |    2 +-
 2 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/wui/src/app/controllers/vm_controller.rb b/wui/src/app/controllers/vm_controller.rb
index e55ec28..6d32427 100644
--- a/wui/src/app/controllers/vm_controller.rb
+++ b/wui/src/app/controllers/vm_controller.rb
@@ -193,6 +193,21 @@ class VmController < ApplicationController
   end
 
   protected
+  def _setup_provisioning
+    @provisioning_options = [[Vm::PXE_OPTION_LABEL, Vm::PXE_OPTION_VALUE],
+                             [Vm::HD_OPTION_LABEL, Vm::HD_OPTION_VALUE]]
+    # FIXME add cobbler images too
+    begin
+      @provisioning_options += Cobbler::Profile.find.collect do |profile|
+        [profile.name + Vm::COBBLER_PROFILE_SUFFIX,
+         Vm::COBBLER_PREFIX + Vm::PROVISIONING_DELIMITER +
+         Vm::PROFILE_PREFIX + Vm::PROVISIONING_DELIMITER + profile.name]
+      end
+    rescue
+      #if cobbler doesn't respond/is misconfigured/etc just don't add profiles
+    end
+  end
+
   def pre_new
     # if no vm_resource_pool is passed in, find (or auto-create) it based on hardware_pool_id
     unless params[:vm_resource_pool_id]
@@ -229,18 +244,7 @@ class VmController < ApplicationController
     @perm_obj = @vm.vm_resource_pool
     @redir_controller = 'resources'
     @current_pool_id= perm_obj id
-    @provisioning_options = [[Vm::PXE_OPTION_LABEL, Vm::PXE_OPTION_VALUE],
-                             [Vm::HD_OPTION_LABEL, Vm::HD_OPTION_VALUE]]
-    # FIXME add cobbler images too
-    begin
-      @provisioning_options += Cobbler::Profile.find.collect do |profile|
-        [profile.name + Vm::COBBLER_PROFILE_SUFFIX,
-         Vm::COBBLER_PREFIX + Vm::PROVISIONING_DELIMITER +
-         Vm::PROFILE_PREFIX + Vm::PROVISIONING_DELIMITER + profile.name]
-      end
-    rescue
-      #if cobbler doesn't respond/is misconfigured/etc just don't add profiles
-    end
+    _setup_provisioning
   end
   def pre_create
     params[:vm][:state] = Vm::STATE_PENDING
@@ -267,6 +271,7 @@ class VmController < ApplicationController
     @perm_obj = @vm.vm_resource_pool
     @redir_obj = @vm
     @current_pool_id= perm_obj id
+    _setup_provisioning
   end
   def pre_vm_action
     pre_edit
diff --git a/wui/src/app/views/vm/_form.rhtml b/wui/src/app/views/vm/_form.rhtml
index 60ed003..0dfe940 100644
--- a/wui/src/app/views/vm/_form.rhtml
+++ b/wui/src/app/views/vm/_form.rhtml
@@ -8,7 +8,7 @@
 <%= hidden_field_tag 'hardware_pool_id', @hardware_pool.id if @hardware_pool %>
 
     <%= text_field_with_label "Name:", "vm", "description", {:style=>"width:250px;"}  %>
-    <%= select_with_label "Operating System:", 'vm', 'provisioning_and_boot_settings', @provisioning_options, :style=>"width:250px;"  if create %>
+    <%= select_with_label "Operating System:", 'vm', 'provisioning_and_boot_settings', @provisioning_options, :style=>"width:250px;" %>
     <div class="clear_row" style="height:15px;"></div>
 
     <div class="form_heading">Resources</div>
-- 
1.5.4.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]