Top Level Namespace

Defined Under Namespace

Classes: I2Cssh

Instance Method Summary collapse

Instance Method Details

#get_hosts(c) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'bin/i2cssh', line 11

def get_hosts(c)
    if c =~ /(.+)@(.+)/ then
         = $1
        c = $2
    end

    cluster = @clusters[c]

    if cluster
        set_options(cluster, )

        if @i2_options[:login_override] then
            @servers += cluster["hosts"].map{|h| "#{@i2_options[:login_override]}@#{h}"}
        else
            @servers += cluster["hosts"]
        end
    else
        puts "ERROR: unknown cluster #{c}. Check your #{@config_file}"
        exit 1
    end
end

#set_options(config_hash, login_override = nil) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'bin/i2cssh', line 33

def set_options(config_hash, =nil)
    if config_hash["columns"] and config_hash["rows"] then
        puts "CONFIG ERROR: rows and columns can't be used a the same time"
        exit 1
    end

    [:broadcast, :profile, :rank, :iterm2, :login_override, :columns, :rows, :sleep, :direction].each do |p|
        @i2_options[p] = config_hash[p.to_s].nil? ? @i2_options[p] : config_hash[p.to_s]
    end

    @i2_options[:login_override] =  if 
    @i2_options[:direction] ||= :column
    @i2_options[:direction] = @i2_options[:direction].to_sym

    @ssh_environment.merge!(config_hash["environment"].inject({}){|m, v| m.merge(v)}) if config_hash["environment"]
end