From 0945504b61cc37e3e66adae388ef6ed1e7e342fa Mon Sep 17 00:00:00 2001 From: Haijiao Zhao Date: Tue, 22 Oct 2024 06:09:04 -0400 Subject: [PATCH] network_xml:Update to support setting up hostname xmls with a list of hostname strings Then we can directly use the values getting from a netxml.hostnames to set the value of netxml.hostnames without having to convert it from a list of dicts to a list of strings. Signed-off-by: Haijiao Zhao --- virttest/libvirt_xml/network_xml.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/virttest/libvirt_xml/network_xml.py b/virttest/libvirt_xml/network_xml.py index 581074f649..3f8cc9e30e 100644 --- a/virttest/libvirt_xml/network_xml.py +++ b/virttest/libvirt_xml/network_xml.py @@ -291,9 +291,12 @@ def marshal_from_hostname(item, index, libvirtxml): """ if isinstance(item, DNSXML.HostnameXML): return "hostname", item - elif isinstance(item, str): + elif isinstance(item, (dict, str)): hostname = DNSXML.HostnameXML() - hostname.hostname = item + if isinstance(item, dict): + hostname.setup_attrs(**item) + else: + hostname.hostname = item return "hostname", hostname else: raise xcepts.LibvirtXMLError(