Commits

Kaspar Schiess committed 8e639b2

Rehauls list command

  • Participants
  • Parent commits 956633d

Comments (0)

Files changed (2)

 #!/usr/bin/env ruby
 
+require 'pp'
 require 'clamp'
 require 'mixlib/shellout'
 
     def execute
       shares = ISCSI::Shares.new
       shares.list do |target|
-        puts target
+        pp target
       end
     end
   end

lib/iscsi/iscsi.rb

     def runner
       @runner ||= Runner.new
     end
+
     def list
-      iqns do |iqn|
-        yield Target.new(iqn)
+      stmf_targets.each do |node| 
+        yield Target.new(node)
       end
     end
-    def iqns
-      runner.shell('stmfadm list-target').lines do |line|
-        if md=line.match(/^Target: (.*)$/)
-          yield md[1]
-        end
-      end
+    def stmf_targets
+      parser = HashParser.new
+      parser.parse runner.shell('stmfadm list-target -v')
     end
   end
   
   class Target
-    def initialize(iqn)
-      @iqn = iqn
+    def initialize(node)
+      @node = node
     end
   end
 end