OSDN Git Service

Add container definition JSON writer.
authorTatsuki Sugiura <sugi@nemui.org>
Mon, 30 Sep 2019 04:06:17 +0000 (13:06 +0900)
committerTatsuki Sugiura <sugi@nemui.org>
Mon, 30 Sep 2019 04:06:17 +0000 (13:06 +0900)
create-image

index 96a4ead..f110622 100755 (executable)
@@ -3,6 +3,7 @@ require 'pp'
 require 'shellwords'
 require 'tmpdir'
 require 'yaml'
+require 'json'
 
 class SyncDirDef
   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
     end
   end
 
+  def write_json
+    jdef = []
+    dirs.each_with_index do |dir, idx|
+      jdef.push({
+        "Description" => dir.path == '/' ? 'root' : dir.path[1..-1].tr('/', '-'),
+        "Format" => "raw",
+        "UserBucket" => {
+          "S3Bucket" => "Change-to-your-buket-name",
+          "S3Key" => "/src-disks/#{img_path_base}_#{idx}.img"
+        }
+      })
+    end
+    File.write "#{img_path_base}.json", JSON.pretty_generate(jdef)
+  end
+
+
   def run
     create_disk
     create_fs
     sync_dirs
     fix_boot
+    write_json
     puts "Image creation has been complated (#{name})"
   end
-
 end
 
 if $0 == __FILE__