Commits

Kaspar Schiess committed 2c3d7af

Handles the case where the lu exists

  • Participants
  • Parent commits 4752deb

Comments (0)

Files changed (1)

         end
       end
     end
-    def lu_for_path path
+    def create_lu path
       runner = Runner.new
 
       output = begin
       
       md[:luid]
     end
+    def lookup_lu(path)
+      runner = Runner.new
+      parser = ISCSI::HashParser.new
+      
+      output = runner.shell %Q(stmfadm list-lu -v)
+      lus = parser.parse(output)
+      p lus
+      
+      lus.each do |lu_attrs| 
+        if lu_attrs[:data_file] == path
+          return lu_attrs[:lu_name]
+        end
+      end
+      
+      return nil
+    end
+    def lu_for_path path
+      lookup_lu(path) || create_lu(path)
+    end
     def add_tg_member group, iqn
       runner = Runner.new
 
       
       device_list.each do |path| 
         luid = lu_for_path(path)
+        fail
         runner.shell %Q(stmfadm add-view -t #{group} #{luid})
       end