awful 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a102ebb758f56e3699436ff0e32fa5a3a7b1db36
4
- data.tar.gz: 6b73e714e85aeb3a10aff2d57c038818dded6a74
3
+ metadata.gz: a489c3905456530f6bb1c8488efda13ad8855934
4
+ data.tar.gz: 9955d6190e62661d9bef504d13f915f43a8567a1
5
5
  SHA512:
6
- metadata.gz: 76ffecd19a005dc4542f94c867e4940a5064dce71378c05ce5a8053231b088a4af7a15bded7cbbb741fde91c954c369b92b124ebfb695d46ab2c70bbcfab4fd6
7
- data.tar.gz: 957a113135a6f9ea94e968e645cf8d9a34f7591f7fbc86edadb30e11cfaf49ab4c5c48a76c8fbdf43969ca93a6f20046ca5cddeb3663176f46d4443f35064982
6
+ metadata.gz: 19022988314be3f944afa42e4ed2e1e79a62d78301496dbe69be8534b45a182aba777053f72cb857f49ccc41e421dd4dc366e8ed16551a802bdd9889863571a5
7
+ data.tar.gz: 6235726073e5515af5a66b19b41d34048aea162adb11923d2659c4f7ded1330aea43bb32c5ed3690d3fe9ecf72d5e0e92f0574e6c408813bdf394562d1cd44ba
@@ -3,6 +3,7 @@ require "awful/version"
3
3
  require 'aws-sdk'
4
4
  require 'thor'
5
5
  require 'yaml'
6
+ require 'erb'
6
7
 
7
8
  module Awful
8
9
 
@@ -42,9 +43,10 @@ module Awful
42
43
  end
43
44
  end
44
45
 
45
- def load_cfg(options = {})
46
- cfg = $stdin.tty? ? {} : symbolize_keys(YAML.load($stdin.read))
47
- cfg.merge(symbolize_keys(options.reject{ |_,v| v.nil? }))
46
+ def load_cfg(options = {}, file = nil)
47
+ src = (file and File.read(file)) || ((not $stdin.tty?) and $stdin.read)
48
+ cfg = src ? YAML.load(::ERB.new(src).result(binding)) : {}
49
+ symbolize_keys(cfg).merge(symbolize_keys(options.reject{ |_,v| v.nil? }))
48
50
  end
49
51
 
50
52
  def only_keys_matching(hash, keylist)
@@ -88,4 +90,15 @@ module Awful
88
90
  end
89
91
  end
90
92
 
93
+ ## return id for security group by name
94
+ def find_sg(name)
95
+ if name.match(/^sg-[\d[a-f]]{8}$/)
96
+ name
97
+ else
98
+ ec2.describe_security_groups.map(&:security_groups).flatten.find do |sg|
99
+ tag_name(sg) == name
100
+ end.group_id
101
+ end
102
+ end
103
+
91
104
  end
@@ -75,9 +75,9 @@ module Awful
75
75
  puts YAML.dump(stringify_keys(asg))
76
76
  end
77
77
 
78
- desc 'create NAME', 'create a new auto-scaling group'
79
- def create(name)
80
- opt = load_cfg
78
+ desc 'create NAME [FILE]', 'create a new auto-scaling group'
79
+ def create(name, file = nil)
80
+ opt = load_cfg(options, file)
81
81
  whitelist = %i[auto_scaling_group_name launch_configuration_name instance_id min_size max_size desired_capacity default_cooldown availability_zones
82
82
  load_balancer_names health_check_type health_check_grace_period placement_group vpc_zone_identifier termination_policies tags ]
83
83
 
@@ -91,13 +91,14 @@ module Awful
91
91
  autoscaling.create_auto_scaling_group(opt)
92
92
  end
93
93
 
94
- desc 'update NAME', 'update existing auto-scaling group'
94
+ desc 'update NAME [FILE]', 'update existing auto-scaling group'
95
95
  method_option :desired_capacity, aliases: '-d', default: nil, desc: 'Set desired capacity'
96
96
  method_option :min_size, aliases: '-m', default: nil, desc: 'Set minimum capacity'
97
97
  method_option :max_size, aliases: '-M', default: nil, desc: 'Set maximum capacity'
98
98
  method_option :launch_configuration_name, aliases: '-l', default: nil, desc: 'Launch config name'
99
- def update(name)
100
- opt = load_cfg(options)
99
+ def update(name, file = nil)
100
+ opt = load_cfg(options, file)
101
+
101
102
  whitelist = %i[auto_scaling_group_name launch_configuration_name min_size max_size desired_capacity default_cooldown availability_zones
102
103
  health_check_type health_check_grace_period placement_group vpc_zone_identifier termination_policies ]
103
104
 
@@ -1,3 +1,3 @@
1
1
  module Awful
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awful
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ric Lister
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-20 00:00:00.000000000 Z
11
+ date: 2015-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler