Indent all function bodies for improved readability
All function bodies in build.func are now consistently indented, improving code readability and maintainability. No logic changes were made; only whitespace and indentation were updated.
This commit is contained in:
parent
980c4df18d
commit
12f92c0947
@ -3335,41 +3335,47 @@ create_lxc_container() {
|
||||
fi
|
||||
fi
|
||||
|
||||
# Validate content types
|
||||
msg_info "Validating content types of storage '$CONTAINER_STORAGE'"
|
||||
STORAGE_CONTENT=$(grep -A4 -E "^(zfspool|dir|lvmthin|lvm|linstor): $CONTAINER_STORAGE" /etc/pve/storage.cfg | grep content | awk '{$1=""; print $0}' | xargs)
|
||||
msg_debug "Storage '$CONTAINER_STORAGE' has content types: $STORAGE_CONTENT"
|
||||
msg_info "Validating storage '$CONTAINER_STORAGE'"
|
||||
STORAGE_CONTENT=$(grep -A10 -E "^(dir|nfs|cifs|btrfs|cephfs|lvm|lvmthin|zfspool|rbd|iscsi|iscsidirect|zfs|linstor|pbs): $CONTAINER_STORAGE$" /etc/pve/storage.cfg | grep -m1 content | awk '{$1=""; print $0}' | xargs)
|
||||
|
||||
# Check storage type for special handling
|
||||
STORAGE_TYPE=$(grep -E "^[^:]+: $CONTAINER_STORAGE$" /etc/pve/storage.cfg | cut -d: -f1)
|
||||
if [[ "$STORAGE_TYPE" == "linstor" ]]; then
|
||||
msg_info "Detected LINSTOR storage - verifying cluster connectivity"
|
||||
if [[ -z "$STORAGE_CONTENT" ]]; then
|
||||
if pvesm status -content rootdir 2>/dev/null | awk 'NR>1{print $1}' | grep -qx "$CONTAINER_STORAGE"; then
|
||||
STORAGE_CONTENT="rootdir"
|
||||
fi
|
||||
fi
|
||||
|
||||
STORAGE_TYPE=$(grep -E "^[^:]+: $CONTAINER_STORAGE$" /etc/pve/storage.cfg | cut -d: -f1 | head -1)
|
||||
|
||||
case "$STORAGE_TYPE" in
|
||||
linstor | rbd | cephfs | iscsi | iscsidirect | nfs | cifs)
|
||||
if ! pvesm status -storage "$CONTAINER_STORAGE" &>/dev/null; then
|
||||
msg_error "LINSTOR storage '$CONTAINER_STORAGE' not accessible. Check LINSTOR cluster health."
|
||||
msg_error "Storage '$CONTAINER_STORAGE' ($STORAGE_TYPE) not accessible"
|
||||
exit 217
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if ! pvesm status -content rootdir 2>/dev/null | awk 'NR>1{print $1}' | grep -qx "$CONTAINER_STORAGE"; then
|
||||
if ! grep -qw "rootdir" <<<"$STORAGE_CONTENT"; then
|
||||
msg_error "Storage '$CONTAINER_STORAGE' does not support 'rootdir'"
|
||||
exit 217
|
||||
fi
|
||||
fi
|
||||
msg_ok "Storage '$CONTAINER_STORAGE' ($STORAGE_TYPE) validated"
|
||||
|
||||
grep -qw "rootdir" <<<"$STORAGE_CONTENT" || {
|
||||
msg_error "Storage '$CONTAINER_STORAGE' does not support 'rootdir'. Cannot create LXC."
|
||||
exit 217
|
||||
}
|
||||
$STD msg_ok "Storage '$CONTAINER_STORAGE' supports 'rootdir'"
|
||||
|
||||
msg_info "Validating content types of template storage '$TEMPLATE_STORAGE'"
|
||||
TEMPLATE_CONTENT=$(grep -A4 -E "^[^:]+: $TEMPLATE_STORAGE" /etc/pve/storage.cfg | grep content | awk '{$1=""; print $0}' | xargs)
|
||||
msg_debug "Template storage '$TEMPLATE_STORAGE' has content types: $TEMPLATE_CONTENT"
|
||||
# Check if template storage is LINSTOR (may need special handling)
|
||||
msg_info "Validating template storage '$TEMPLATE_STORAGE'"
|
||||
TEMPLATE_CONTENT=$(grep -A10 -E "^(dir|nfs|cifs|btrfs|cephfs|lvm|lvmthin|zfspool|rbd|iscsi|iscsidirect|zfs|linstor|pbs): $TEMPLATE_STORAGE$" /etc/pve/storage.cfg | grep -m1 content | awk '{$1=""; print $0}' | xargs)
|
||||
if [[ -z "$TEMPLATE_CONTENT" ]]; then
|
||||
if pvesm status -content vztmpl 2>/dev/null | awk 'NR>1{print $1}' | grep -qx "$TEMPLATE_STORAGE"; then
|
||||
TEMPLATE_CONTENT="vztmpl"
|
||||
fi
|
||||
fi
|
||||
TEMPLATE_TYPE=$(grep -E "^[^:]+: $TEMPLATE_STORAGE$" /etc/pve/storage.cfg | cut -d: -f1)
|
||||
if [[ "$TEMPLATE_TYPE" == "linstor" ]]; then
|
||||
msg_info "Template storage uses LINSTOR - ensuring resource availability"
|
||||
fi
|
||||
|
||||
if ! grep -qw "vztmpl" <<<"$TEMPLATE_CONTENT"; then
|
||||
msg_warn "Template storage '$TEMPLATE_STORAGE' does not declare 'vztmpl'. This may cause pct create to fail."
|
||||
else
|
||||
$STD msg_ok "Template storage '$TEMPLATE_STORAGE' supports 'vztmpl'"
|
||||
msg_warn "Template storage '$TEMPLATE_STORAGE' may not support 'vztmpl'"
|
||||
fi
|
||||
msg_ok "Template storage '$TEMPLATE_STORAGE' validated"
|
||||
|
||||
# Free space check
|
||||
STORAGE_FREE=$(pvesm status | awk -v s="$CONTAINER_STORAGE" '$1 == s { print $6 }')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user