Class: Ec2::Cli::Resources
- Inherits:
-
Object
- Object
- Ec2::Cli::Resources
- Defined in:
- lib/ec2/cli/resources.rb
Instance Method Summary collapse
- #config ⇒ Object
- #init_aws ⇒ Object
-
#initialize(argv) ⇒ Resources
constructor
A new instance of Resources.
- #lock ⇒ Object
- #opts ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(argv) ⇒ Resources
9 10 11 |
# File 'lib/ec2/cli/resources.rb', line 9 def initialize(argv) @argv = argv end |
Instance Method Details
#config ⇒ Object
35 36 37 |
# File 'lib/ec2/cli/resources.rb', line 35 def config @config ||= ::Ec2::Config.new("ec2.rb").config end |
#init_aws ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/ec2/cli/resources.rb', line 27 def init_aws if not config[:use_iam] credentials = Aws::Credentials.new(config[:aws_key], config[:aws_secret]) Aws.config[:credentials] = credentials end Aws.config[:region] = config[:region] end |
#lock ⇒ Object
23 24 25 |
# File 'lib/ec2/cli/resources.rb', line 23 def lock @lock ||= ::Ec2::Lock.new end |
#opts ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ec2/cli/resources.rb', line 39 def opts OptionParser.new do |opts| opts. = "Usage: ec2 resources [options] [target]" opts.on("-f", "--file FILE", "Specify hosts file") do |f| salt.hosts_file = f end opts.on("-h", "--help", "Help") do puts opts exit end end end |
#run ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/ec2/cli/resources.rb', line 13 def run lock.acquire opts.parse!(@argv) init_aws @argv.each do |file| resources = ::Ec2::Resources.new(file) resources.apply end end |