danarchy_sys 0.4.2 → 0.4.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3f76e6fb34f0feb1d9f1cf3d322682a57d7d750
|
4
|
+
data.tar.gz: 9ddddfb4bc3c9736987becf0a56e1f866ecc85a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75cd4dbcac1d2079567ba80ebb59a22de3c9c4931440b55202c19f1165f6e2945ebae9387e9a968601a134ae50e72b676d9b3aae2429da530dd4d03040dbb024
|
7
|
+
data.tar.gz: d28bd7ea89a6352b892ba4e86650aae633b81551dd5c3c039fc8156f50476c298bf7be6614273555a306f2cc8843b55f7d308a601aee842eed2590d0e6757e8d
|
@@ -50,50 +50,48 @@ module DanarchySys
|
|
50
50
|
image_id = instance.image['id']
|
51
51
|
image = comp_img.get_image_by_id(image_id)
|
52
52
|
|
53
|
-
ssh = nil
|
53
|
+
ssh, user = nil
|
54
54
|
if image == nil
|
55
55
|
puts "Image not found for #{instance.name}! This instance needs to be rebuild with a current image."
|
56
|
-
ssh = fallback_ssh(ipv4, pemfile)
|
56
|
+
ssh, user = fallback_ssh(ipv4, pemfile)
|
57
|
+
else
|
58
|
+
user = 'ubuntu' if image.name =~ /ubuntu/i
|
59
|
+
user = 'debian' if image.name =~ /debian/i
|
60
|
+
user = 'centos' if image.name =~ /centos/i
|
61
|
+
user = 'fedora' if image.name =~ /fedora/i
|
62
|
+
user = 'core' if image.name =~ /coreos/i
|
57
63
|
end
|
58
64
|
|
59
|
-
return
|
65
|
+
return if !user
|
60
66
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
user = 'centos' if image.name =~ /centos/i
|
65
|
-
user = 'fedora' if image.name =~ /fedora/i
|
66
|
-
user = 'core' if image.name =~ /coreos/i
|
67
|
-
|
68
|
-
puts "Connecting as user: #{user} => #{ipv4}"
|
69
|
-
connect = "ssh #{user}@#{ipv4} -i '#{pemfile}'"
|
70
|
-
ssh = system(connect)
|
71
|
-
|
72
|
-
attempts = 1
|
73
|
-
until ssh == true || attempts > 3
|
74
|
-
puts "Connection failed. Attempting again after 5 seconds..."
|
75
|
-
sleep(5)
|
76
|
-
fallback_ssh(ipv4, pemfile)
|
77
|
-
attempts += 1
|
78
|
-
puts 'Giving up after 3 tries.' if attempts > 3
|
79
|
-
end
|
80
|
-
|
81
|
-
ssh
|
67
|
+
puts "Connecting as user: #{user} @ #{ipv4}"
|
68
|
+
connect = "/usr/bin/ssh -i '#{pemfile}' #{user}@#{ipv4}"
|
69
|
+
system(connect)
|
82
70
|
end
|
83
71
|
|
84
72
|
def fallback_ssh(ipv4, pemfile)
|
85
|
-
users = [
|
86
|
-
ssh = nil
|
87
|
-
|
88
|
-
users.each do |
|
89
|
-
|
90
|
-
connect = "ssh
|
91
|
-
ssh = system(connect)
|
92
|
-
|
73
|
+
users = %w[centos ubuntu debian fedora core]
|
74
|
+
ssh, user = nil
|
75
|
+
|
76
|
+
users.each do |username|
|
77
|
+
print "Attempting connection as user: #{username} @ #{ipv4} => "
|
78
|
+
connect = "/usr/bin/ssh -i '#{pemfile}' #{username}@#{ipv4}"
|
79
|
+
ssh = system("#{connect} 'uptime' &>/dev/null")
|
80
|
+
puts 'failed' if ssh ==false
|
81
|
+
|
82
|
+
if ssh == true
|
83
|
+
puts 'success'
|
84
|
+
user = username
|
85
|
+
break
|
86
|
+
end
|
93
87
|
end
|
94
88
|
|
95
|
-
|
96
|
-
|
89
|
+
if ssh == false
|
90
|
+
puts 'Unable to connect! User unknown or SSHd is not running on the instance.'
|
91
|
+
return ssh, nil
|
92
|
+
else
|
93
|
+
return [ssh, user]
|
94
|
+
end
|
97
95
|
end
|
98
96
|
end
|
99
97
|
end
|
data/lib/danarchy_sys/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danarchy_sys
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan James
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog-openstack
|