Giter VIP home page Giter VIP logo

Comments (2)

bpg avatar bpg commented on August 9, 2024 1

This really gnarly code is responsible for disk creation:

`set -e`,
fmt.Sprintf(`datastore_id_image="%s"`, fileIDParts[0]),
fmt.Sprintf(`datastore_id_target="%s"`, datastoreID),
fmt.Sprintf(`disk_index="%d"`, i),
fmt.Sprintf(`disk_options="%s"`, diskOptions),
fmt.Sprintf(`disk_size="%d"`, size),
fmt.Sprintf(`disk_interface="%s"`, diskInterface),
fmt.Sprintf(`file_path="%s"`, filePath),
fmt.Sprintf(`file_path_tmp="%s"`, filePathTmp),
fmt.Sprintf(`vm_id="%d"`, vmID),
`getdsi() { local nr='^([A-Za-z0-9_-]+): ([A-Za-z0-9_-]+)$'; local pr='^[[:space:]]+path[[:space:]]+([^[:space:]]+)$'; local dn=""; local dt=""; while IFS='' read -r l || [[ -n "$l" ]]; do if [[ "$l" =~ $nr ]]; then dt="${BASH_REMATCH[1]}"; dn="${BASH_REMATCH[2]}"; elif [[ "$l" =~ $pr ]] && [[ "$dn" == "$1" ]]; then echo "${BASH_REMATCH[1]};${dt}"; break; fi; done < /etc/pve/storage.cfg; }`,
`dsi_image="$(getdsi "$datastore_id_image")"`,
`dsp_image="$(echo "$dsi_image" | cut -d ";" -f 1)"`,
`dst_image="$(echo "$dsi_image" | cut -d ";" -f 2)"`,
`if [[ -z "$dsp_image" ]]; then echo "Failed to determine the path for datastore '${datastore_id_image}' (${dsi_image})"; exit 1; fi`,
`dsi_target="$(getdsi "$datastore_id_target")"`,
`dsp_target="$(echo "$dsi_target" | cut -d ";" -f 1)"`,
`cp "${dsp_image}${file_path}" "$file_path_tmp"`,
`qemu-img resize "$file_path_tmp" "${disk_size}G"`,
`imported_disk="$(qm importdisk "$vm_id" "$file_path_tmp" "$datastore_id_target" -format qcow2 | grep "unused0" | cut -d ":" -f 3 | cut -d "'" -f 1)"`,
`disk_id="${datastore_id_target}:$([[ -n "$dsp_target" ]] && echo "${vm_id}/" || echo "")$imported_disk$([[ -n "$dsp_target" ]] && echo ".qcow2" || echo "")${disk_options}"`,
`qm set "$vm_id" "-${disk_interface}" "$disk_id"`,
`rm -f "$file_path_tmp"`,
)

It doesn't know anything about special handling of vztmpl content type 😞. Without much of unit tests any change there is kind of open heart surgery, but let me see what can be done. It seems that pvesm can replace most of the custom getdsi() logic over there, so I have some hope.

I would really appreciate any help with testing the fix when it will be available, on as many different storage types as possible.

from terraform-provider-proxmox.

bpg avatar bpg commented on August 9, 2024

Hi @fpicot! 👋🏼
I think #241 should fix this particular issue, although i'm not sure if the image you're trying to create VM from is the right one. I wasn't able to boot the VM using a "raw" disk from that image.
Have you had any success with any of non-qcow2 images for VMs on proxmox?

EDIT: I guess my comment is more related to #188 issue 😅

from terraform-provider-proxmox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.