xencap 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/xencap/tasks.rb +32 -5
  2. metadata +2 -2
data/lib/xencap/tasks.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  Capistrano::Configuration.instance.load do
2
- set :xencap_server_uri, nil
2
+ set :xencap_server_ip, nil
3
+ set :xencap_server_uri, do
4
+ "http://#{xencap_server_ip}"
5
+ end
3
6
  set :xencap_login, "root"
4
7
  set :xencap_password, do
5
8
  Capistrano::CLI.password_prompt("xen password: ")
@@ -26,6 +29,32 @@ Capistrano::Configuration.instance.load do
26
29
  end
27
30
  end
28
31
 
32
+ namespace :iso_lib do
33
+ task :create, :role => :xenserver do
34
+ xencap.session.setup
35
+ name = "ISO Library"
36
+ run "mkdir -p /var/lib/isos"
37
+
38
+ sr_ref, sr_record = xencap_plugin.sr.find_record(:name_label => name)
39
+ if sr_ref
40
+ puts "#{name}already exists. Exiting."
41
+ exit
42
+ end
43
+
44
+ host_ref, host = xencap_plugin.host.find_all_records.first
45
+
46
+ puts "Creating Storge Repository..."
47
+ sr_ref = xencap_plugin.sr.create(host_ref, {"location" => "/var/lib/isos", "legacy_mode" => "true"}, "1", name, "", "iso", "iso", false)
48
+ puts "Created. Add images to /var/lib/isos/"
49
+ end
50
+
51
+ task :scan do
52
+ xencap.session.setup
53
+ sr_ref, sr_record = xencap_plugin.sr.find_record(:name_label => "ISO Library")
54
+ xencap_plugin.sr.scan(sr_ref)
55
+ end
56
+ end
57
+
29
58
  namespace :vm do
30
59
  task :list do
31
60
  xencap.session.setup
@@ -34,8 +63,6 @@ Capistrano::Configuration.instance.load do
34
63
 
35
64
  task :vnc_tunnel do
36
65
  xencap.session.setup
37
- ip = xencap_server_uri.gsub(%r{^https?://}, '')
38
-
39
66
  vms = xencap_plugin.vm.get_vms.inject({}) do |out, (vm_ref, params)|
40
67
  dom_id = params["domid"]
41
68
  out.merge({vm_ref => {:name => params["name_label"], :dom_id => params["domid"]}})
@@ -50,12 +77,12 @@ Capistrano::Configuration.instance.load do
50
77
 
51
78
  valid_choice = vms.map {|vm, params| params[:dom_id]}.include?(choice)
52
79
  if valid_choice
53
- cmd = "ssh root@#{ip} 'xenstore-read /local/domain/#{choice.to_i}/console/vnc-port'"
80
+ cmd = "ssh root@#{xencap_server_ip} 'xenstore-read /local/domain/#{choice.to_i}/console/vnc-port'"
54
81
  port = `#{cmd}`.chomp
55
82
  puts "Establishing tunnel to VNC server."
56
83
  puts "Use your VNC client to connec to: localhost:#{port}"
57
84
  puts "Kill (^c) this when you're done."
58
- `ssh -N -L #{port}:localhost:#{port} root@#{ip}`
85
+ `ssh -N -L #{port}:localhost:#{port} root@#{xencap_server_ip}`
59
86
  else
60
87
  puts "ERROR: No such VM"
61
88
  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.1.0
4
+ version: 1.2.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-02 00:00:00.000000000 Z
12
+ date: 2014-02-04 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)