aws_csshx 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,8 @@
1
+ ### aws_csshx 0.1.4 2012-05-21
2
+
3
+ * Better error handling (Eric Lubow)
4
+ * Better system call checking (Eric Lubow)
5
+
1
6
  ### aws_csshx 0.1.3 2012-05-05
2
7
 
3
8
  * Ability to add individual servers on the command line (Eric Lubow)
data/TODO.md CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  * Add testing
4
4
  * Specify AWS secret and access key on the command
5
- * Better method for system call
6
5
  * Silence RightAws::Ec2 output
7
6
  * Add logging for verbose output
7
+ * Add ability to SSH to multiple groups
@@ -6,6 +6,7 @@ module AwsCsshx
6
6
 
7
7
  def csshx_exists?
8
8
  `which csshx > /dev/null 2>&1`
9
+ $?.success?
9
10
  end
10
11
 
11
12
  def aws_settings_exist?
@@ -20,7 +21,7 @@ module AwsCsshx
20
21
  @options = {}
21
22
 
22
23
  # No need to go further unless csshX exists
23
- abort('csshX file is required') unless csshx_exists?
24
+ raise OptionsError, "csshX file is required" unless csshx_exists?
24
25
 
25
26
  begin
26
27
  # First we load the config file and then process the command line
@@ -61,9 +62,10 @@ module AwsCsshx
61
62
  end
62
63
 
63
64
  # Stop here without all our AWS settings
64
- abort("Invalid AWS settings") unless aws_settings_exist?
65
+ raise OptionsError, "Invalid AWS settings" unless aws_settings_exist?
66
+
67
+ raise OptionsError, "Cannot continue without AWS security group (-g)" unless @options[:group]
65
68
 
66
- abort("Cannot continue without AWS security group (-g)") unless @options[:group]
67
69
  @server_list = aws_server_list_by_group @options[:group]
68
70
  aws_server_count = @server_list.count
69
71
 
@@ -71,21 +73,38 @@ module AwsCsshx
71
73
  add_servers_from_command_line if @options[:additional_servers]
72
74
 
73
75
  if has_servers? @server_list
74
- `csshx --login #{@options[:login]} --ssh_args='-i #{@options[:ec2_private_key]}' #{@server_list.join(' ')}`
76
+ csshx_switches = create_csshx_switches
77
+ `csshx #{[csshx_switches, @server_list].join(' ')}`
75
78
  puts "Opened connections to #{aws_server_count} servers in the '#{@options[:group]}' security group."
76
79
  puts "Opened connections to #{@options[:additional_servers].count} servers from command-line options." if @options[:additional_servers]
77
80
  else
78
- puts "No servers found...bailing out!"
81
+ raise OptionsError, "No servers found in '#{@options[:group]}' group...bailing out!"
79
82
  end
83
+
84
+ rescue OptionsError => e
85
+ puts "Error: #{e}"
86
+
80
87
  rescue Exception => e
81
- puts "Error: #{e.inspect}"
82
- puts "Trace: #{e.backtrace.join('\n')}"
88
+ puts "#{e.class} Error: #{e}"
89
+ puts "Backtrace:\n#{e.backtrace.join("\n")}"
83
90
  end
84
91
 
85
92
  # Exit cleanly
86
93
  return 0
87
94
  end
88
95
 
96
+ def create_csshx_switches
97
+ switches = []
98
+
99
+ # Set the basics by default
100
+ switches.push('--login', @options[:login])
101
+ switches.push("--ssh_args='-i #{@options[:ec2_private_key]}'")
102
+
103
+ # Add the additional stuff specific to csshx
104
+ switches.push('--iterm2', @options[:iterm2]) if @options[:iterm2]
105
+ switches.push(@options[:csshx_opts]) if @options[:csshx_opts]
106
+ end
107
+
89
108
  def add_servers_from_command_line
90
109
  @server_list.push(@options[:additional_servers]).flatten!.uniq! if @options[:additional_servers]
91
110
  end
@@ -1,4 +1,6 @@
1
1
  module AwsCsshx
2
+ class OptionsError < StandardError; end
3
+
2
4
  class Options < Hash
3
5
  attr_reader :opts, :orig_args, :parsed
4
6
 
@@ -1,3 +1,3 @@
1
1
  module AwsCsshx
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws_csshx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-05-05 00:00:00.000000000 Z
13
+ date: 2012-05-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: right_aws