danarchy_sys 0.2.15 → 0.2.16
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1dc8aee4f74e525822bf6f39af45612d8a7abd9
|
4
|
+
data.tar.gz: 997a84b936ea0fd23e4134a2294612e654439075
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8293f2a3dfb97a1a6b947a31ba11f6c6412d09ad3ce326a2f017d3233711567f03e6831240f420bdbcd0b360117f3de5ffbfd43fd70980d8ddeb7c4007e044c2
|
7
|
+
data.tar.gz: f4e9bc35308b8bf9e0be45791e74c8032f5416fdc262df1c7c9349fcc8c60f539fd04667918e5b6517e5d41837fc5d5a4357b20cc84c6f43b6d6fec1d3454f4c
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative './menus'
|
2
|
+
require_relative './keypair_manager/keypair_status'
|
2
3
|
|
3
4
|
class KeypairManager
|
4
5
|
def self.manager(os_compute)
|
@@ -11,8 +12,13 @@ class KeypairManager
|
|
11
12
|
while keypair == false
|
12
13
|
keypair = chooser(os_compute)
|
13
14
|
return Menus.print_menu('main') if keypair == 'main'
|
14
|
-
end
|
15
15
|
|
16
|
+
if keypair == 'keypair'
|
17
|
+
Menus.print_menu('keypair')
|
18
|
+
keypair = false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
16
22
|
print "#{keypair.name} ~: " if keypair
|
17
23
|
cmd = gets.chomp
|
18
24
|
|
@@ -27,6 +33,8 @@ class KeypairManager
|
|
27
33
|
Menus.print_menu('keypair')
|
28
34
|
elsif cmd == 'main'
|
29
35
|
return Menus.print_menu('main')
|
36
|
+
elsif cmd == 'info'
|
37
|
+
KeypairStatus.single_keypair(keypair)
|
30
38
|
elsif cmd == 'chooser'
|
31
39
|
keypair = chooser(os_compute)
|
32
40
|
elsif cmd == 'create'
|
@@ -45,36 +53,6 @@ class KeypairManager
|
|
45
53
|
else
|
46
54
|
puts "#{keypair.name} was not deleted!"
|
47
55
|
end
|
48
|
-
elsif cmd == 'status'
|
49
|
-
printf("%#{keypair.name.size}s %0s %0s\n", keypair.name, ' => ', keypair.state)
|
50
|
-
elsif %w(pause unpause suspend resume start stop).include?(cmd.to_s)
|
51
|
-
status = keypair.state
|
52
|
-
|
53
|
-
if cmd =~ /e$/
|
54
|
-
print "#{cmd.gsub(/e$/, 'ing')} #{keypair.name} ."
|
55
|
-
else
|
56
|
-
print "#{cmd}ing #{keypair.name} ."
|
57
|
-
end
|
58
|
-
|
59
|
-
response = comp_kp.send(cmd.to_s, keypair.name.to_s)
|
60
|
-
if response == false
|
61
|
-
puts "\nInvalid action for #{keypair.name}'s current status!"
|
62
|
-
next
|
63
|
-
end
|
64
|
-
|
65
|
-
until status != keypair.state
|
66
|
-
keypair = os_compute.compute_keypairs.get_keypair(keypair.name)
|
67
|
-
sleep(3)
|
68
|
-
print ' .'
|
69
|
-
end
|
70
|
-
|
71
|
-
printf("\n%#{keypair.name.size}s %0s %0s\n", keypair.name, ' => ', keypair.state)
|
72
|
-
elsif cmd == 'connect'
|
73
|
-
if keypair.state == 'ACTIVE'
|
74
|
-
os_compute.compute_ssh(keypair.name.to_s)
|
75
|
-
else
|
76
|
-
puts "Unable to connect: #{keypair.name} is not running!"
|
77
|
-
end
|
78
56
|
else
|
79
57
|
Menus.print_menu('keypair')
|
80
58
|
puts "\nCommand \'#{cmd}\' not available. Enter a command from above."
|
@@ -119,6 +97,7 @@ class KeypairManager
|
|
119
97
|
|
120
98
|
abort('Exiting') if keypair_name == 'exit'
|
121
99
|
return 'main' if keypair_name == 'main'
|
100
|
+
return 'keypair' if keypair_name == 'help'
|
122
101
|
|
123
102
|
# Accept keypair Id as an entry
|
124
103
|
if keypair_name =~ /^[0-9]*$/
|
@@ -135,7 +114,8 @@ class KeypairManager
|
|
135
114
|
Should we create a new keypair named #{keypair_name}? (Y/N): "
|
136
115
|
|
137
116
|
if gets.chomp =~ /^y(es)?$/i
|
138
|
-
comp_kp.create_keypair(keypair_name)
|
117
|
+
keypair = comp_kp.create_keypair(keypair_name)
|
118
|
+
KeypairStatus.single_keypair(keypair)
|
139
119
|
else
|
140
120
|
puts "Not creating new keypair: #{keypair_name}."
|
141
121
|
return false
|
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
class KeypairStatus
|
3
|
+
def self.all_keypairs(os_compute)
|
4
|
+
keypairs = os_compute.compute_keypairs.all_keypairs
|
5
|
+
|
6
|
+
keypairs.each do |keypair|
|
7
|
+
single_keypair(keypair)
|
8
|
+
puts ''
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.single_keypair(keypair)
|
14
|
+
istats = { 'Name' => keypair.name,
|
15
|
+
'Fingerprint' => keypair.fingerprint,
|
16
|
+
'Public Key' => keypair.public_key,
|
17
|
+
}
|
18
|
+
|
19
|
+
format = "%#{istats.keys.max.size + 2}s"
|
20
|
+
|
21
|
+
istats.each do |k, v|
|
22
|
+
printf("#{format} %0s\n", "#{k}:", v)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -17,7 +17,8 @@ class Menus
|
|
17
17
|
'create' => 'Create a new instance',
|
18
18
|
'delete' => 'Delete this instance'
|
19
19
|
},
|
20
|
-
'keypair' => { '
|
20
|
+
'keypair' => { 'info' => 'View information about this keypair',
|
21
|
+
'create' => 'Create a new keypair',
|
21
22
|
'delete' => 'Delete an existing keypair'
|
22
23
|
}
|
23
24
|
}
|
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.2.
|
4
|
+
version: 0.2.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan James
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog-openstack
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- lib/danarchy_sys/cli/instance_manager/instance_status.rb
|
101
101
|
- lib/danarchy_sys/cli/instance_manager/prompts_create_instance.rb
|
102
102
|
- lib/danarchy_sys/cli/keypair_manager.rb
|
103
|
+
- lib/danarchy_sys/cli/keypair_manager/keypair_status.rb
|
103
104
|
- lib/danarchy_sys/cli/menus.rb
|
104
105
|
- lib/danarchy_sys/cli/providers.rb
|
105
106
|
- lib/danarchy_sys/config_manager.rb
|