aws-eni 0.4.0 → 0.4.1

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: 9e3020c6ae20a0d6a7027f065560e00c5764dbfb
4
- data.tar.gz: f4827152a5efad857d3a8818e7f882a5a25e15ca
3
+ metadata.gz: c19de93aff68758d1c59c46801a7ad707350aa7b
4
+ data.tar.gz: 6fb377899c3f4c1f894d82a195768e699388cfec
5
5
  SHA512:
6
- metadata.gz: bd1bb10082ba681b5452411d8f2e75a39cc9b6d7227e3e8b996de89b5d619072c3295a40c63db98e0e11bb2c938e8c01c7b736fd5122f6bd4da45d896a65b435
7
- data.tar.gz: 9c0e454b7797af337b50829ee4231ee9ee2f3f558343980023f4bb5078f6fb0c17fe0d81e5954473b90e67669e25adbb710ffc808143bb9e7b9eeb2a47e52ed4
6
+ metadata.gz: ef384ea2c14806ba12a499563639b8c1f4b9d63ee7c4b4f081c3cb6368813d625003204fccee7c68d9220f63741de189020b19c471ed8ee408cb1319298cb085
7
+ data.tar.gz: d3e0e7595785be73265394aa356457f343001033b03ef32336e41c6cd58909ecf83f8b1d2ad7f1ebe9f4d404b5306ea44da5fcae619508573eff6f3d856e0cba
@@ -562,7 +562,7 @@ command [:check] do |c|
562
562
  c.action do |global,opts,args|
563
563
  help_now! "Too many arguments" if args.count > 1
564
564
 
565
- print 'Interface permissions test... '
565
+ print 'kernel permissions test... '
566
566
  if Aws::ENI.has_interface_access?
567
567
  puts 'success!'
568
568
  else
@@ -570,13 +570,23 @@ command [:check] do |c|
570
570
  puts "- unable to modify network configuration with /sbin/ip (try sudo)"
571
571
  end
572
572
 
573
- print 'AWS EC2 permissions test... '
574
- if Aws::ENI.has_client_access?
573
+ print 'ec2 instance meta-data test... '
574
+ begin
575
+ env = Aws::ENI.environment
576
+ rescue Aws::ENI::Errors::EnvironmentError
577
+ puts 'failed'
578
+ puts '- unable to access ec2 meta-data. are we runing on ec2?'
579
+ else
580
+ puts 'success!'
581
+ end
582
+
583
+ print 'aws ec2 client access test... '
584
+ if env && Aws::ENI.has_client_access?
575
585
  puts 'success!'
576
586
  else
577
587
  puts 'failed'
578
- puts "- insufficient EC2 access. Ensure you have granted access to the"
579
- puts " appropriate EC2 methods in your IAM policy (see documentation)"
588
+ puts '- insufficient ec2 access to mutate interface config.'
589
+ puts '- ensure you have granted access to the appropriate ec2 methods in your IAM policy (see documentation)'
580
590
  end
581
591
  end
582
592
  end
@@ -25,8 +25,9 @@ module Aws
25
25
  # lazy-load our ec2 client
26
26
  def client
27
27
  @client ||= EC2::Client.new(region: region)
28
- rescue StandardError => e
29
- raise if e === Errors::ServiceError
28
+ rescue Errors::ServiceError
29
+ raise
30
+ rescue
30
31
  raise Errors::EnvironmentError, 'Unable to initialize EC2 client'
31
32
  end
32
33
 
@@ -99,13 +99,14 @@ module Aws
99
99
 
100
100
  # Execute an 'ip' command
101
101
  def cmd(command, options = {})
102
+ options[:sudo] = options[:sudo] != false
102
103
  errors = options[:errors]
103
104
  options[:errors] = true
104
105
  begin
105
106
  exec("/sbin/ip #{command}", options)
106
107
  rescue Errors::InterfaceOperationError => e
107
108
  case e.message
108
- when /operation not permitted/i
109
+ when /operation not permitted/i, /password is required/i
109
110
  raise Errors::InterfacePermissionError, "Operation not permitted"
110
111
  else
111
112
  raise if errors
@@ -125,6 +126,7 @@ module Aws
125
126
  output = nil
126
127
  errors = options[:errors]
127
128
  verbose = self.verbose || options[:verbose]
129
+ command = "sudo -n #{command}" if options[:sudo]
128
130
 
129
131
  puts command if verbose
130
132
  Open3.popen3(command) do |i,o,e,t|
@@ -213,8 +215,8 @@ module Aws
213
215
 
214
216
  # Return an array of configured ip addresses (primary + secondary)
215
217
  def local_ips
216
- list = cmd("addr show dev #{name} primary") +
217
- cmd("addr show dev #{name} secondary")
218
+ list = cmd("addr show dev #{name} primary", sudo: false) +
219
+ cmd("addr show dev #{name} secondary", sudo: false)
218
220
  list.lines.grep(/inet ([0-9\.]+)\/.* #{name}/i){ $1 }
219
221
  end
220
222
 
@@ -256,7 +258,7 @@ module Aws
256
258
 
257
259
  # Check whether our interface is enabled
258
260
  def enabled?
259
- exists? && cmd("link show up").include?(name)
261
+ exists? && cmd("link show up", sudo: false).include?(name)
260
262
  end
261
263
 
262
264
  # Initialize a new interface config
@@ -1,5 +1,5 @@
1
1
  module Aws
2
2
  module ENI
3
- VERSION = "0.4.0"
3
+ VERSION = "0.4.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-eni
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Greiling
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-13 00:00:00.000000000 Z
11
+ date: 2015-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli