aws-eni 0.4.0 → 0.4.1
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.
- checksums.yaml +4 -4
- data/bin/aws-eni +15 -5
- data/lib/aws-eni/client.rb +3 -2
- data/lib/aws-eni/interface.rb +6 -4
- data/lib/aws-eni/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: c19de93aff68758d1c59c46801a7ad707350aa7b
|
4
|
+
data.tar.gz: 6fb377899c3f4c1f894d82a195768e699388cfec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef384ea2c14806ba12a499563639b8c1f4b9d63ee7c4b4f081c3cb6368813d625003204fccee7c68d9220f63741de189020b19c471ed8ee408cb1319298cb085
|
7
|
+
data.tar.gz: d3e0e7595785be73265394aa356457f343001033b03ef32336e41c6cd58909ecf83f8b1d2ad7f1ebe9f4d404b5306ea44da5fcae619508573eff6f3d856e0cba
|
data/bin/aws-eni
CHANGED
@@ -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 '
|
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 '
|
574
|
-
|
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
|
579
|
-
puts
|
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
|
data/lib/aws-eni/client.rb
CHANGED
@@ -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
|
29
|
-
raise
|
28
|
+
rescue Errors::ServiceError
|
29
|
+
raise
|
30
|
+
rescue
|
30
31
|
raise Errors::EnvironmentError, 'Unable to initialize EC2 client'
|
31
32
|
end
|
32
33
|
|
data/lib/aws-eni/interface.rb
CHANGED
@@ -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
|
data/lib/aws-eni/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2015-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|