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 +4 -4
- data/README.md +7 -5
- data/bin/cluster +19 -15
- data/lib/ec2/clusterssh/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2eccafeb666e8571d974f859152314f076b0db1
|
4
|
+
data.tar.gz: 80d246b1dbc3ea948a92bfcb3213d1743597ad05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
33
|
-
$cluster -
|
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
|
-
|
38
|
+
Aws.config.update({:region => options['region']})
|
39
|
+
$ec2 = Aws::EC2::Client.new
|
40
40
|
|
41
|
-
|
42
|
-
instances = []
|
43
|
-
|
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 '#{
|
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
|
-
|
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
|
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
|
+
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:
|
11
|
+
date: 2016-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|