Python3 support fixes

This commit is contained in:
Андрей Лимачко 2022-02-25 17:40:55 +04:00
parent 626e28687a
commit 17ecb2d824
4 changed files with 8 additions and 8 deletions

View File

@ -644,7 +644,7 @@ def get_vminfo(module, proxmox, node, vmid, **kwargs):
kwargs = dict((k, v) for k, v in kwargs.items() if v is not None)
# Convert all dict in kwargs to elements. For hostpci[n], ide[n], net[n], numa[n], parallel[n], sata[n], scsi[n], serial[n], virtio[n]
for k in kwargs.keys():
for k in list(kwargs.keys()):
if isinstance(kwargs[k], dict):
kwargs.update(kwargs[k])
del kwargs[k]
@ -730,7 +730,7 @@ def create_vm(module, proxmox, vmid, newid, node, name, memory, cpu, cores, sock
#kwargs['net'][n]['virtio'] = results['mac'][n]
# Convert all dict in kwargs to elements. For hostpci[n], ide[n], net[n], numa[n], parallel[n], sata[n], scsi[n], serial[n], virtio[n]
for k in kwargs.keys():
for k in list(kwargs.keys()):
if isinstance(kwargs[k], dict):
kwargs.update(kwargs[k])
del kwargs[k]
@ -1067,9 +1067,9 @@ def main():
module.exit_json(changed=True, msg="VM %s with vmid %s deployed" % (name, vmid), **results)
except Exception as e:
if update:
module.fail_json(msg="Unable to update vm {} with vimd {}=".format(name, vmid) + str(e))
module.fail_json(msg="Unable to update vm {} with vimd {} = {}".format(name, vmid, str(e)))
elif clone is not None:
module.fail_json(msg="Unable to clone vm {} from vimd {}=".format(name, vmid) + str(e))
module.fail_json(msg="Unable to clone vm {} from vimd {} = {}".format(name, vmid, str(e)))
else:
module.fail_json(msg="creation of %s VM %s with vmid %s failed with exception=%s" % (VZ_TYPE, name, vmid, e))

View File

@ -36,7 +36,7 @@ def dict_merge(dct, merge_dct):
:param merge_dct: dct merged into dct
:return: None
"""
for k, v in merge_dct.iteritems():
for k, v in merge_dct.items():
if (k in dct and isinstance(dct[k], dict)
and isinstance(merge_dct[k], collections.Mapping)):
dict_merge(dct[k], merge_dct[k])
@ -115,7 +115,7 @@ def get_steps(node, steps_list):
def filter_dict(src, pred):
p = eval(pred)
return { k: v for k, v in src.iteritems() if p(v)}
return { k: v for k, v in src.items() if p(v)}
def format2(what, fmt):
return fmt % what

View File

@ -1,4 +1,4 @@
{% for node_name, node in stack.nodes.iteritems() %}
{% for node_name, node in stack.nodes.items() %}
Host {{node_name}}.{{stack.domain}} {{node_name}}
HostName {{node.net.eth0.ipv4[0]|ipaddr('address')}}
User root

View File

@ -1,4 +1,4 @@
{% for node_name, node in stack.nodes.iteritems() %}
{% for node_name, node in stack.nodes.items() %}
Host {{node_name}}.{{stack.domain}} {{node_name}}
{% if node.nics is defined %}
HostName {{node.nics.eth0.addrs[0]|ipaddr('address')}}