Method: CollinsShell::Asset#set_attribute

Defined in:
lib/collins_shell/asset.rb

#set_attribute(key, value) ⇒ Object



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/collins_shell/asset.rb', line 143

def set_attribute key, value
  batch_selector_operation Hash[
    :remote => options.remote,
    :operation => "set_attribute",
    :size => options["size"],
    :success_message => proc {|asset| "Set attribute on #{asset.tag}"},
    :error_message => proc{|asset| "Setting attribute on #{asset.tag}"},
    :confirmation_message => proc do |assets|
      "You are about to set #{key}=#{value} on #{assets.length} hosts. ARE YOU SURE?"
    end
  ] do |client,asset|
    if options.json then
      value = JSON.dump(eval(value))
    end
    dimension = nil
    if options.dimension >= 0 then
      dimension = options.dimension
    end
    client.set_attribute!(asset, key, value, dimension)
  end
end