mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-24 23:25:24 +00:00
convert strings to python3 f-Strings
This commit is contained in:
parent
0461df7685
commit
a93f8b3321
5 changed files with 121 additions and 124 deletions
|
@ -651,27 +651,27 @@ class wvmInstance(wvmConnect):
|
|||
|
||||
additionals = ''
|
||||
if cache_mode is not None and cache_mode != 'default' and disk_device != 'cdrom':
|
||||
additionals += "cache='%s' " % cache_mode
|
||||
additionals += f"cache='{cache_mode}' "
|
||||
if io_mode is not None and io_mode != 'default':
|
||||
additionals += "io='%s' " % io_mode
|
||||
additionals += f"io='{io_mode}' "
|
||||
if discard_mode is not None and discard_mode != 'default':
|
||||
additionals += "discard='%s' " % discard_mode
|
||||
additionals += f"discard='{discard_mode}' "
|
||||
if detect_zeroes_mode is not None and detect_zeroes_mode != 'default':
|
||||
additionals += "detect_zeroes='%s' " % detect_zeroes_mode
|
||||
additionals += f"detect_zeroes='{detect_zeroes_mode}' "
|
||||
|
||||
xml_disk = "<disk type='%s' device='%s'>" % (disk_type, disk_device)
|
||||
xml_disk = f"<disk type='{disk_type}' device='{disk_device}'>"
|
||||
if disk_device == 'cdrom':
|
||||
xml_disk += "<driver name='%s' type='%s'/>" % (driver_name, driver_type)
|
||||
xml_disk += f"<driver name='{driver_name}' type='{driver_type}'/>"
|
||||
elif disk_device == 'disk':
|
||||
xml_disk += "<driver name='%s' type='%s' %s/>" % (driver_name, driver_type, additionals)
|
||||
xml_disk += """<source file='%s'/>
|
||||
<target dev='%s' bus='%s'/>""" % (source, target_dev, target_bus)
|
||||
xml_disk += f"<driver name='{driver_name}' type='{driver_type}' {additionals}/>"
|
||||
xml_disk += f"""<source file='{source}'/>
|
||||
<target dev='{target_dev}' bus='{target_bus}'/>"""
|
||||
if readonly or disk_device == 'cdrom':
|
||||
xml_disk += """<readonly/>"""
|
||||
if shareable:
|
||||
xml_disk += """<shareable/>"""
|
||||
if serial is not None and serial != 'None' and serial != '':
|
||||
xml_disk += """<serial>%s</serial>""" % serial
|
||||
xml_disk += f"""<serial>{serial}</serial>"""
|
||||
xml_disk += """</disk>"""
|
||||
if self.get_status() == 1:
|
||||
self.instance.attachDeviceFlags(xml_disk, VIR_DOMAIN_AFFECT_LIVE)
|
||||
|
@ -703,28 +703,28 @@ class wvmInstance(wvmConnect):
|
|||
|
||||
additionals = ''
|
||||
if cache_mode is not None and cache_mode != 'default':
|
||||
additionals += "cache='%s' " % cache_mode
|
||||
additionals += f"cache='{cache_mode}' "
|
||||
if io_mode is not None and io_mode != 'default':
|
||||
additionals += "io='%s' " % io_mode
|
||||
additionals += f"io='{io_mode}' "
|
||||
if discard_mode is not None and discard_mode != 'default':
|
||||
additionals += "discard='%s' " % discard_mode
|
||||
additionals += f"discard='{discard_mode}' "
|
||||
if detect_zeroes_mode is not None and detect_zeroes_mode != 'default':
|
||||
additionals += "detect_zeroes='%s' " % detect_zeroes_mode
|
||||
additionals += f"detect_zeroes='{detect_zeroes_mode}' "
|
||||
|
||||
xml_disk = "<disk type='%s' device='%s'>" % (old_disk_type, old_disk_device)
|
||||
xml_disk = f"<disk type='{old_disk_type}' device='{old_disk_device}'>"
|
||||
if old_disk_device == 'cdrom':
|
||||
xml_disk += "<driver name='%s' type='%s'/>" % (old_driver_name, format)
|
||||
xml_disk += f"<driver name='{old_driver_name}' type='{format}'/>"
|
||||
elif old_disk_device == 'disk':
|
||||
xml_disk += "<driver name='%s' type='%s' %s/>" % (old_driver_name, format, additionals)
|
||||
xml_disk += f"<driver name='{old_driver_name}' type='{format}' {additionals}/>"
|
||||
|
||||
xml_disk += """<source file='%s'/>
|
||||
<target dev='%s' bus='%s'/>""" % (source, target_dev, target_bus)
|
||||
xml_disk += f"""<source file='{source}'/>
|
||||
<target dev='{target_dev}' bus='{target_bus}'/>"""
|
||||
if readonly:
|
||||
xml_disk += """<readonly/>"""
|
||||
if shareable:
|
||||
xml_disk += """<shareable/>"""
|
||||
if serial is not None and serial != 'None' and serial != '':
|
||||
xml_disk += """<serial>%s</serial>""" % serial
|
||||
xml_disk += f"""<serial>{serial}</serial>"""
|
||||
xml_disk += """</disk>"""
|
||||
|
||||
self.instance.updateDeviceFlags(xml_disk, VIR_DOMAIN_AFFECT_CONFIG)
|
||||
|
@ -753,7 +753,7 @@ class wvmInstance(wvmConnect):
|
|||
xml = """ <vcpus>"""
|
||||
xml += """<vcpu id='0' enabled='yes' hotpluggable='no' order='1'/>"""
|
||||
for i in range(1, vcpus_hotplug):
|
||||
xml += """<vcpu id='{}' enabled='yes' hotpluggable='yes' order='{}'/>""".format(i, i+1)
|
||||
xml += f"""<vcpu id='{i}' enabled='yes' hotpluggable='yes' order='{i+1}'/>"""
|
||||
xml += """</vcpus>"""
|
||||
|
||||
tree = etree.fromstring(self._XMLDesc(0))
|
||||
|
@ -914,7 +914,7 @@ class wvmInstance(wvmConnect):
|
|||
xml = self._XMLDesc(VIR_DOMAIN_XML_SECURE)
|
||||
root = ElementTree.fromstring(xml)
|
||||
try:
|
||||
graphic = root.find("devices/graphics[@type='%s']" % current_type)
|
||||
graphic = root.find(f"devices/graphics[@type='{current_type}']")
|
||||
except SyntaxError:
|
||||
# Little fix for old version ElementTree
|
||||
graphic = root.find("devices/graphics")
|
||||
|
@ -942,7 +942,7 @@ class wvmInstance(wvmConnect):
|
|||
root = ElementTree.fromstring(xml)
|
||||
console_type = self.get_console_type()
|
||||
try:
|
||||
graphic = root.find("devices/graphics[@type='%s']" % console_type)
|
||||
graphic = root.find(f"devices/graphics[@type='{console_type}']")
|
||||
except SyntaxError:
|
||||
# Little fix for old version ElementTree
|
||||
graphic = root.find("devices/graphics")
|
||||
|
@ -1161,7 +1161,7 @@ class wvmInstance(wvmConnect):
|
|||
stg_conn = self.get_wvmStorages()
|
||||
stg_conn.create_storage('dir', nvram_pool_name, None, nvram_dir)
|
||||
|
||||
new_nvram_name = "%s_VARS" % clone_data['name']
|
||||
new_nvram_name = f"{clone_data['name']}_VARS"
|
||||
nvram_stg = self.get_wvmStorage(nvram_pool_name)
|
||||
nvram_stg.clone_volume(src_nvram_name, new_nvram_name, file_suffix='fd')
|
||||
|
||||
|
@ -1195,16 +1195,16 @@ class wvmInstance(wvmConnect):
|
|||
if vol_format == 'qcow2' and meta_prealloc:
|
||||
meta_prealloc = True
|
||||
|
||||
vol_clone_xml = """
|
||||
vol_clone_xml = f"""
|
||||
<volume>
|
||||
<name>%s</name>
|
||||
<name>{target_file}</name>
|
||||
<capacity>0</capacity>
|
||||
<allocation>0</allocation>
|
||||
<target>
|
||||
<format type='%s'/>
|
||||
<format type='{vol_format}'/>
|
||||
<permissions>
|
||||
<owner>%s</owner>
|
||||
<group>%s</group>
|
||||
<owner>{OWNER['uid']}</owner>
|
||||
<group>{OWNER['guid']}</group>
|
||||
<mode>0644</mode>
|
||||
<label>virt_image_t</label>
|
||||
</permissions>
|
||||
|
@ -1213,7 +1213,7 @@ class wvmInstance(wvmConnect):
|
|||
<lazy_refcounts/>
|
||||
</features>
|
||||
</target>
|
||||
</volume>""" % (target_file, vol_format, OWNER['uid'], OWNER['guid'])
|
||||
</volume>"""
|
||||
|
||||
stg = vol.storagePoolLookupByVolume()
|
||||
stg.createXMLFrom(vol_clone_xml, vol, meta_prealloc)
|
||||
|
@ -1227,15 +1227,15 @@ class wvmInstance(wvmConnect):
|
|||
vol = self.get_volume_by_path(source_name)
|
||||
vol_format = util.get_xml_path(vol.XMLDesc(0), "/volume/target/format/@type")
|
||||
|
||||
vol_clone_xml = """
|
||||
vol_clone_xml = f"""
|
||||
<volume type='network'>
|
||||
<name>%s</name>
|
||||
<name>{target_file}</name>
|
||||
<capacity>0</capacity>
|
||||
<allocation>0</allocation>
|
||||
<target>
|
||||
<format type='%s'/>
|
||||
<format type='{vol_format}'/>
|
||||
</target>
|
||||
</volume>""" % (target_file, vol_format)
|
||||
</volume>"""
|
||||
stg = vol.storagePoolLookupByVolume()
|
||||
stg.createXMLFrom(vol_clone_xml, vol, meta_prealloc)
|
||||
|
||||
|
@ -1275,18 +1275,16 @@ class wvmInstance(wvmConnect):
|
|||
else:
|
||||
interface_type = 'bridge'
|
||||
|
||||
xml_iface = """
|
||||
<interface type='%s'>
|
||||
<mac address='%s'/>""" % (interface_type, mac_address)
|
||||
xml_iface = f"""
|
||||
<interface type='{interface_type}'>
|
||||
<mac address='{mac_address}'/>"""
|
||||
if interface_type == 'network':
|
||||
xml_iface += """<source network='%s'/>""" % source
|
||||
xml_iface += f"""<source network='{source}'/>"""
|
||||
else:
|
||||
xml_iface += """<source bridge='%s'/>""" % bridge_name
|
||||
xml_iface += """<model type='%s'/>""" % model
|
||||
xml_iface += f"""<source bridge='{bridge_name}'/>"""
|
||||
xml_iface += f"""<model type='{model}'/>"""
|
||||
if nwfilter:
|
||||
xml_iface += """
|
||||
<filterref filter='%s'/>
|
||||
""" % nwfilter
|
||||
xml_iface += f"""<filterref filter='{nwfilter}'/>"""
|
||||
xml_iface += """</interface>"""
|
||||
|
||||
if self.get_status() == 1:
|
||||
|
@ -1438,9 +1436,9 @@ class wvmInstance(wvmConnect):
|
|||
|
||||
def set_qos(self, mac, direction, average, peak, burst):
|
||||
if direction == "inbound":
|
||||
xml = "<inbound average='{}' peak='{}' burst='{}'/>".format(average, peak, burst)
|
||||
xml = f"<inbound average='{average}' peak='{peak}' burst='{burst}'/>"
|
||||
elif direction == "outbound":
|
||||
xml = "<outbound average='{}' peak='{}' burst='{}'/>".format(average, peak, burst)
|
||||
xml = f"<outbound average='{average}' peak='{peak}' burst='{burst}'/>"
|
||||
else:
|
||||
raise Exception('Direction must be inbound or outbound')
|
||||
|
||||
|
|
|
@ -19,32 +19,32 @@ class wvmInterfaces(wvmConnect):
|
|||
|
||||
def create_iface(self, name, itype, mode, netdev, ipv4_type, ipv4_addr, ipv4_gw,
|
||||
ipv6_type, ipv6_addr, ipv6_gw, stp, delay):
|
||||
xml = """<interface type='%s' name='%s'>
|
||||
<start mode='%s'/>""" % (itype, name, mode)
|
||||
xml = f"""<interface type='{itype}' name='{name}'>
|
||||
<start mode='{mode}'/>"""
|
||||
if ipv4_type == 'dhcp':
|
||||
xml += """<protocol family='ipv4'>
|
||||
<dhcp/>
|
||||
</protocol>"""
|
||||
if ipv4_type == 'static':
|
||||
address, prefix = ipv4_addr.split('/')
|
||||
xml += """<protocol family='ipv4'>
|
||||
<ip address='%s' prefix='%s'/>
|
||||
<route gateway='%s'/>
|
||||
</protocol>""" % (address, prefix, ipv4_gw)
|
||||
xml += f"""<protocol family='ipv4'>
|
||||
<ip address='{address}' prefix='{prefix}'/>
|
||||
<route gateway='{ipv4_gw}'/>
|
||||
</protocol>"""
|
||||
if ipv6_type == 'dhcp':
|
||||
xml += """<protocol family='ipv6'>
|
||||
<dhcp/>
|
||||
</protocol>"""
|
||||
if ipv6_type == 'static':
|
||||
address, prefix = ipv6_addr.split('/')
|
||||
xml += """<protocol family='ipv6'>
|
||||
<ip address='%s' prefix='%s'/>
|
||||
<route gateway='%s'/>
|
||||
</protocol>""" % (address, prefix, ipv6_gw)
|
||||
xml += f"""<protocol family='ipv6'>
|
||||
<ip address='{address}' prefix='{prefix}'/>
|
||||
<route gateway='{ipv6_gw}'/>
|
||||
</protocol>"""
|
||||
if itype == 'bridge':
|
||||
xml += """<bridge stp='%s' delay='%s'>
|
||||
<interface name='%s' type='ethernet'/>
|
||||
</bridge>""" % (stp, delay, netdev)
|
||||
xml += f"""<bridge stp='{stp}' delay='{delay}'>
|
||||
<interface name='{netdev}' type='ethernet'/>
|
||||
</bridge>"""
|
||||
xml += """</interface>"""
|
||||
self.define_iface(xml)
|
||||
iface = self.get_iface(name)
|
||||
|
|
|
@ -45,37 +45,37 @@ class wvmNetworks(wvmConnect):
|
|||
ipv4, gateway, mask, dhcp4,
|
||||
ipv6, gateway6, prefix6, dhcp6,
|
||||
bridge, openvswitch, fixed=False):
|
||||
xml = """
|
||||
xml = f"""
|
||||
<network>
|
||||
<name>%s</name>""" % name
|
||||
<name>{name}</name>"""
|
||||
if forward in ['nat', 'route', 'bridge']:
|
||||
xml += """<forward mode='%s'/>""" % forward
|
||||
xml += f"""<forward mode='{forward}'/>"""
|
||||
xml += """<bridge """
|
||||
if forward in ['nat', 'route', 'none']:
|
||||
xml += """stp='on' delay='0'"""
|
||||
if forward == 'bridge':
|
||||
xml += """name='%s'""" % bridge
|
||||
xml += f"""name='{bridge}'"""
|
||||
xml += """/>"""
|
||||
if openvswitch is True:
|
||||
xml += """<virtualport type='openvswitch'/>"""
|
||||
if forward != 'bridge':
|
||||
if ipv4:
|
||||
xml += """<ip address='%s' netmask='%s'>""" % (gateway, mask)
|
||||
xml += f"""<ip address='{gateway}' netmask='{mask}'>"""
|
||||
if dhcp4:
|
||||
xml += """<dhcp>
|
||||
<range start='%s' end='%s' />""" % (dhcp4[0], dhcp4[1])
|
||||
xml += f"""<dhcp>
|
||||
<range start='{dhcp4[0]}' end='{dhcp4[1]}' />"""
|
||||
if fixed:
|
||||
fist_oct = int(dhcp4[0].strip().split('.')[3])
|
||||
last_oct = int(dhcp4[1].strip().split('.')[3])
|
||||
for ip in range(fist_oct, last_oct + 1):
|
||||
xml += """<host mac='%s' ip='%s.%s' />""" % (util.randomMAC(), gateway[:-2], ip)
|
||||
xml += f"""<host mac='{util.randomMAC()}' ip='{gateway[:-2]}.{ip}' />"""
|
||||
xml += """</dhcp>"""
|
||||
xml += """</ip>"""
|
||||
if ipv6:
|
||||
xml += """<ip family='ipv6' address='%s' prefix='%s'>""" % (gateway6, prefix6)
|
||||
xml += f"""<ip family='ipv6' address='{gateway6}' prefix='{prefix6}'>"""
|
||||
if dhcp6:
|
||||
xml += """<dhcp>
|
||||
<range start='%s' end='%s' />""" % (dhcp6[0], dhcp6[1])
|
||||
xml += f"""<dhcp>
|
||||
<range start='{dhcp6[0]}' end='{dhcp6[1]}' />"""
|
||||
xml += """</dhcp>"""
|
||||
xml += """</ip>"""
|
||||
xml += """</network>"""
|
||||
|
@ -314,9 +314,9 @@ class wvmNetwork(wvmConnect):
|
|||
|
||||
def set_qos(self, direction, average, peak, burst):
|
||||
if direction == "inbound":
|
||||
xml = "<inbound average='{}' peak='{}' burst='{}'/>".format(average, peak, burst)
|
||||
xml = f"<inbound average='{average}' peak='{peak}' burst='{burst}'/>"
|
||||
elif direction == "outbound":
|
||||
xml = "<outbound average='{}' peak='{}' burst='{}'/>".format(average, peak, burst)
|
||||
xml = f"<outbound average='{average}' peak='{peak}' burst='{burst}'/>"
|
||||
else:
|
||||
raise Exception('Direction must be inbound or outbound')
|
||||
|
||||
|
@ -324,7 +324,7 @@ class wvmNetwork(wvmConnect):
|
|||
|
||||
band = tree.xpath("/network/bandwidth")
|
||||
if len(band) == 0:
|
||||
xml = "<bandwidth>" + xml + "</bandwidth>"
|
||||
xml = f"<bandwidth>{xml}</bandwidth>"
|
||||
tree.append(etree.fromstring(xml))
|
||||
else:
|
||||
direct = band[0].find(direction)
|
||||
|
@ -339,7 +339,7 @@ class wvmNetwork(wvmConnect):
|
|||
|
||||
def unset_qos(self, direction):
|
||||
tree = etree.fromstring(self._XMLDesc(0))
|
||||
for direct in tree.xpath("/network/bandwidth/{}".format(direction)):
|
||||
for direct in tree.xpath(f"/network/bandwidth/{direction}"):
|
||||
parent = direct.getparent()
|
||||
parent.remove(direct)
|
||||
|
||||
|
@ -353,7 +353,7 @@ class wvmNetwork(wvmConnect):
|
|||
self.leases = self.net.DHCPLeases()
|
||||
except Exception as e:
|
||||
self.leases = []
|
||||
raise "Error getting %s DHCP leases: %s" % (self, e)
|
||||
raise f"Error getting {self} DHCP leases: {e}"
|
||||
|
||||
def get_dhcp_leases(self):
|
||||
if self.leases is None:
|
||||
|
|
|
@ -4,14 +4,14 @@ from vrtManager.connection import wvmConnect
|
|||
|
||||
class wvmSecrets(wvmConnect):
|
||||
def create_secret(self, ephemeral, private, secret_type, data):
|
||||
xml = """<secret ephemeral='%s' private='%s'>
|
||||
<usage type='%s'>""" % (ephemeral, private, secret_type)
|
||||
xml = f"""<secret ephemeral='{ephemeral}' private='{private}'>
|
||||
<usage type='{secret_type}'>"""
|
||||
if secret_type == 'ceph':
|
||||
xml += """<name>%s</name>""" % data
|
||||
xml += f"""<name>{data}</name>"""
|
||||
if secret_type == 'volume':
|
||||
xml += """<volume>%s</volume>""" % data
|
||||
xml += f"""<volume>{data}</volume>"""
|
||||
if secret_type == 'iscsi':
|
||||
xml += """<target>%s</target>""" % data
|
||||
xml += f"""<target>{data}</target>"""
|
||||
xml += """</usage>
|
||||
</secret>"""
|
||||
self.wvm.secretDefineXML(xml)
|
||||
|
|
|
@ -25,23 +25,21 @@ class wvmStorages(wvmConnect):
|
|||
self.wvm.storagePoolDefineXML(xml, flag)
|
||||
|
||||
def create_storage(self, stg_type, name, source, target):
|
||||
xml = """
|
||||
<pool type='%s'>
|
||||
<name>%s</name>""" % (stg_type, name)
|
||||
xml = f"""<pool type='{stg_type}'>
|
||||
<name>{name}</name>"""
|
||||
if stg_type == 'logical':
|
||||
xml += """
|
||||
<source>
|
||||
<device path='%s'/>
|
||||
<name>%s</name>
|
||||
xml += f"""<source>
|
||||
<device path='{source}'/>
|
||||
<name>{name}</name>
|
||||
<format type='lvm2'/>
|
||||
</source>""" % (source, name)
|
||||
</source>"""
|
||||
if stg_type == 'logical':
|
||||
target = '/dev/' + name
|
||||
xml += """
|
||||
xml += f"""
|
||||
<target>
|
||||
<path>%s</path>
|
||||
<path>{target}</path>
|
||||
</target>
|
||||
</pool>""" % target
|
||||
</pool>"""
|
||||
self.define_storage(xml, 0)
|
||||
stg = self.get_storage(name)
|
||||
if stg_type == 'logical':
|
||||
|
@ -52,35 +50,37 @@ class wvmStorages(wvmConnect):
|
|||
return stg
|
||||
|
||||
def create_storage_ceph(self, stg_type, name, ceph_pool, ceph_host, ceph_user, secret):
|
||||
xml = """
|
||||
<pool type='%s'>
|
||||
<name>%s</name>
|
||||
xml = f"""
|
||||
<pool type='{stg_type}'>
|
||||
<name>{name}</name>
|
||||
<source>
|
||||
<name>%s</name>
|
||||
<host name='%s' port='6789'/>
|
||||
<auth username='%s' type='ceph'>
|
||||
<secret uuid='%s'/>
|
||||
<name>{ceph_pool}</name>
|
||||
<host name='{ceph_host}' port='6789'/>
|
||||
<auth username='{ceph_user}' type='ceph'>
|
||||
<secret uuid='{secret}'/>
|
||||
</auth>
|
||||
</source>
|
||||
</pool>""" % (stg_type, name, ceph_pool, ceph_host, ceph_user, secret)
|
||||
</pool>
|
||||
"""
|
||||
self.define_storage(xml, 0)
|
||||
stg = self.get_storage(name)
|
||||
stg.create(0)
|
||||
stg.setAutostart(1)
|
||||
|
||||
def create_storage_netfs(self, stg_type, name, netfs_host, source, source_format, target):
|
||||
xml = """
|
||||
<pool type='%s'>
|
||||
<name>%s</name>
|
||||
xml = f"""
|
||||
<pool type='{stg_type}'>
|
||||
<name>{name}</name>
|
||||
<source>
|
||||
<host name='%s'/>
|
||||
<dir path='%s'/>
|
||||
<format type='%s'/>
|
||||
<host name='{netfs_host}'/>
|
||||
<dir path='{source}'/>
|
||||
<format type='{source_format}'/>
|
||||
</source>
|
||||
<target>
|
||||
<path>%s</path>
|
||||
<path>{target}</path>
|
||||
</target>
|
||||
</pool>""" % (stg_type, name, netfs_host, source, source_format, target)
|
||||
</pool>
|
||||
"""
|
||||
self.define_storage(xml, 0)
|
||||
stg = self.get_storage(name)
|
||||
stg.create(0)
|
||||
|
@ -222,27 +222,26 @@ class wvmStorage(wvmConnect):
|
|||
else:
|
||||
name += '.img'
|
||||
alloc = 0
|
||||
xml = """
|
||||
xml = f"""
|
||||
<volume>
|
||||
<name>%s</name>
|
||||
<capacity>%s</capacity>
|
||||
<allocation>%s</allocation>
|
||||
<name>{name}</name>
|
||||
<capacity>{size}</capacity>
|
||||
<allocation>{alloc}</allocation>
|
||||
<target>
|
||||
<format type='%s'/>
|
||||
<format type='{vol_fmt}'/>
|
||||
<permissions>
|
||||
<owner>%s</owner>
|
||||
<group>%s</group>
|
||||
<owner>{owner['uid']}</owner>
|
||||
<group>{owner['guid']}</group>
|
||||
<mode>0644</mode>
|
||||
<label>virt_image_t</label>
|
||||
</permissions>""" % (name, size, alloc, vol_fmt, owner['uid'], owner['guid'])
|
||||
</permissions>"""
|
||||
if vol_fmt == 'qcow2':
|
||||
xml += """
|
||||
<compat>1.1</compat>
|
||||
<features>
|
||||
<lazy_refcounts/>
|
||||
</features>"""
|
||||
xml += """
|
||||
</target>
|
||||
xml += """</target>
|
||||
</volume>"""
|
||||
self._createXML(xml, metadata)
|
||||
return name
|
||||
|
@ -260,19 +259,19 @@ class wvmStorage(wvmConnect):
|
|||
suffix = '.' + file_suffix
|
||||
target_file += suffix if len(suffix) > 1 else ''
|
||||
|
||||
xml = """
|
||||
xml = f"""
|
||||
<volume>
|
||||
<name>%s</name>
|
||||
<name>{target_file}</name>
|
||||
<capacity>0</capacity>
|
||||
<allocation>0</allocation>
|
||||
<target>
|
||||
<format type='%s'/>
|
||||
<format type='{vol_fmt}'/>
|
||||
<permissions>
|
||||
<owner>%s</owner>
|
||||
<group>%s</group>
|
||||
<mode>%s</mode>
|
||||
<owner>{owner['uid']}</owner>
|
||||
<group>{owner['guid']}</group>
|
||||
<mode>{mode}</mode>
|
||||
<label>virt_image_t</label>
|
||||
</permissions>""" % (target_file, vol_fmt, owner['uid'], owner['guid'], mode)
|
||||
</permissions>"""
|
||||
if vol_fmt == 'qcow2':
|
||||
xml += """
|
||||
<compat>1.1</compat>
|
||||
|
|
Loading…
Reference in a new issue