create and mount volume. being mounted as vda

This commit is contained in:
Josh Patterson
2025-10-07 16:36:23 -04:00
parent 4ab4264f77
commit a1a8f75409
2 changed files with 14 additions and 11 deletions

View File

@@ -242,16 +242,7 @@ def create_volume_file(vm_name, size_gb, logger):
Raises:
VolumeCreationError: If volume creation fails
"""
# Create volume directory if it doesn't exist
try:
if not os.path.exists(VOLUME_DIR):
os.makedirs(VOLUME_DIR, mode=0o755)
logger.info(f"VOLUME: Created volume directory: {VOLUME_DIR}")
except OSError as e:
logger.error(f"VOLUME: Failed to create volume directory: {e}")
raise VolumeCreationError(f"Failed to create volume directory: {e}")
# Define volume path
# Define volume path (directory already created in main())
volume_path = os.path.join(VOLUME_DIR, f"{vm_name}-nsm.img")
# Check if volume already exists
@@ -449,6 +440,18 @@ def main():
# Emit start status event
emit_status_event(vm_name, 'Volume Creation')
# Ensure volume directory exists before checking disk space
try:
os.makedirs(VOLUME_DIR, mode=0o755, exist_ok=True)
socore_uid = pwd.getpwnam('socore').pw_uid
socore_gid = grp.getgrnam('socore').gr_gid
os.chown(VOLUME_DIR, socore_uid, socore_gid)
logger.debug(f"VOLUME: Ensured volume directory exists: {VOLUME_DIR}")
except Exception as e:
logger.error(f"VOLUME: Failed to create volume directory: {e}")
emit_status_event(vm_name, 'Volume Configuration Failed')
sys.exit(1)
# Check disk space
check_disk_space(size_gb, logger)

View File

@@ -544,7 +544,7 @@ def run_qcow2_create_volume_config(profile, vm_name, size_gb, cpu=None, memory=N
memory (int, optional): Amount of memory in MiB
start (bool): Whether to start the VM after configuration
"""
hv_name = profile.split('-')[1]
hv_name = profile.split('_')[1]
target = hv_name + "_*"
try: