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

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



Mohammed Morsi wrote:
---
 wui/src/app/controllers/vm_controller.rb |   73 +++++++++++++++++++++++++-----
 wui/src/app/views/vm/_form.rhtml         |    6 ++-
 2 files changed, 65 insertions(+), 14 deletions(-)

diff --git a/wui/src/app/controllers/vm_controller.rb b/wui/src/app/controllers/vm_controller.rb
index e55ec28..82d8952 100644
--- a/wui/src/app/controllers/vm_controller.rb
+++ b/wui/src/app/controllers/vm_controller.rb
@@ -193,6 +215,43 @@ class VmController < ApplicationController
   end
protected
+  def _setup_provisioning_options
+    @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, profile.name]
+
+    end
+    rescue
+      #if cobbler doesn't respond/is misconfigured/etc just don't add profiles
+    end
+  end
+
+  def _setup_vm_provision(params)
This is fine for now -- but we eventually need to move this into an edit_vm task -- so go ahead and include a FIXME comment to mention this for now.

+    # spaces are invalid in the cobbler name
+    name = params[:vm][:description].gsub(" ", "-")
+    provision = params[:vm][:provisioning_and_boot_settings]
+    unless provision == Vm::PXE_OPTION_VALUE or
+           provision == Vm::HD_OPTION_VALUE
+      found = false
+      Cobbler::System.find.each{ |system|
+        if system.name == name
+          system.profile = provision
+          system.save
+          found = true
+        end
+      }
+      unless found
+        system = Cobbler::System.create("name" => name,
+                                        "profile" => provision)
+        # do we need to set any of the other system attributes?
+        system.save
+      end
+    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]
ACK, once the FIXME comment is added.

Scott


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