diff --git a/vrtManager/create.py b/vrtManager/create.py index 1d37300..d9f5350 100644 --- a/vrtManager/create.py +++ b/vrtManager/create.py @@ -7,9 +7,17 @@ from webvirtcloud.settings import QEMU_CONSOLE_DEFAULT_TYPE def get_rbd_storage_data(stg): xml = stg.XMLDesc(0) ceph_user = util.get_xml_path(xml, "/pool/source/auth/@username") - ceph_host = util.get_xml_path(xml, "/pool/source/host/@name") - secrt_uuid = util.get_xml_path(xml, "/pool/source/auth/secret/@uuid") - return ceph_user, secrt_uuid, ceph_host + + def get_ceph_hosts(ctx): + hosts = [] + for host in ctx.xpathEval("/pool/source/host"): + name = host.prop("name") + if name: + hosts.append({'name': name, 'port': host.prop("port")}) + return hosts + ceph_hosts = util.get_xml_path(xml, func=get_ceph_hosts) + secret_uuid = util.get_xml_path(xml, "/pool/source/auth/secret/@uuid") + return ceph_user, secret_uuid, ceph_hosts class wvmCreate(wvmConnect): @@ -162,15 +170,23 @@ class wvmCreate(wvmConnect): stg_type = util.get_xml_path(stg.XMLDesc(0), "/pool/@type") if stg_type == 'rbd': - ceph_user, secrt_uuid, ceph_host = get_rbd_storage_data(stg) + ceph_user, secret_uuid, ceph_hosts = get_rbd_storage_data(stg) xml += """ - - - """ % (img_type, ceph_user, secrt_uuid, image, ceph_host) + """ % (img_type, ceph_user, secret_uuid, image) + if isinstance(ceph_hosts, list): + for host in ceph_hosts: + if host.get('port'): + xml += """ + """ % (host.get('name'), host.get('port')) + else: + xml += """ + """ % host.get('name') + xml += """ + """ else: xml += """