Class: Oc::Run::Ssh
- Inherits:
-
Base
show all
- Defined in:
- lib/system/run/commands/ssh.rb
Instance Attribute Summary
Attributes inherited from Base
#options
Instance Method Summary
collapse
Methods inherited from Base
description, example, get_object_name, meta, method_added, option, options, summary, syntax
Instance Method Details
#add(*args) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/system/run/commands/ssh.rb', line 30
def add(*args)
name = args[0]
pub_key = args[1]
if name.nil? or pub_key.nil?
puts "Argument Error".red
puts "Usage".yellow
puts "$ oc ssh add [KEY_NAME] [KEY_PUB]".yellow
else
result = barge.key.create({
:name => name,
:public_key => pub_key
})
if !result.success?
puts "#{result.message}".red
else
puts "SSH Key Added".green
end
end
end
|
#destroy(*args) ⇒ Object
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/system/run/commands/ssh.rb', line 108
def destroy(*args)
id = args[0]
if id.nil?
puts "Argument Error".red
puts "Usage".yellow
puts "$ oc ssh destroy [KEY_ID]".yellow
else
raise ArgumentError, "Argument Error - #{id}" unless id =~ /\A[-+]?[0-9]*\.?[0-9]+\Z/
result = barge.key.destroy(id)
if !result.success?
puts "#{result.message}".red
else
puts "SSH Key Deleted".green
end
end
end
|
#keys ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/system/run/commands/ssh.rb', line 6
def keys
result = barge.key.all
if !result.success?
puts "Error: Please check your information".red
else
puts "Your SSH Keys".yellow
rows = []
rows << [
'ID',
'Name'
]
result.ssh_keys.each do |key|
rows << [
key["id"],
key["name"].red,
]
end
table = Terminal::Table.new :rows => rows
puts table
end
end
|
#show(*args) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/system/run/commands/ssh.rb', line 52
def show(*args)
id = args[0]
if id.nil?
puts "Argument Error".red
puts "Usage".yellow
puts "$ oc ssh show [KEY_ID]".yellow
else
raise ArgumentError, "Argument Error - #{id}" unless id =~ /\A[-+]?[0-9]*\.?[0-9]+\Z/
result = barge.key.show(id)
if !result.success?
puts "#{result.message}".red
else
puts "SSH Keys".yellow
rows = []
rows << [
'ID',
'Name'
]
key = result.ssh_key
rows << [
key.id,
key.name.to_s.red
]
table = Terminal::Table.new :rows => rows
puts table
end
end
end
|
#update(*args) ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/system/run/commands/ssh.rb', line 84
def update(*args)
id = args[0]
name = args[1]
pub_key = args[2]
if id.nil? or name.nil? or pub_key.nil?
puts "Argument Error".red
puts "Usage".yellow
puts "$ oc ssh edit [KEY_ID] [KEY_NAME] [KEY_PUB]".yellow
else
raise ArgumentError, "Argument Error - #{id}" unless id =~ /\A[-+]?[0-9]*\.?[0-9]+\Z/
result = barge.key.update(id, {
:name => name,
:public_key => pub_key
})
if !result.success?
puts "#{result.message}".red
else
puts "SSH Key Edited".green
end
end
end
|