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

[Ovirt-devel] [Patch] add Host task type -- will be needed for Migration



First round of migration-related code: Added HostTask as another Task type for taskomatic to deal with. This will be used for the "clear host" migration functionality when we implement the migration UI.

Scott
diff --git a/wui/src/app/controllers/task_controller.rb b/wui/src/app/controllers/task_controller.rb
index 09b6d32..e3b1b8b 100644
--- a/wui/src/app/controllers/task_controller.rb
+++ b/wui/src/app/controllers/task_controller.rb
@@ -28,6 +28,8 @@ class TaskController < ApplicationController
       set_perms(@task.vm.vm_library)
     elsif @task[:type] == StorageTask.name 
       set_perms(@task.storage_pool.hardware_pool)
+    elsif @task[:type] == HostTask.name 
+      set_perms(@task.host.hardware_pool)
     end
     unless @can_monitor
       flash[:notice] = 'You do not have permission to view this task: redirecting to top level'
diff --git a/wui/src/app/models/host_task.rb b/wui/src/app/models/host_task.rb
new file mode 100644
index 0000000..5cce5b9
--- /dev/null
+++ b/wui/src/app/models/host_task.rb
@@ -0,0 +1,24 @@
+# 
+# Copyright (C) 2008 Red Hat, Inc.
+# Written by Scott Seago <sseago redhat com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA  02110-1301, USA.  A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+class HostTask < Task
+  belongs_to :host
+
+  ACTION_CLEAR_VMS = "clear_vms"
+end
diff --git a/wui/src/app/views/task/_list_table.rhtml b/wui/src/app/views/task/_list_table.rhtml
index ee740b8..a3f7fe4 100644
--- a/wui/src/app/views/task/_list_table.rhtml
+++ b/wui/src/app/views/task/_list_table.rhtml
@@ -13,6 +13,7 @@
     <td style="text-align:left">
       <%= link_to task.vm.description, { :controller => "vm", :action => 'show', :id => task.vm.id }, { :class => "show" } if task[:type] == VmTask.name %>
       <%= link_to task.storage_pool.display_name, { :controller => "storage", :action => 'show', :id => task.storage_pool.id }, { :class => "show" } if task[:type] == StorageTask.name %>
+      <%= link_to task.host.hostname, { :controller => "host", :action => 'show', :id => task.host.id }, { :class => "show" } if task[:type] == HostTask.name %>
       <div class="secondary"><%= task.vm.uuid if task[:type] == VmTask.name %></div>
     </td>
     <td><%= task.state %></td>
diff --git a/wui/src/app/views/task/show.rhtml b/wui/src/app/views/task/show.rhtml
index 1dcfb79..c1cf04e 100644
--- a/wui/src/app/views/task/show.rhtml
+++ b/wui/src/app/views/task/show.rhtml
@@ -31,6 +31,7 @@
         <div class="actions">
           <%= link_to "Back to #{ task vm description}", { :controller => 'vm', :action => 'show', :id => @task.vm.id }, { :class => "show"  } if @task[:type] == VmTask.name  %>
           <%= link_to "Back to #{ task storage_pool display_name}", { :controller => 'storage', :action => 'show', :id => @task.storage_pool.id }, { :class => "show"  } if @task[:type] == StorageTask.name %>
+          <%= link_to "Back to #{ task host hostname}", { :controller => 'host', :action => 'show', :id => @task.host.id }, { :class => "show"  } if @task[:type] == HostTask.name %>
         </div>
       </div>
   </td>
diff --git a/wui/src/db/migrate/008_create_tasks.rb b/wui/src/db/migrate/008_create_tasks.rb
index f4b78c3..d8c0ad0 100644
--- a/wui/src/db/migrate/008_create_tasks.rb
+++ b/wui/src/db/migrate/008_create_tasks.rb
@@ -33,11 +33,15 @@ class CreateTasks < ActiveRecord::Migration
       t.column :vm_id,             :integer
       # StorageTask columns
       t.column :storage_pool_id,   :integer
+      # HostTask columns
+      t.column :host_id,           :integer
     end
     execute "alter table tasks add constraint fk_tasks_vms
              foreign key (vm_id) references vms(id)"
     execute "alter table tasks add constraint fk_tasks_pools
              foreign key (storage_pool_id) references storage_pools(id)"
+    execute "alter table tasks add constraint fk_tasks_hosts
+             foreign key (host_id) references hosts(id)"
   end
 
   def self.down

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