itchy 0.2.5 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/itchy +69 -18
- data/config/itchy.yml +2 -1
- data/lib/itchy/format_converter.rb +6 -2
- data/lib/itchy/image_transformer.rb +7 -4
- data/lib/itchy/version.rb +1 -1
- data/lib/itchy.rb +3 -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: fdda0b2aa4e9eb5cc2ea91f70fac7563a84549dd
|
4
|
+
data.tar.gz: a0af4183e2155fc184c60dec6dbbf6bfb845d703
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7443a124bc70d22664b774c31ebc5e2da9b773b136c0b8a335365478f5813cb27224f152a0272dc1a098a79717cbdb0c99802ec20f4cf370b80176dfc3bd2d07
|
7
|
+
data.tar.gz: c3c4bc6f42d601077ca9f91390ae9ec77e335fa0819f407bb28e969cb345b021d3318958b1fd02871304ced73a833c7394c429abb51be3d75a8414c4f20fd93a
|
data/bin/itchy
CHANGED
@@ -47,12 +47,25 @@ class ItchyRunnable < Thor
|
|
47
47
|
end
|
48
48
|
|
49
49
|
desc 'archive', 'Handle an incoming vmcatcher event and store it for further processing'
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
50
|
+
|
51
|
+
method_option :metadata_dir,
|
52
|
+
type: :string,
|
53
|
+
default: Itchy::Settings.metadata_dir,
|
54
|
+
aliases: '-m',
|
55
|
+
desc: 'Path to a metadata directory for storing events, must be writable'
|
56
|
+
|
57
|
+
method_option :log_to,
|
58
|
+
type: :string,
|
59
|
+
default: Itchy::Settings.log_to.archive_log,
|
60
|
+
aliasses: '-l',
|
61
|
+
desc: 'Logging output, file path or stderr/stdout'
|
62
|
+
|
63
|
+
method_option :file_permissions,
|
64
|
+
type: :string,
|
65
|
+
default: Itchy::Settings['permissions']['file'],
|
66
|
+
aliases: '-p',
|
67
|
+
desc: 'Sets permissions for all created files'
|
68
|
+
|
56
69
|
method_option *shared_option_log_level
|
57
70
|
method_option *shared_option_debug
|
58
71
|
|
@@ -71,18 +84,56 @@ class ItchyRunnable < Thor
|
|
71
84
|
end
|
72
85
|
|
73
86
|
desc 'process', 'Process stored events'
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
87
|
+
|
88
|
+
method_option :metadata_dir,
|
89
|
+
type: :string,
|
90
|
+
default: Itchy::Settings.metadata_dir,
|
91
|
+
aliases: '-m',
|
92
|
+
desc: 'Path to a metadata directory for stored events'
|
93
|
+
|
94
|
+
method_option :required_format,
|
95
|
+
type: :string,
|
96
|
+
default: Itchy::Settings.output_image_format,
|
97
|
+
aliases: '-f',
|
98
|
+
desc: 'Required output format of converted images'
|
99
|
+
|
100
|
+
method_option :output_dir,
|
101
|
+
type: :string,
|
102
|
+
default: Itchy::Settings.output_dir,
|
103
|
+
aliases: '-o',
|
104
|
+
desc: 'Path to a directory where processed events descriptors will be stored'
|
105
|
+
|
106
|
+
method_option :temp_image_dir,
|
107
|
+
type: :string,
|
108
|
+
default: Itchy::Settings.temp_image_dir,
|
109
|
+
aliases: '-t',
|
110
|
+
desc: 'Path to a directory where images will be temporary stored while being processed'
|
111
|
+
|
112
|
+
method_option :descriptor_dir,
|
113
|
+
type: :string,
|
114
|
+
default: Itchy::Settings.descriptor_dir,
|
115
|
+
aliases: '-e',
|
116
|
+
desc: 'Path to a directory where appliance descriptors will be stored'
|
117
|
+
|
118
|
+
method_option :file_permissions,
|
119
|
+
type: :string,
|
120
|
+
default: Itchy::Settings['permissions']['file'],
|
121
|
+
aliases: '-p',
|
122
|
+
desc: 'Sets permissions for all created files'
|
123
|
+
|
124
|
+
method_option :log_to,
|
125
|
+
type: :string,
|
126
|
+
default: Itchy::Settings.log_to.process_log,
|
127
|
+
aliases: '-l',
|
128
|
+
desc: 'Logging output, file path or stderr/stdout'
|
129
|
+
|
130
|
+
|
131
|
+
method_option :qemu_img_binary,
|
132
|
+
type: :string,
|
133
|
+
default: Itchy::Settings['qemu_img_binary'],
|
134
|
+
aliases: '-q',
|
135
|
+
desc: 'Path to qemu-img command binary, if not used, ITCHY will look for it in PATH'
|
136
|
+
|
86
137
|
method_option *shared_option_log_level
|
87
138
|
method_option *shared_option_debug
|
88
139
|
|
data/config/itchy.yml
CHANGED
@@ -3,6 +3,7 @@ defaults: &defaults
|
|
3
3
|
metadata_dir: /var/spool/itchy/metadata
|
4
4
|
output_dir: /var/spool/itchy/output
|
5
5
|
descriptor_dir: /var/spool/itchy/descriptors
|
6
|
+
temp_image_dir: /var/spool/itchy/temp
|
6
7
|
log_to:
|
7
8
|
archive_log: /var/log/itchy/archive.log
|
8
9
|
process_log: /var/log/itchy/process.log
|
@@ -11,7 +12,7 @@ defaults: &defaults
|
|
11
12
|
permissions:
|
12
13
|
file: '0664'
|
13
14
|
output_image_format: qcow2
|
14
|
-
qemu_img_binary:
|
15
|
+
#qemu_img_binary: # When used, ITCHY will use this binary to run qemu-img command (converting images)
|
15
16
|
|
16
17
|
###############################################
|
17
18
|
####### DO NOT EDIT AFTER THIS POINT ########
|
@@ -1,12 +1,15 @@
|
|
1
1
|
module Itchy
|
2
2
|
# Converting different image formats
|
3
3
|
class FormatConverter
|
4
|
+
|
5
|
+
|
4
6
|
# Creates and converter instance for converting image to requried format
|
5
7
|
#
|
6
8
|
# @param unpacking_dir [String] path to directory where image is stored
|
7
9
|
# @param metadata [VmcatcherEvent] metadata of event corresponding to image
|
8
10
|
# @param vmcatcher_configuration [VmcatcherConfiguration] vmcatcher configuration
|
9
11
|
def initialize(unpacking_dir, metadata, vmcatcher_configuration)
|
12
|
+
|
10
13
|
unless vmcatcher_configuration.is_a?(Itchy::VmcatcherConfiguration)
|
11
14
|
fail ArgumentError, '\'vmcatcher_configuration\' must be an instance of ' \
|
12
15
|
'Itchy::VmcatcherConfiguration!'
|
@@ -22,14 +25,15 @@ module Itchy
|
|
22
25
|
# @param file_format [String] actual format of the image
|
23
26
|
# @param required_format [String] required format
|
24
27
|
# @param output_dir [String] path to a directory where converted image should be stored
|
25
|
-
def convert!(file_format, required_format, output_dir)
|
28
|
+
def convert!(file_format, required_format, output_dir, qemu_img_binary)
|
26
29
|
Itchy::Log.info "[#{self.class.name}] Converting image " \
|
27
30
|
"#{@metadata.dc_identifier.inspect} from " \
|
28
31
|
"original format: #{file_format} to " \
|
29
32
|
"required format: #{required_format}."
|
30
33
|
|
31
34
|
new_file_name = "#{::Time.now.to_i}_#{@metadata.dc_identifier}"
|
32
|
-
|
35
|
+
qemu_command = qemu_img_binary || Itchy::BASIC_QEMU_COMMAND
|
36
|
+
convert_cmd = Mixlib::ShellOut.new("#{qemu_command} convert -f #{file_format} -O #{required_format} #{@unpacking_dir}/#{@metadata.dc_identifier} #{output_dir}/#{new_file_name}")
|
33
37
|
convert_cmd.run_command
|
34
38
|
begin
|
35
39
|
convert_cmd.error!
|
@@ -46,7 +46,7 @@ module Itchy
|
|
46
46
|
new_file_name = copy_same_format(unpacking_dir, metadata)
|
47
47
|
else
|
48
48
|
converter = Itchy::FormatConverter.new(unpacking_dir, metadata, vmcatcher_configuration)
|
49
|
-
new_file_name = converter.convert!(file_format, @options.required_format, @options.output_dir)
|
49
|
+
new_file_name = converter.convert!(file_format, @options.required_format, @options.output_dir, @options.qemu_img_binary)
|
50
50
|
end
|
51
51
|
remove_dir(unpacking_dir)
|
52
52
|
rescue Itchy::Errors::FileInspectError, Itchy::Errors::FormatConversionError,
|
@@ -64,7 +64,10 @@ module Itchy
|
|
64
64
|
# @param unpacking_dir [String] name and path of the checked file
|
65
65
|
# @return [String] image format
|
66
66
|
def format(file)
|
67
|
-
|
67
|
+
|
68
|
+
qemu_command = @options.qemu_img_binary || Itchy::BASIC_QEMU_COMMAND
|
69
|
+
|
70
|
+
image_format_tester = Mixlib::ShellOut.new("#{qemu_command} info #{file}")
|
68
71
|
image_format_tester.run_command
|
69
72
|
begin
|
70
73
|
image_format_tester.error!
|
@@ -119,7 +122,7 @@ module Itchy
|
|
119
122
|
dir = Dir.new directory
|
120
123
|
counter = 0
|
121
124
|
files = dir['*']
|
122
|
-
files
|
125
|
+
files.each do |file|
|
123
126
|
file_format = format("#{directory}/#{file}")
|
124
127
|
if KNOWN_IMAGE_FORMATS.include? file_format
|
125
128
|
counter += 1
|
@@ -202,7 +205,7 @@ module Itchy
|
|
202
205
|
# @param vmcatcher_configuration [Itchy::VmcatcherConfiguration] current VMC configuration
|
203
206
|
# @return [String] path to the newly created image directory
|
204
207
|
def prepare_image_temp_dir(metadata, vmcatcher_configuration)
|
205
|
-
temp_dir = "#{
|
208
|
+
temp_dir = "#{@options.temp_image_dir}/#{metadata.dc_identifier}"
|
206
209
|
|
207
210
|
begin
|
208
211
|
::FileUtils.mkdir_p temp_dir
|
data/lib/itchy/version.rb
CHANGED
data/lib/itchy.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itchy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lubomir Kosaristan
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-03-
|
12
|
+
date: 2016-03-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: opennebula
|