Creates the image and properties file pair
()
| 420 | @APP.route("/drive/create", methods=["POST"]) |
| 421 | @login_required |
| 422 | def 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"]) |
nothing calls this directly
no test coverage detected