cangallo 0.0.1 → 0.0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cangallo/libguestfs.rb +53 -7
- data/lib/cangallo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b90c4e1c69b4114fbdc225c7d0af0b7d2ef6fdd
|
4
|
+
data.tar.gz: 0cd1c440f093931313e562a730a8fb51e48e718e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df8fbdcdfe22afed9e21af5200615213d58b7c77b93076dc3560f8d6a631afad502f34bbad7d45f48e0d5e2bb9923ed1f1ca98c477bfbe2eb1dc80efbb775abf
|
7
|
+
data.tar.gz: 3d36c90229f184f55bfaf6a0faa6c66e90d8d2e2916adaedb796def36475d2d517302dae72456e61a322c0739bb4c406a9e30b1cc9060404d71d5995e1c62c1e
|
data/lib/cangallo/libguestfs.rb
CHANGED
@@ -19,20 +19,54 @@ require 'json'
|
|
19
19
|
require 'systemu'
|
20
20
|
require 'tempfile'
|
21
21
|
require 'fileutils'
|
22
|
+
require 'shellwords'
|
23
|
+
require 'rubygems'
|
22
24
|
|
23
25
|
class Cangallo
|
24
26
|
|
25
27
|
class LibGuestfs
|
26
28
|
def self.virt_customize(image, commands, params = "")
|
27
|
-
|
29
|
+
version = self.version
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
+
if !version
|
32
|
+
raise "Could not get virt-customize version"
|
33
|
+
end
|
31
34
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
35
|
+
target_version = Gem::Version.new('1.30')
|
36
|
+
current_version = Gem::Version.new(version)
|
37
|
+
good_version = false
|
38
|
+
|
39
|
+
customize_command = nil
|
40
|
+
|
41
|
+
good_version = true if current_version >= target_version
|
42
|
+
|
43
|
+
if good_version
|
44
|
+
cmd_file = Tempfile.new("canga")
|
45
|
+
|
46
|
+
cmd_file.puts(commands)
|
47
|
+
cmd_file.close
|
48
|
+
|
49
|
+
customize_command = "virt-customize -a #{image} #{params.join(" ")} " <<
|
50
|
+
"--commands-from-file #{cmd_file.path}"
|
51
|
+
else
|
52
|
+
cmd_params = commands.map do |line|
|
53
|
+
m = line.match(/^([^\s]+)\s+(.*)$/)
|
54
|
+
if m
|
55
|
+
"--" + m[1] + " " + Shellwords.escape(m[2].strip)
|
56
|
+
else
|
57
|
+
nil
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
cmd_params.compact!
|
62
|
+
|
63
|
+
customize_command = "virt-customize -a #{image} #{params.join(" ")} " <<
|
64
|
+
"#{cmd_params.join(" ")}"
|
65
|
+
end
|
66
|
+
|
67
|
+
rc = system(customize_command)
|
68
|
+
|
69
|
+
cmd_file.unlink if good_version
|
36
70
|
|
37
71
|
return rc
|
38
72
|
end
|
@@ -42,5 +76,17 @@ class Cangallo
|
|
42
76
|
|
43
77
|
return rc
|
44
78
|
end
|
79
|
+
|
80
|
+
def self.version
|
81
|
+
str = `virt-customize --version`
|
82
|
+
|
83
|
+
m = str.match(/^virt-customize (.*)$/)
|
84
|
+
|
85
|
+
if m
|
86
|
+
m[1]
|
87
|
+
else
|
88
|
+
nil
|
89
|
+
end
|
90
|
+
end
|
45
91
|
end
|
46
92
|
end
|
data/lib/cangallo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cangallo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1
|
4
|
+
version: 0.0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Javier Fontan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|