From 7cbc50ba5b433400bc66ecf88818059949619960 Mon Sep 17 00:00:00 2001 From: John Lewis Date: Sun, 2 Dec 2012 22:14:04 -0500 Subject: [PATCH 1/2] Added vnc.on command Allow vnc to be turned on without bringing up vnc client --- lib/rvc/modules/vnc.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/rvc/modules/vnc.rb b/lib/rvc/modules/vnc.rb index 8892bdc..9f68de8 100644 --- a/lib/rvc/modules/vnc.rb +++ b/lib/rvc/modules/vnc.rb @@ -31,6 +31,18 @@ rvc_alias :view, :V def view vm + vnc_hash = on vm + vnc_client vnc_hash[:ip], vnc_hash[:port], vnc_hash[:password] +end + + +opts :on do + summary "Enable VNC server" + arg :vm, nil, :lookup => VIM::VirtualMachine + opt :print_password, false +end + +def on vm, opts ip = reachable_ip vm.collect('runtime.host')[0] extraConfig, = vm.collect('config.extraConfig') already_enabled = extraConfig.find { |x| x.key == 'RemoteDisplay.vnc.enabled' && x.value.downcase == 'true' } @@ -49,7 +61,8 @@ def view vm ] }).wait_for_completion end - vnc_client ip, port, password + puts "#{ip}:#{port} password: #{password}" if opts[:print_password] + {:ip => ip, :port => port, :password => password} end From c918fb379fe6dd1dc4149f10d47036be22e91e6b Mon Sep 17 00:00:00 2001 From: John Lewis Date: Mon, 3 Dec 2012 21:52:11 -0500 Subject: [PATCH 2/2] Fixed issue with number of arguments passed in --- lib/rvc/modules/vnc.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rvc/modules/vnc.rb b/lib/rvc/modules/vnc.rb index 9f68de8..894816b 100644 --- a/lib/rvc/modules/vnc.rb +++ b/lib/rvc/modules/vnc.rb @@ -31,7 +31,7 @@ rvc_alias :view, :V def view vm - vnc_hash = on vm + vnc_hash = on vm, {} vnc_client vnc_hash[:ip], vnc_hash[:port], vnc_hash[:password] end