forked from auser/poolparty
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcloud-vnc
39 lines (31 loc) · 1.21 KB
/
cloud-vnc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env ruby
$:.unshift(File.dirname(__FILE__) + "/../lib")
require "poolparty"
require 'git-style-binary/command'
GitStyleBinary.command do
banner <<-EOS
Usage: #{$0} #{all_options_string}
start a vnc server and create an ssh tunnel
EOS
short_desc "ssh into an instance of the cloud"
opt :instance_number, "Start VNC server on this instance number", :type => :integer, :default => 0
opt :local_port, "The local port to tunnel to", :type => :integer, :default => 5900
opt :display, "The remote display number to start the VNC Server on", :type => :integer, :default => 0
run do |command|
cloud = @loaded_clouds.first
if !cloud.nodes.empty?
inst = cloud.nodes[command[:instance_number]]
if inst
inst.ssh(["x11vnc -localhost -nopw -display :#{command[:display]}"],
{'-X' => nil,
'-C' => nil,
' -o' => 'UserKnownHostsFile=/dev/null',
'-L' => "#{command[:local_port]}:localhost:5900"})
else
puts("Error: The instance number (#{command[:instance_number]}) is too high for the current number of instances")
end
else
puts "No running instances can be found"
end
end
end