Class: Kytoon::ThorTasks
- Inherits:
-
Thor
- Object
- Thor
- Kytoon::ThorTasks
- Defined in:
- lib/kytoon/thor_tasks.rb
Instance Method Summary collapse
- #create(options = (options or {})) ⇒ Object
- #delete(options = (options or {})) ⇒ Object
- #ip(options = (options or {})) ⇒ Object
- #list(options = (options or {})) ⇒ Object
- #show(options = (options or {})) ⇒ Object
- #ssh(options = (options or {})) ⇒ Object
Instance Method Details
#create(options = (options or {})) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/kytoon/thor_tasks.rb', line 10 def create(=( or {})) begin ServerGroup.init([:group_type]) sg = ServerGroup.create([:group_config]) puts "Server group ID #{sg.id} created." rescue KytoonException => ke puts ke. end end |
#delete(options = (options or {})) ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/kytoon/thor_tasks.rb', line 47 def delete(=( or {})) begin ServerGroup.init([:group_type]) sg = ServerGroup.get([:group_id]) sg.delete SshUtil.remove_known_hosts_ip(sg.gateway_ip) rescue KytoonException => ke puts ke. end end |
#ip(options = (options or {})) ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/kytoon/thor_tasks.rb', line 61 def ip(=( or {})) begin ServerGroup.init([:group_type]) sg = ServerGroup.get([:group_id]) puts sg.gateway_ip rescue KytoonException => ke puts ke. end end |
#list(options = (options or {})) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/kytoon/thor_tasks.rb', line 22 def list(=( or {})) begin ServerGroup.init([:group_type]) ServerGroup.index() rescue KytoonException => ke puts ke. end end |
#show(options = (options or {})) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/kytoon/thor_tasks.rb', line 34 def show(=( or {})) begin ServerGroup.init([:group_type]) sg = ServerGroup.get([:group_id]) sg.pretty_print rescue KytoonException => ke puts ke. end end |
#ssh(options = (options or {})) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/kytoon/thor_tasks.rb', line 74 def ssh(=( or {})) begin ServerGroup.init([:group_type]) args=ARGV[1, ARGV.length].join(" ") sg = ServerGroup.get([:group_id]) if (ARGV[1] and ARGV[1] =~ /^--group_id.*/) and (ARGV[2] and ARGV[2] =~ /^--group_id.*/) args=ARGV[3, ARGV.length].join(" ") elsif ARGV[1] and ARGV[1] =~ /^--group_id.*/ args=ARGV[2, ARGV.length].join(" ") end exec("ssh -o \"StrictHostKeyChecking no\" root@#{sg.gateway_ip} #{args}") rescue KytoonException => ke puts ke. end end |