ec2-clusterssh 0.5.0 → 0.6.0

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: d2eccafeb666e8571d974f859152314f076b0db1
4
- data.tar.gz: 80d246b1dbc3ea948a92bfcb3213d1743597ad05
3
+ metadata.gz: 87e0940e6e9a972f932a251ea1ad5ef8f80f8b7b
4
+ data.tar.gz: 724c9fe8595dc50a057511f96e034cb1892305e6
5
5
  SHA512:
6
- metadata.gz: 5cde55c7a1907c72d4aca4ded9ae1c56320dabc50ab27598b02b693e91b053e71042b1f521b19d5aca498ff53d703692c692d738da90c7b723f37bffd85600e0
7
- data.tar.gz: 3b08abc374e9c818edbb8d96ff59fc8058e72bcec30e9e11796b23ff240222c61ca9664cf148c7b50567fa4bb727963c5c46e975f58bdc0b52878055446b5e1c
6
+ metadata.gz: 6dc03822490f16a98756ed823d007e5a5457791c72ccf527f73593048af95d7c6969c7004bc91817751bc3fd19e3438e4ef152996139f19d11b01b67386f190d
7
+ data.tar.gz: f981e74639119f9d0649f4e8f3b0dcbeec54c86eff47101fb31a2b55cc430ade66664a0a10b9f4df9dc0b98cbbc09898c00e7313c465fa34c0be47882588f817
data/bin/cluster CHANGED
@@ -16,8 +16,8 @@ OptionParser.new do |opts|
16
16
  options['user'] = opt
17
17
  end
18
18
 
19
- opts.on("-t", "--tags [TAGS]", "a 'space' sparated key value pair of tags and values (i.e. role=web,database environment=dev)") do |opt|
20
- options['tags'] = opt.split(' ')
19
+ opts.on("-t", "--tags [TAGS]", Array, "a 'comma' sparated key value pair of tags and values (i.e. role=web|database,environment=dev)") do |opt|
20
+ options['tags'] = opt
21
21
  end
22
22
 
23
23
  opts.on("-r", "--region [REGION]", "AWS region") do |opt|
@@ -34,10 +34,20 @@ OptionParser.new do |opts|
34
34
 
35
35
  end.parse!
36
36
 
37
+ puts options
38
+
37
39
 
38
40
  Aws.config.update({:region => options['region']})
39
41
  $ec2 = Aws::EC2::Client.new
40
42
 
43
+ def get_ip(instance, options)
44
+ if options['use_public_ip']
45
+ return instance.public_ip_address
46
+ else
47
+ return instance.private_ip_address
48
+ end
49
+ end
50
+
41
51
  def get_instances_by_tag (tag_key,tag_values,options)
42
52
  instances = []
43
53
  response = $ec2.describe_instances(filters: [{:name => "tag:#{tag_key}", :values => tag_values},{:name => "instance-state-name", :values => ['running']}])
@@ -46,7 +56,7 @@ def get_instances_by_tag (tag_key,tag_values,options)
46
56
  else
47
57
  response.reservations.each do |reservation|
48
58
  reservation.instances.each do |instance|
49
- instances << instance
59
+ instances << get_ip(instance, options)
50
60
  end
51
61
  end
52
62
  return instances
@@ -58,33 +68,26 @@ matched_instances = []
58
68
  options['tags'].each do |tag|
59
69
  tag = tag.split('=')
60
70
  key = tag[0]
61
- values = tag[1].split(',')
62
- matched_instances << get_instances_by_tag(key,values,options)
71
+ values = tag[1].split('|')
72
+ if matched_instances.empty?
73
+ matched_instances = get_instances_by_tag(key,values,options)
74
+ end
75
+ matched_instances = matched_instances & get_instances_by_tag(key,values,options)
76
+ puts "#{tag}: #{matched_instances}"
63
77
  end
64
- instances = matched_instances[0]
65
- matched_instances.map {|group| instances = group & instances }
66
78
 
67
- if instances.length == 0
79
+ if matched_instances.length == 0
68
80
  puts "No instnaces matched filter: #{options['tags']}"
69
81
  exit 1
70
82
  end
71
83
 
72
- # get dns entries for cssh
73
- dns = nil
74
- if options['use_public_ip']
75
- dns = instances.map{|instance| instance.public_ip_address}
76
- else
77
- dns = instances.map{|instance| instance.private_ip_address}
78
- end
79
-
80
-
81
84
  cssh = (/darwin/ =~ RUBY_PLATFORM) ? 'csshX' : 'cssh'
82
85
 
83
86
  cmd = "#{cssh}"
84
87
  cmd = cmd + " -l #{options['user']}" unless options['user'].nil?
85
88
  cmd = cmd + " -screen #{options['screen']}" unless options['screen'].nil?
86
- cmd = cmd + " #{dns.join ' '}"
89
+ cmd = cmd + " #{matched_instances.join ' '}"
87
90
 
88
- puts "Connecting to #{dns.length} instances"
91
+ puts "Connecting to #{matched_instances.length} instances"
89
92
  puts cmd
90
- exec cmd
93
+ #exec cmd
@@ -1,5 +1,5 @@
1
1
  module Ec2
2
2
  module Clusterssh
3
- VERSION = "0.5.0"
3
+ VERSION = "0.6.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ec2-clusterssh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Glenn Poston
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-11 00:00:00.000000000 Z
11
+ date: 2016-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler