example4.rb

Example 4 - Andreas Schröder, 07/12/2007 01:50 am

Download (698 Bytes)

 
1
#!/usr/bin/ruby
2

    
3

    
4
require 'libdrqueue'
5

    
6

    
7
puts "Master: #{ENV["DRQUEUE_MASTER"]}\n"
8

    
9
# First we receive the list of slaves
10
computer_list = Libdrqueue::request_computer_list(Libdrqueue::CLIENT)
11
puts "Computers connected to the master:"
12
computer_list.each do |c|
13
        # We can check if the computer is enabled looking into computer.limits.enabled (0 if disabled)
14
        print "Computer: #{c.hwinfo.name} | Enabled: "
15
        if "#{c.limits.enabled}" == "1"
16
                print "Yes"
17
                # If the computer is enabled we disable it
18
                c.request_disable(Libdrqueue::CLIENT)
19
                print "\tDisabled !\n"
20
        else
21
                print "No"
22
                # If the computer is disabled we enable it
23
                c.request_enable(Libdrqueue::CLIENT)
24
                print "\tEnabled !\n"
25
        end
26
end
27