[Title] add friend server query
authorjiil.hyoun <jiil.hyoun@samsung.com>
Tue, 4 Sep 2012 13:11:36 +0000 (22:11 +0900)
committerjiil.hyoun <jiil.hyoun@samsung.com>
Tue, 4 Sep 2012 13:11:36 +0000 (22:11 +0900)
[Type] Enhancement
[Module] Toolchain /
[Priority] Minor
[Jira#]
[Redmine#]  6794
[Problem]
[Cause]
[Solution]
[TestCase]

Change-Id: I45213ca9092fa1878d83113ab00f9a84fca55b34

build-cli
package/pkginfo.manifest
src/build_server/SocketJobRequestListener.rb

index 5b439fcd45e878fbf1062683d0eaf0f232c546db..129e73b1debd56e42993b7a10d4165d5516496b8 100755 (executable)
--- a/build-cli
+++ b/build-cli
@@ -53,109 +53,80 @@ if not Utils.check_host_OS() then
        exit 1
 end
 
-def query_system_info(ip, port)
-       # HOST SYSTEM INFO
-    puts "* SYSTEM INFO *"
+def query( ip, port, sym )
        client = BuildCommClient.create( ip, port, nil, 0 )
-       if not client.nil? then
-               client.send "QUERY|SYSTEM" 
-               result0 = client.receive_data()
-               if result0.nil? then
-                       client.terminate
-                       exit 1
-               end
-               result0 = result0[0].split(",").map { |x| x.strip }
-               puts "HOST-OS: #{result0[0]}"
-               puts "MAX_WORKING_JOBS: #{result0[1]}"
-               client.terminate
-       else
+       if client.nil? then
                puts "Connection to server failed!"
-               exit 1
+               return nil
        end
+       client.send "QUERY|#{sym.strip}"
+       result = client.receive_data()
+       client.terminate
+       return result
+end
+
+def query_system_info(ip, port)
+       # HOST SYSTEM INFO
+    puts "* SYSTEM INFO *"
+       data = query( ip, port, "SYSTEM")
+       if data.nil? then exit 1 end
+
+       result = data[0].split(",").map { |x| x.strip }
+       puts "HOST-OS: #{result[0]}"
+       puts "MAX_WORKING_JOBS: #{result[1]}"
 
        # FTP INFO
-       puts ""
-    puts "* FTP *"
-       client = BuildCommClient.create( ip, port )
-       if not client.nil? then
-               client.send "QUERY|FTP"
-               result0 = client.receive_data()
-               if result0.nil? then
-                       client.terminate
-                       exit 1
-               end
-               result0 = result0[0].split(",").map { |x| x.strip }
-               puts "FTP_ADDR: #{result0[0]}"
-               puts "FTP_USERNAME: #{result0[1]}"
-               client.terminate
-       else
-               puts "Connection to server failed!"
-               exit 1
-       end
+    puts "\n* FTP *"
+       data = query(ip, port, "FTP")
+       if data.nil? then exit 1 end
+
+       result = data[0].split(",").map { |x| x.strip }
+       puts "FTP_ADDR: #{result[0]}"
+       puts "FTP_USERNAME: #{result[1]}"
 
        # SUPPORTED OS INFO
-       puts ""
-    puts "* SUPPORTED OS LIST *"
-       client = BuildCommClient.create( ip, port )
-       if not client.nil? then
-               client.send "QUERY|OS"
-               result0 = client.receive_data()
-               if not result0.nil? then
-                       result0.each do |item|
-                               puts "#{item.strip}"    
-                       end
-               end
-               client.terminate
-       else
-               puts "Connection to server failed!"
-               exit 1
+    puts "\n* SUPPORTED OS LIST *"
+       data = query(ip, port, "OS")
+       if data.nil? then exit 1 end
+
+       data.each do |item|
+               puts "#{item.strip}"
+       end
+
+       # Friend lists
+    puts "\n* FRIEND SERVER LIST (WAIT|WORK/MAX) jobs [transfer count] *"
+       data = query(ip, port, "FRIEND")
+       if data.nil? then exit 1 end
+       i = 0
+       data.each do |item|
+               i = i + 1
+               info = item.split(",").map { |x| x.strip }
+               puts "#{i}. #{info[0]} server (#{info[1]}|#{info[2]}/#{info[3]}) [#{info[4]}]"
        end
 end
 
 
 def query_project_list(ip, port)
        puts "* PROJECT(S) *"
-       client = BuildCommClient.create( ip, port, nil, 0 )
-       if not client.nil? then
-               client.send "QUERY|PROJECT"
-               result1 = client.receive_data()
-               if result1.nil? then
-                       client.terminate
-                       exit 1
-               end
-               result1.each do |item|
-                       tok = item.split(",").map { |x| x.strip }
-                       type = (tok[0]=="G" ? "NORMAL":"REMOTE")
-                       printf("%-25s %s\n",tok[1],type)
-               end
-       else
-               puts "Connection to server failed!"
-               exit 1
+       data = query( ip, port, "PROJECT")
+       data.each do |item|
+               tok = item.split(",").map { |x| x.strip }
+               type = (tok[0]=="G" ? "NORMAL":"REMOTE")
+               printf("%-25s %s\n",tok[1],type)
        end
 end
 
 
 def query_job_list(ip, port)
        puts "* JOB(S) *"
-       client = BuildCommClient.create( ip, port, nil, 0 )
-       if not client.nil? then
-               client.send "QUERY|JOB"
-               result1 = client.receive_data()
-               if result1.nil? then
-                       client.terminate
-                       exit 1
-               end
-               result1.each do |item|
-                       tok = item.split(",").map { |x| x.strip }
-                       if tok[3].nil? then
-                               puts "#{tok[1]} #{tok[0]} #{tok[2]}"    
-                       else
-                               puts "#{tok[1]} #{tok[0]} #{tok[2]} (#{tok[3]})"        
-                       end
+       data = query(ip, port, "JOB")
+       data.each do |item|
+               tok = item.split(",").map { |x| x.strip }
+               if tok[3].nil? then
+                       puts "#{tok[1]} #{tok[0]} #{tok[2]}"
+               else
+                       puts "#{tok[1]} #{tok[0]} #{tok[2]} (#{tok[3]})"
                end
-       else
-               puts "Connection to server failed!"
-               exit 1
        end
 end
 
index 87b9647db135dfa5f5588a50910eb91256c666da..baca1cda64b3435b902d6c061b23a119233ec580 100644 (file)
@@ -1,5 +1,5 @@
 Source : dibs
-Version :0.99.37
+Version :0.99.38
 Maintainer : taejun ha<taejun.ha@samsung.com>, jiil hyoun <jiil.hyoun@samsung.com>, donghyuk yang <donghyouk.yang@samsung.com>, donghee yang <donghee.yang@samsung.com>, sungmin kim <dev.sungmin.kim@samsung.com
 
 Package : dibs
index 32022b047204d791fe4a72199dd68c96263cb852..0683f403606e03708fe5223bc2499d9d9316192d 100644 (file)
@@ -453,7 +453,7 @@ class SocketJobRequestListener
                        end
                        BuildCommServer.send_end(req)
                        BuildCommServer.disconnect(req)
-       
+
                when "OS"
                        BuildCommServer.send_begin(req)
                        # print GIT projects
@@ -462,7 +462,16 @@ class SocketJobRequestListener
                        end
                        BuildCommServer.send_end(req)
                        BuildCommServer.disconnect(req)
-       
+
+               when "FRIEND"
+                       BuildCommServer.send_begin(req)
+                       # print GIT projects
+                       @parent_server.friend_servers.each do |server|
+                               BuildCommServer.send(req,"#{server.host_os},#{server.waiting_jobs.length},#{server.working_jobs.length},#{server.max_working_jobs},#{server.get_file_transfer_cnt}")
+                       end
+                       BuildCommServer.send_end(req)
+                       BuildCommServer.disconnect(req)
+
                else
                        @log.info "Received Wrong REQ: #{line}" 
                        raise "Invalid request format is used: #{line}"