KVM host image creator.Jessica Lockwood
修訂 | d871eb2a6136d0068990ce2bcc0817aa012d4746 (tree) |
---|---|
時間 | 2019-09-30 13:06:17 |
作者 | Tatsuki Sugiura <sugi@nemu...> |
Commiter | Tatsuki Sugiura |
Add container definition JSON writer.
@@ -3,6 +3,7 @@ require 'pp' | ||
3 | 3 | require 'shellwords' |
4 | 4 | require 'tmpdir' |
5 | 5 | require 'yaml' |
6 | +require 'json' | |
6 | 7 | |
7 | 8 | class SyncDirDef |
8 | 9 | DEFAULT_EXCLUDE = %w[/proc/* /sys/* /dev/mqueue /dev/hugepages /run/* /var/lib/os-prober/mount /swap /dev/shm/* /var/lib/lxcfs/*] |
@@ -164,14 +165,30 @@ class ImageCreator | ||
164 | 165 | end |
165 | 166 | end |
166 | 167 | |
168 | + def write_json | |
169 | + jdef = [] | |
170 | + dirs.each_with_index do |dir, idx| | |
171 | + jdef.push({ | |
172 | + "Description" => dir.path == '/' ? 'root' : dir.path[1..-1].tr('/', '-'), | |
173 | + "Format" => "raw", | |
174 | + "UserBucket" => { | |
175 | + "S3Bucket" => "Change-to-your-buket-name", | |
176 | + "S3Key" => "/src-disks/#{img_path_base}_#{idx}.img" | |
177 | + } | |
178 | + }) | |
179 | + end | |
180 | + File.write "#{img_path_base}.json", JSON.pretty_generate(jdef) | |
181 | + end | |
182 | + | |
183 | + | |
167 | 184 | def run |
168 | 185 | create_disk |
169 | 186 | create_fs |
170 | 187 | sync_dirs |
171 | 188 | fix_boot |
189 | + write_json | |
172 | 190 | puts "Image creation has been complated (#{name})" |
173 | 191 | end |
174 | - | |
175 | 192 | end |
176 | 193 | |
177 | 194 | if $0 == __FILE__ |