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

[Ovirt-devel] [PATCH 4/6] hardware_pool: search by path



Signed-off-by: David Lutterkort <dlutter redhat com>
---
 wui/src/app/models/hardware_pool.rb |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/wui/src/app/models/hardware_pool.rb b/wui/src/app/models/hardware_pool.rb
index 276779f..249d744 100644
--- a/wui/src/app/models/hardware_pool.rb
+++ b/wui/src/app/models/hardware_pool.rb
@@ -97,4 +97,16 @@ class HardwarePool < Pool
     return {:total => total, :labels => labels}
   end
 
+  def self.find_by_path(path)
+      segs = path.split("/")
+      unless segs.shift.empty?
+          raise "Path must be absolute, but is #{path}"
+      end
+      if segs.shift == "default"
+          segs.inject(get_default_pool) do |pool, seg|
+              pool.sub_hardware_pools.find { |p| p.name == seg } if pool
+          end
+      end
+  end
+
 end
-- 
1.5.5.1


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