Compare commits
No commits in common. "856675180980c9cae51a92a4d4eaccea2e1a2d6d" and "4d2439c25072b638b6abd7a97c5fd6c082527633" have entirely different histories.
8566751809
...
4d2439c250
|
@ -16,17 +16,14 @@ except:
|
||||||
from .utils import _
|
from .utils import _
|
||||||
|
|
||||||
|
|
||||||
DATASET_PATH = '/usr/share/risotto/'
|
DATASET_PATH = ''
|
||||||
TMP_DIRECTORY = '/tmp'
|
TMP_DIRECTORY = '/tmp'
|
||||||
PACKER_TMP_DIRECTORY = join(TMP_DIRECTORY, 'packer')
|
PACKER_TMP_DIRECTORY = join(TMP_DIRECTORY, 'packer')
|
||||||
PACKER_FILE_NAME = 'recipe.json'
|
PACKER_FILE_NAME = 'recipe.json'
|
||||||
IMAGES_DIRECTORY = join(TMP_DIRECTORY, 'images')
|
IMAGES_DIRECTORY = join(TMP_DIRECTORY, 'images')
|
||||||
|
|
||||||
|
|
||||||
FUNCTIONS = b"""try:
|
FUNCTIONS = b"""from tiramisu import valid_network_netmask, valid_ip_netmask, valid_broadcast, valid_in_network, valid_not_equal as valid_differ, valid_not_equal, calc_value
|
||||||
from tiramisu3 import valid_network_netmask, valid_ip_netmask, valid_broadcast, valid_in_network, valid_not_equal as valid_differ, valid_not_equal, calc_value
|
|
||||||
except:
|
|
||||||
from tiramisu import valid_network_netmask, valid_ip_netmask, valid_broadcast, valid_in_network, valid_not_equal as valid_differ, valid_not_equal, calc_value
|
|
||||||
# =============================================================
|
# =============================================================
|
||||||
# fork of risotto-setting/src/risotto_setting/config/config.py
|
# fork of risotto-setting/src/risotto_setting/config/config.py
|
||||||
def get_password(**kwargs):
|
def get_password(**kwargs):
|
||||||
|
@ -171,6 +168,7 @@ class Image:
|
||||||
if not isdir(funcs_dir):
|
if not isdir(funcs_dir):
|
||||||
continue
|
continue
|
||||||
for func in listdir(funcs_dir):
|
for func in listdir(funcs_dir):
|
||||||
|
print(join(funcs_dir, func))
|
||||||
with open(join(funcs_dir, func), 'rb') as fh:
|
with open(join(funcs_dir, func), 'rb') as fh:
|
||||||
functions += fh.read()
|
functions += fh.read()
|
||||||
func_name = join(packer_tmp_directory, 'func.py')
|
func_name = join(packer_tmp_directory, 'func.py')
|
||||||
|
@ -253,12 +251,14 @@ class Image:
|
||||||
|
|
||||||
def build_image(self,
|
def build_image(self,
|
||||||
packer_dst_filename: str,
|
packer_dst_filename: str,
|
||||||
tmp_directory: str,
|
packer_tmp_directory: str,
|
||||||
packer_configuration: dict,
|
packer_configuration: dict,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
tmp_directory = join(packer_tmp_directory, 'tmp')
|
||||||
|
makedirs(tmp_directory)
|
||||||
packer_configuration['tmp_directory'] = tmp_directory
|
packer_configuration['tmp_directory'] = tmp_directory
|
||||||
recipe = {'variables': packer_configuration}
|
recipe = {'variables': packer_configuration}
|
||||||
packer_filename = join(tmp_directory, PACKER_FILE_NAME)
|
packer_filename = join(packer_tmp_directory, PACKER_FILE_NAME)
|
||||||
with open(packer_filename, 'r') as recipe_fd:
|
with open(packer_filename, 'r') as recipe_fd:
|
||||||
for key, value in jload(recipe_fd).items():
|
for key, value in jload(recipe_fd).items():
|
||||||
recipe[key] = value
|
recipe[key] = value
|
||||||
|
@ -271,7 +271,7 @@ class Image:
|
||||||
)
|
)
|
||||||
proc.wait()
|
proc.wait()
|
||||||
if proc.returncode:
|
if proc.returncode:
|
||||||
raise Exception(_(f'cannot build {packer_dst_filename} with {packer_filename}'))
|
raise Exception(_(f'cannot build {application} with {packer_filename}'))
|
||||||
move(join(tmp_directory, 'image.img'), packer_dst_filename)
|
move(join(tmp_directory, 'image.img'), packer_dst_filename)
|
||||||
move(join(tmp_directory, 'image.sha256'), f'{packer_dst_filename}.sha256')
|
move(join(tmp_directory, 'image.sha256'), f'{packer_dst_filename}.sha256')
|
||||||
rmtree(tmp_directory)
|
rmtree(tmp_directory)
|
||||||
|
|
Loading…
Reference in New Issue