-
Notifications
You must be signed in to change notification settings - Fork 1
/
make.py
23 lines (17 loc) · 848 Bytes
/
make.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from glob import glob
import sys, os
import yaml
from lxdimageconverter.utils import download_file, extract_rootfs, make_meta
from lxdimageconverter.lxd import lxd_import_image
from lxdimageconverter.conf import IMAGE_DIR
if __name__ == '__main__':
for file in glob(sys.argv[1]+"/*"):
with open(file) as f:
conf = yaml.safe_load(f)
print(conf)
packed = download_file(conf["url"])
rootfs = extract_rootfs(packed, "%s-%s" % (conf["distribution"], conf["release"]))
make_meta(conf)
lxd_import_image(os.path.join(IMAGE_DIR,"%s-%s-metadata.tar.gz" % (conf["distribution"], conf["release"])),
os.path.join(IMAGE_DIR, "%s-%s-rootfs.tar.gz" % (conf["distribution"], conf["release"])),
"%s/%s" % (conf["distribution"], conf["release"]))