Skip to content

Instantly share code, notes, and snippets.

@drewr
Last active December 15, 2015 04:09
Show Gist options
  • Save drewr/5199337 to your computer and use it in GitHub Desktop.
Save drewr/5199337 to your computer and use it in GitHub Desktop.

Recently I ran into a vmfest issue where I was trying to run setup-model on a Vagrant box. The exception looked like:

   Invalid byte 52 at offset 7 in '12322424' len=8
     [Thrown class java.lang.IllegalArgumentException]
   
   Restarts:
    0: [QUIT] Quit to the SLIME top level
   
   Backtrace:
     0:           TarUtils.java:127 org.apache.commons.compress...
     1:           TarUtils.java:171 org.apache.commons.compress...
     2:    TarArchiveEntry.java:937 org.apache.commons.compress...
     3:    TarArchiveEntry.java:924 org.apache.commons.compress...
     4:    TarArchiveEntry.java:328 org.apache.commons.compress...

Thinking the file had somehow corrupted in transit, I downloaded it again with hardly a second thought. Same error next time. I checked the sha1 for both files and they were identical. I learned that a .box file was simply a tar archive, so I tried /usr/bin/tar and it read the file just fine.

At this point I knew it was likely a Commons Compress incompatibility with the file and I didn't want to bother with it. However, this was an image my team had used with Vagrant and I needed the identical environment. Vagrant tends to cause Virtualbox to be unusable by vmfest (networking-wise), so I didn't want to vagrant up to fleeting convenience.

I settled on registering the model manually. Turned out to be fairly simple. My attempted setup-model invocation looked like this:

    user> (setup-model "/data2/iso/CentOS-6.4-x86_64-v20130309.box" vbox
           :meta {:os-family :centos :os-version 6.4 :os-64-bit true})

setup-model contains a threaded sequence of operations on a map of metadata about the model. First I recreated that map with prepare-job:

    user> (def job (prepare-job "/data2/iso/CentOS-6.4-x86_64-v20130309.box" vbox
                       :meta {:os-family :centos :os-version 6.4 :os-64-bit true}))

At this point, the directory /tmp/vmfest-vmfest-CentOS-6.4-x86_64-v20130309 existed. I needed to extract the contents of the box there.

    % cd /tmp/vmfest-vmfest-CentOS-6.4-x86_64-v20130309
    % tar xvf /data2/iso/CentOS-6.4-x86_64-v20130309.box
    box-disk1.vmdk
    box.ovf
    Vagrantfile
    %

Now, the rest of the sequence in setup-model after threaded-unbox can complete.

    user> (-> job threaded-get-metadata threaded-get-key
                  threaded-register-model threaded-create-meta
                  threaded-cleanup-temp-files)
    {:model-name "CentOS-6.4-x86_64-v20130309"
     :image-name "CentOS-6.4-x86_64-v20130309"
     :model-file "/home/user/.vmfest/models/vmfest-CentOS-6.4-x86_64-v20130309.vmdk"
     ...}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment