Class: SetPrefix

Inherits:
Command show all
Defined in:
lib/maws/commands/set-prefix.rb

Instance Attribute Summary

Attributes inherited from Command

#connection, #maws

Instance Method Summary collapse

Methods inherited from Command

#add_generic_options, #initialize, #instances, #process_options, #verify_configs

Constructor Details

This class inherits a constructor from Command

Instance Method Details

#add_specific_options(parser) ⇒ Object



8
9
10
# File 'lib/maws/commands/set-prefix.rb', line 8

def add_specific_options(parser)
  parser.opt :prefix_to_set, "Prefix to set", :short => "-P", :type => :string, :default => ""
end

#descriptionObject



4
5
6
# File 'lib/maws/commands/set-prefix.rb', line 4

def description
  "set-prefix - sets prefix for specified EC2 instances"
end

#run!Object



19
20
21
22
23
# File 'lib/maws/commands/set-prefix.rb', line 19

def run!
  prefix = @config.command_line.prefix_to_set

  instances.specified.alive.each {|i| i.set_prefix(prefix) if i.respond_to?(:set_prefix)}
end

#verify_optionsObject



12
13
14
15
16
17
# File 'lib/maws/commands/set-prefix.rb', line 12

def verify_options
  super
  prefix = @config.command_line.prefix_to_set

  Trollop::die "Can't set the prefix to be the same as the prefix currently in scope: '#{@config.prefix}'" if prefix == @config.prefix
end