xencap 1.0.0 → 1.1.0

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.
@@ -17,8 +17,8 @@ class Xencap::SessionProxy::Vm < Xencap::SessionProxy
17
17
  end
18
18
 
19
19
  def get_vms
20
- get_all_records.reject do |vm|
21
- vm['is_a_template'] || vm['is_control_domain']
20
+ get_all_records.reject do |vm, params|
21
+ params['is_a_template'] || params['is_control_domain']
22
22
  end
23
23
  end
24
24
 
data/lib/xencap/tasks.rb CHANGED
@@ -31,6 +31,35 @@ Capistrano::Configuration.instance.load do
31
31
  xencap.session.setup
32
32
  xencap_plugin.vm.get_all_records.reject {|ref, record| record['is_a_template'] || record['is_control_domain'] }.values.each {|v| puts v['name_label'] }
33
33
  end
34
+
35
+ task :vnc_tunnel do
36
+ xencap.session.setup
37
+ ip = xencap_server_uri.gsub(%r{^https?://}, '')
38
+
39
+ vms = xencap_plugin.vm.get_vms.inject({}) do |out, (vm_ref, params)|
40
+ dom_id = params["domid"]
41
+ out.merge({vm_ref => {:name => params["name_label"], :dom_id => params["domid"]}})
42
+ end
43
+
44
+ puts "VMs"
45
+ vms.each do |vm, params|
46
+ puts " #{params[:dom_id]}: #{params[:name]}"
47
+ end
48
+ puts "Which server would you like to connect to? "
49
+ choice = $stdin.gets.chomp
50
+
51
+ valid_choice = vms.map {|vm, params| params[:dom_id]}.include?(choice)
52
+ if valid_choice
53
+ cmd = "ssh root@#{ip} 'xenstore-read /local/domain/#{choice.to_i}/console/vnc-port'"
54
+ port = `#{cmd}`.chomp
55
+ puts "Establishing tunnel to VNC server."
56
+ puts "Use your VNC client to connec to: localhost:#{port}"
57
+ puts "Kill (^c) this when you're done."
58
+ `ssh -N -L #{port}:localhost:#{port} root@#{ip}`
59
+ else
60
+ puts "ERROR: No such VM"
61
+ end
62
+ end
34
63
  end
35
64
  end
36
65
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xencap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-01 00:00:00.000000000 Z
12
+ date: 2014-02-02 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Should work with any xen system that uses XAPI (including XenServer &
15
15
  XCP)