[GH-ISSUE #152] Update description in vm config #78

Closed
opened 2026-02-27 15:46:19 +03:00 by kerem · 4 comments
Owner

Originally created by @areqq on GitHub (Dec 30, 2023).
Original GitHub issue: https://github.com/proxmoxer/proxmoxer/issues/152

How to update 'description' in config?

vm = proxmox.nodes('proxmox6').qemu('101')
vm.config.update({'description': '#test\ntest2\n'})

Don't work.

Originally created by @areqq on GitHub (Dec 30, 2023). Original GitHub issue: https://github.com/proxmoxer/proxmoxer/issues/152 How to update 'description' in config? vm = proxmox.nodes('proxmox6').qemu('101') vm.config.update({'description': '#test\ntest2\n'}) Don't work.
kerem closed this issue 2026-02-27 15:46:19 +03:00
Author
Owner

@morph027 commented on GitHub (Dec 30, 2023):

Try

vm.config.post(description="#test\ntest2\n")

<!-- gh-comment-id:1872578235 --> @morph027 commented on GitHub (Dec 30, 2023): Try `vm.config.post(description="#test\ntest2\n")`
Author
Owner

@areqq commented on GitHub (Dec 30, 2023):

it works, thanks!
but "\n" was ignored and all text is in one line ;(
any idea how to set multiline description ?

<!-- gh-comment-id:1872579045 --> @areqq commented on GitHub (Dec 30, 2023): it works, thanks! but "\n" was ignored and all text is in one line ;( any idea how to set multiline description ?
Author
Owner

@aznashwan commented on GitHub (Jan 11, 2024):

@areqq it looks like Proxmoxer DOES properly send newlines to the server and they do get properly saved:

Checks

vmcli = proxmox.nodes("proxmox03").qemu(500)

MULTILINE_DESCR = """
Line 1
Line 2
Line 3
""".strip("\n")

vmcli.config.set(description=MULTILINE_DESCR)

# Works:
assert vmcli.config.get()["description"] == MULTILINE_DESCR

The problem is that the Web UI is rendering HTML, so \n will basically be ignored.

Solution

What we need to do is "HTML-ify" the description a bit by replacing \n with <br>. (HTML line break)

html_description = MULTILINE_DESCR.replace('\n', '<br>')

vmcli.config.set(description=html_description)
<!-- gh-comment-id:1887479390 --> @aznashwan commented on GitHub (Jan 11, 2024): @areqq it looks like Proxmoxer DOES properly send newlines to the server and they do get properly saved: ### Checks ```python3 vmcli = proxmox.nodes("proxmox03").qemu(500) MULTILINE_DESCR = """ Line 1 Line 2 Line 3 """.strip("\n") vmcli.config.set(description=MULTILINE_DESCR) # Works: assert vmcli.config.get()["description"] == MULTILINE_DESCR ``` The problem is that the Web UI is rendering HTML, so `\n` will basically be ignored. ### Solution What we need to do is "HTML-ify" the description a bit by replacing `\n` with `<br>`. (HTML line break) ```python3 html_description = MULTILINE_DESCR.replace('\n', '<br>') vmcli.config.set(description=html_description) ```
Author
Owner

@areqq commented on GitHub (Jan 12, 2024):

Thank you very much for your detailed explanation

<!-- gh-comment-id:1888855279 --> @areqq commented on GitHub (Jan 12, 2024): Thank you very much for your detailed explanation
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/proxmoxer#78
No description provided.