107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
# File 'lib/cluster.rb', line 107
def current(*params)
unless @sub.in_cluster?
msg = "#{Cluster::NAME} says that we aren't in the cluster?"
$stderr.puts msg
raise RuntimeError.new(msg)
end
unless params.length > 0
msg = "#{Cluster::NAME} current needs to know what to do?\n\t* services\n\t* name (|| dns)\n\t* ip\n\t* enable\n\t* disable"
$stderr.puts msg
raise ArgumentError.new(msg)
end
current = @sub.current_instance
cmd = params.shift
case cmd.downcase
when 'services'
current.services - current.disabled_services
when /^(n|dn)/ current.dns
when /^i/ current.ip
when /^a/ @sub.alter_instances!(current) {|i| i.services = Array(params) }
when /^e/ @sub.alter_instances!(current) {|i| i.enable *params }
when /^di/ @sub.alter_instances!(current) {|i| i.disable *params }
when /^s/ @sub.alter_instances!(current) {|i| i.set_state *params }
else
msg = "#{Cluster::NAME} curent did not understand '#{params.join(' ')}'"
$stderr.puts msg
raise ArgumentError.new(msg)
end
end
|