ec2-clusterssh 0.4.3 → 0.5.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: e6372df3f909d807cbe50f7b27b9047b55cbf0bf
4
- data.tar.gz: 4a0275ecadbc4f08dfbc9a1220b57590c7dcd2d8
3
+ metadata.gz: d2eccafeb666e8571d974f859152314f076b0db1
4
+ data.tar.gz: 80d246b1dbc3ea948a92bfcb3213d1743597ad05
5
5
  SHA512:
6
- metadata.gz: 237dbca77daceee9390cac5c4922b94398a20070be58c742d0c1ecd74fa444abee900b4f177c5ca51b981b6c88dc4765e48a81e40cb8f1c80661c3bfa17e9534
7
- data.tar.gz: 32fe08161bc6371c46ee5169794a9b4248c3ada71d82039706a4056b0e1dacaf69bea4594cce7dba3bf0a050e3a30085dff3cafaa44ece577fa349f0f355525d
6
+ metadata.gz: 5cde55c7a1907c72d4aca4ded9ae1c56320dabc50ab27598b02b693e91b053e71042b1f521b19d5aca498ff53d703692c692d738da90c7b723f37bffd85600e0
7
+ data.tar.gz: 3b08abc374e9c818edbb8d96ff59fc8058e72bcec30e9e11796b23ff240222c61ca9664cf148c7b50567fa4bb727963c5c46e975f58bdc0b52878055446b5e1c
data/README.md CHANGED
@@ -23,14 +23,16 @@ Note: Mac users with the latest version of XCode may run into a compilation err
23
23
  ## Usage
24
24
 
25
25
  $cluster -h
26
- Usage: cluster [-t TAGS] [-l USER] [-r region]
27
- -l, --login [USER] Log in with this user (default: ec2-user
28
- -t, --tags [TAGS] a 'space' sparated key value pair of tags and values (i.e. role=web,database environment=dev)
26
+ Usage: cluster [-t TAGS] [-l USER] [-k KEY -s SECRET] [-r region]
27
+ -l, --login [USER] Log in with this user
28
+ -t, --tags [TAGS] a 'space' sparated key value pair of tags and values (i.e. -t 'role=web,database environment=dev')
29
29
  -r, --region [REGION] AWS region
30
+ -s, --screen [SCREEN] What screen to use for clustering windows (form multiple displays)
30
31
  -p, --use-public-ip Use public IP (default false)
31
32
 
32
- $cluster -l ec2-user -t Name=web,database #Connects to all web and database servers
33
- $cluster -l ec2-user -t role=web,database environment=dev #Connects to all web and database servers in the dev environment
33
+
34
+ $cluster -t Name=web,database #Connects to all web and database servers
35
+ $cluster -t 'role=web,database environment=dev' #Connects to all web and database servers in the dev environment
34
36
 
35
37
  ## Notes
36
38
 
data/bin/cluster CHANGED
@@ -34,32 +34,36 @@ OptionParser.new do |opts|
34
34
 
35
35
  end.parse!
36
36
 
37
- Aws.config.update({:region => options['region']})
38
37
 
39
- ec2 = Aws::EC2::Client.new
38
+ Aws.config.update({:region => options['region']})
39
+ $ec2 = Aws::EC2::Client.new
40
40
 
41
- # filter instances based on tags
42
- instances = []
43
- options['tags'].each do |tag|
44
- tag = tag.split('=')
45
- key = tag[0]
46
- values = tag[1].split(',')
47
- response = ec2.describe_instances(filters: [{:name => "tag-key", :values => [key]}])
41
+ def get_instances_by_tag (tag_key,tag_values,options)
42
+ instances = []
43
+ response = $ec2.describe_instances(filters: [{:name => "tag:#{tag_key}", :values => tag_values},{:name => "instance-state-name", :values => ['running']}])
48
44
  if response.reservations[0].nil?
49
- puts "No instances in #{options['region']} had a tag named '#{key}'"
50
- next
45
+ puts "No running instances in #{options['region']} had a tag named '#{tag_key}' with values '#{tag_values}'"
51
46
  else
52
47
  response.reservations.each do |reservation|
53
48
  reservation.instances.each do |instance|
54
- tag_value = instance.tags.keep_if{|instance_tag| instance_tag[:key] == key}[0][:value]
55
- if values.include? tag_value
56
- instances << instance
57
- end
49
+ instances << instance
58
50
  end
59
51
  end
52
+ return instances
60
53
  end
61
54
  end
62
55
 
56
+ matched_instances = []
57
+ # filter instances based on tags
58
+ options['tags'].each do |tag|
59
+ tag = tag.split('=')
60
+ key = tag[0]
61
+ values = tag[1].split(',')
62
+ matched_instances << get_instances_by_tag(key,values,options)
63
+ end
64
+ instances = matched_instances[0]
65
+ matched_instances.map {|group| instances = group & instances }
66
+
63
67
  if instances.length == 0
64
68
  puts "No instnaces matched filter: #{options['tags']}"
65
69
  exit 1
@@ -1,5 +1,5 @@
1
1
  module Ec2
2
2
  module Clusterssh
3
- VERSION = "0.4.3"
3
+ VERSION = "0.5.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.4.3
4
+ version: 0.5.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: 2015-11-18 00:00:00.000000000 Z
11
+ date: 2016-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler