libvirtinator 0.1.5 → 0.1.6
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.
data/lib/libvirtinator/config.rb
CHANGED
@@ -15,7 +15,7 @@ end
|
|
15
15
|
|
16
16
|
namespace :libvirtinator do
|
17
17
|
task :load_settings do
|
18
|
-
load "./config/deploy.rb"
|
18
|
+
# load "./config/deploy.rb" # this seems unneeded and to cause tasks to run twice, previously i thought it was needed
|
19
19
|
SSHKit.config.output_verbosity = fetch(:log_level)
|
20
20
|
end
|
21
21
|
|
@@ -53,9 +53,6 @@ set :vmbuilder_run_command, -> {
|
|
53
53
|
|
54
54
|
## Settings that shouldn't need changed:
|
55
55
|
set :nbd_run_file, -> { "/var/lock/#{fetch(:node_name)}.nbd" }
|
56
|
-
set :nbd_lock_file, -> { "/var/lock/qemu-nbd-#{fetch(:nbd)}" }
|
57
|
-
set :dev_nbd, -> { "/dev/#{fetch(:nbd)}" }
|
58
|
-
set :dev_nbdp1, -> { "/dev/#{fetch(:nbd)}p1" }
|
59
56
|
set :dns_nameservers, -> { fetch("#{fetch(:host_machine_name)}_dns_nameservers") }
|
60
57
|
set :bridge, -> { fetch("#{fetch(:host_machine_name)}_bridge") }
|
61
58
|
set :root_partitions_path, -> { fetch("#{fetch(:host_machine_name)}_root_partitions_path") }
|
data/lib/libvirtinator/image.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
set :nbd_lock_file, -> { "/var/lock/qemu-nbd-#{fetch(:nbd)}" } # auto-created by qemu-nbd -c
|
2
|
+
set :dev_nbd, -> { "/dev/#{fetch(:nbd)}" }
|
3
|
+
set :dev_nbdp1, -> { "/dev/#{fetch(:nbd)}p1" }
|
4
|
+
|
1
5
|
namespace :image do
|
2
6
|
desc "Build a base qcow2 image."
|
3
7
|
task :build_base => 'libvirtinator:load_settings' do
|
@@ -32,17 +36,16 @@ namespace :image do
|
|
32
36
|
on roles(:app) do
|
33
37
|
as :root do
|
34
38
|
if test "[", "-f", fetch(:nbd_run_file), "]"
|
35
|
-
|
36
|
-
|
39
|
+
if test "[", "-f", fetch(:nbd_lock_file), "]"
|
40
|
+
raise "nbd run and lock files already exist. Are they already connected?"
|
41
|
+
else
|
42
|
+
if test "mountpoint", "-q", fetch(:mount_point)
|
43
|
+
raise "#{fetch(:mount_point)} is already a mountpoint!"
|
44
|
+
else
|
37
45
|
info "Removing leftover run file"
|
38
46
|
execute "rm", fetch(:nbd_run_file), "-f"
|
39
|
-
unless test "[", "-f", fetch(:nbd_run_file), "]"
|
40
|
-
Rake::Task['image:mount'].reenable
|
41
|
-
return Rake::Task['image:mount'].invoke
|
42
|
-
end
|
43
47
|
end
|
44
48
|
end
|
45
|
-
raise "nbd run file already exists. is it already connected?"
|
46
49
|
end
|
47
50
|
info "Mounting #{fetch(:root_image_path)} on #{fetch(:mount_point)}"
|
48
51
|
set :nbd_connected, false
|
@@ -64,7 +67,7 @@ namespace :image do
|
|
64
67
|
on roles(:app) do
|
65
68
|
as :root do
|
66
69
|
if test "[", "-f", fetch(:nbd_run_file), "]"
|
67
|
-
info "
|
70
|
+
info "Found #{fetch(:nbd_run_file)}"
|
68
71
|
else
|
69
72
|
info "Unable to read #{fetch(:nbd_run_file)}"
|
70
73
|
end
|
@@ -113,27 +116,30 @@ namespace :image do
|
|
113
116
|
task :connect_to_unused_nbd => 'libvirtinator:load_settings' do
|
114
117
|
on roles(:app) do
|
115
118
|
as :root do
|
116
|
-
|
119
|
+
raise "Error: #{fetch(:root_image_path)} not found!" unless test "[", "-f", fetch(:root_image_path), "]"
|
117
120
|
begin
|
118
|
-
|
119
|
-
set :
|
121
|
+
set :nbd, -> { "nbd#{rand(16)}" }
|
122
|
+
set :nbd_lock_file, -> { "/var/lock/qemu-nbd-#{fetch(:nbd)}" }
|
123
|
+
set :dev_nbd, -> { "/dev/#{fetch(:nbd)}" }
|
124
|
+
set :dev_nbdp1, -> { "/dev/#{fetch(:nbd)}p1" }
|
125
|
+
set :prelock, -> { "#{fetch(:nbd_lock_file)}.prelock" }
|
120
126
|
info "Randomly trying the #{fetch(:nbd)} network block device"
|
121
127
|
if test "[", "-f", fetch(:prelock), "]"
|
122
128
|
info "Another process is checking #{fetch(:nbd)}. Trying again..."
|
123
129
|
set :nbd_connected, false
|
124
|
-
|
130
|
+
next
|
125
131
|
else
|
126
132
|
execute "touch", fetch(:prelock)
|
127
133
|
info "Checking for qemu-nbd created lock file"
|
128
134
|
if test "[", "-f", fetch(:nbd_lock_file), "]"
|
129
135
|
info "#{fetch(:dev_nbd)} lockfile already in place - nbd device may be in use. Trying again..."
|
130
136
|
set :nbd_connected, false
|
131
|
-
|
137
|
+
next
|
132
138
|
end
|
133
139
|
if test "[", "-b", fetch(:dev_nbdp1), "]"
|
134
140
|
info "nbd device in use but no lockfile, Trying again..."
|
135
141
|
set :nbd_connected, false
|
136
|
-
|
142
|
+
next
|
137
143
|
end
|
138
144
|
info "Found unused block device"
|
139
145
|
|
@@ -151,7 +157,7 @@ namespace :image do
|
|
151
157
|
rescue TimeoutError
|
152
158
|
fatal "Error: unable to create block dev #{fetch(:dev_nbd)}, trying again..."
|
153
159
|
set :nbd_connected, false
|
154
|
-
|
160
|
+
next
|
155
161
|
#raise "unable to create block device #{fetch(:dev_nbd)}"
|
156
162
|
end
|
157
163
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libvirtinator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
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: 2016-
|
12
|
+
date: 2016-03-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|