MCPcopy Create free account
hub / github.com/PiSCSI/piscsi / drive_create

Function drive_create

python/web/src/web.py:422–460  ·  view source on GitHub ↗

Creates the image and properties file pair

()

Source from the content-addressed store, hash-verified

420@APP.route("/drive/create", methods=["POST"])
421@login_required
422def drive_create():
423 """
424 Creates the image and properties file pair
425 """
426 drive_name = request.form.get("drive_name")
427 file_name = Path(request.form.get("file_name"))
428
429 properties = get_properties_by_drive_name(APP.config["PISCSI_DRIVE_PROPERTIES"], drive_name)
430
431 if not properties:
432 return response(
433 error=True,
434 message=_("No properties data for drive %(drive_name)s", drive_name=drive_name),
435 )
436
437 # Creating the image file
438 server_info = piscsi_cmd.get_server_info()
439 process = file_cmd.create_empty_image(
440 Path(server_info["image_dir"]) / f"{file_name}.{properties['file_type']}",
441 properties["size"],
442 )
443 process = ReturnCodeMapper.add_msg(process)
444 if not process["status"]:
445 return response(error=True, message=process["msg"])
446
447 # Creating the drive properties file
448 full_file_name = f"{file_name}.{properties['file_type']}"
449 prop_file_name = f"{full_file_name}.{PROPERTIES_SUFFIX}"
450 process = file_cmd.write_drive_properties(prop_file_name, properties)
451 process = ReturnCodeMapper.add_msg(process)
452 if not process["status"]:
453 return response(error=True, message=process["msg"])
454
455 return response(
456 message=_(
457 "Image file with properties created: %(file_name)s",
458 file_name=full_file_name,
459 )
460 )
461
462
463@APP.route("/drive/cdrom", methods=["POST"])

Callers

nothing calls this directly

Calls 6

responseFunction · 0.85
create_empty_imageMethod · 0.80
add_msgMethod · 0.80
get_server_infoMethod · 0.45

Tested by

no test coverage detected