Skip to content

Commit

Permalink
Use raw image instead of vhd
Browse files Browse the repository at this point in the history
  • Loading branch information
arianvp committed Apr 19, 2024
1 parent a33d952 commit 159b261
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion upload-ami/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
, python3Packages
, lib
, coldsnap
, qemu
}:

let
Expand Down Expand Up @@ -39,7 +40,7 @@ buildPythonApplication {
];


makeWrapperArgs = [ "--prefix PATH : ${coldsnap}/bin" ];
makeWrapperArgs = [ "--prefix PATH : ${coldsnap}/bin" "--prefix PATH : ${qemu}/bin" ];

propagatedBuildInputs = lib.flatten (map resolvePackages pyproject.project.dependencies);

Expand Down
14 changes: 13 additions & 1 deletion upload-ami/src/upload_ami/upload_coldsnap.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import argparse
from email.mime import image
import json
import logging
from pathlib import Path
from posixpath import basename
from re import I
from tempfile import mktemp
import tempfile
import boto3
import subprocess
from typing import Literal, TypedDict
Expand Down Expand Up @@ -93,12 +98,19 @@ def upload_coldsnap(
) -> str:
logging.info(f"Uploading image to coldsnap")

image_file_vhd = Path(image_info["file"])
image_file_raw = image_file_vhd.with_suffix(".raw")

subprocess.check_call(
[ "qemu-img" , "convert", "-O", "raw", image_file_vhd, image_file_raw ]
)

snapshot_id = subprocess.check_output(
[
"coldsnap",
"upload",
"--wait",
image_info["file"],
image_file_raw,
]
).decode().strip()

Expand Down

0 comments on commit 159b261

Please sign in to comment.