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: 91467380d7fc7465187c4929c8421828cb7d1343
4
- data.tar.gz: c97f5d4a0b6ad94e05a2e7758b8f525f8184d2ee
3
+ metadata.gz: e3f76e6fb34f0feb1d9f1cf3d322682a57d7d750
4
+ data.tar.gz: 9ddddfb4bc3c9736987becf0a56e1f866ecc85a6
5
5
  SHA512:
6
- metadata.gz: 09f9b084eba3b008aacd25310afe55d2a298ac8113649bd1224689be72418cfc5bc79674fd8f3685dc85f8e76d916cdc4d85073324e102744f4ecf1702adbada
7
- data.tar.gz: be506fe3640af9e886ccc951bc8067dbb0f89b858ebaaa1bdbce4a0ee85b7c27c0ef222a575835c06c88dc8c6b242bf4c3f703704c23ccd512042aeca99ccfd2
6
+ metadata.gz: 75cd4dbcac1d2079567ba80ebb59a22de3c9c4931440b55202c19f1165f6e2945ebae9387e9a968601a134ae50e72b676d9b3aae2429da530dd4d03040dbb024
7
+ data.tar.gz: d28bd7ea89a6352b892ba4e86650aae633b81551dd5c3c039fc8156f50476c298bf7be6614273555a306f2cc8843b55f7d308a601aee842eed2590d0e6757e8d
@@ -89,7 +89,6 @@ class PromptsCreateInstance
89
89
 
90
90
  flavor_name = item_chooser(flavors_numbered, 'flavor')
91
91
  print "Flavor Name: #{flavor_name.split('.')[1]}\n"
92
- p comp_flvs.methods
93
92
  comp_flvs.get_flavor_by_name(flavor_name)
94
93
  end
95
94
 
@@ -142,7 +142,7 @@ Should we create a new instance named #{instance_name}? (Y/N): "
142
142
  return instance
143
143
  else
144
144
  puts "Not creating new instance: #{instance_name}."
145
- return
145
+ return false
146
146
  end
147
147
  end
148
148
  end
@@ -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 ssh if ssh == true
65
+ return if !user
60
66
 
61
- # CoreOS is an exception with user as simply 'core' and not 'coreos'
62
- user = 'ubuntu' if image.name =~ /ubuntu/i
63
- user = 'debian' if image.name =~ /debian/i
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 = ['ubuntu','debian','centos','fedora','core']
86
- ssh = nil
87
-
88
- users.each do |user|
89
- puts "Attempting connection as user: #{user} => #{ipv4}"
90
- connect = "ssh #{user}@#{ipv4} -i '#{pemfile}'"
91
- ssh = system(connect)
92
- break if ssh == true
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
- puts 'Unable to connect! User unknown or SSHd is not running on the instance.' if ssh == false
96
- ssh
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
@@ -1,3 +1,3 @@
1
1
  module DanarchySys
2
- VERSION = '0.4.2'
2
+ VERSION = '0.4.3'
3
3
  end
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.2
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-21 00:00:00.000000000 Z
11
+ date: 2018-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-openstack