[Ovirt-devel] [PATCH client 07/11] Command to list storage in a hardware pool

David Lutterkort lutter at redhat.com
Mon Jan 26 21:20:37 UTC 2009


---
 lib/ovirt/command/storage.rb |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)
 create mode 100644 lib/ovirt/command/storage.rb

diff --git a/lib/ovirt/command/storage.rb b/lib/ovirt/command/storage.rb
new file mode 100644
index 0000000..85577e9
--- /dev/null
+++ b/lib/ovirt/command/storage.rb
@@ -0,0 +1,31 @@
+module OVirt::Command::Storage
+
+  module List
+    def execute(args)
+      begin
+        pools = OVirt::StoragePool.find_by_path(args["pool"])
+      rescue ActiveResource::ResourceNotFound => e
+        puts_error "pool #{args["pool"]} not found"
+        return
+      end
+      puts "Pool #{args["pool"]}: #{pools.size} storage pool(s)"
+      puts "=" * 75
+      pools.each do |sp|
+        type = sp.nfs? ? "NFS" : "iSCSI"
+        printf "%3d %-5s %-30s %s\n", sp.id, type, sp.label, sp.state
+        if args["verbose"]
+          sp = OVirt::StoragePool.find(sp.id)
+          sp.storage_volumes.sort_by { |vol| vol.filename }.each do |vol|
+            if sp.nfs?
+              printf "    %3d %-30s %s\n", vol.id, vol.filename, vol.human_readable_size
+            else
+              printf "FIXME\n"
+            end
+          end
+        end
+      end
+      puts "-" * 75
+    end
+  end
+
+end
-- 
1.6.0.6




More information about the ovirt-devel mailing list