mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-01 08:26:03 +00:00
fix(vrtManager): an RBD disk takes its pool's auth and monitors as they are
A disk of an RBD pool, at VM creation or added later, had the pool's user, secret uuid and monitors put into its XML as strings: a user with a quote or ampersand broke the XML, and a secret named by usage gave IndexError on attach and uuid='None' at creation. One function now copies the pool's auth (uuid or usage) and host elements into the disk's source with lxml, replacing the two string builders. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
parent
f94124c891
commit
0ac078b9cc
5 changed files with 76 additions and 82 deletions
|
|
@ -1226,20 +1226,8 @@ class wvmInstance(wvmConnect):
|
|||
elif disk_type == "block": # a volume of an LVM, disk or iSCSI pool
|
||||
xml_disk += f"<source dev='{source}'/>"
|
||||
elif disk_type == "network":
|
||||
if pool_type == "rbd":
|
||||
auth_type = source_info.get("auth_type")
|
||||
auth_user = source_info.get("auth_user")
|
||||
auth_uuid = source_info.get("auth_uuid")
|
||||
xml_disk += f"""<auth username='{auth_user}'>
|
||||
<secret type='{auth_type}' uuid='{auth_uuid}'/>
|
||||
</auth>"""
|
||||
xml_disk += f"""<source protocol='{pool_type}' name='{source}'>"""
|
||||
for host in source_info.get("hosts"):
|
||||
if host.get("hostport"):
|
||||
xml_disk += f"""<host name="{host.get('hostname')}" port='{host.get('hostport')}'/>"""
|
||||
else:
|
||||
xml_disk += f"""<host name="{host.get('hostname')}"/>"""
|
||||
xml_disk += """</source>"""
|
||||
if pool_type == "rbd": # source_info: rbd_source_children of the pool
|
||||
xml_disk += f"<source protocol='rbd' name='{source}'>{source_info}</source>"
|
||||
else:
|
||||
raise Exception("Not implemented disk type")
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue