forked from saratov/infra
Python3 support fixes
This commit is contained in:
parent
626e28687a
commit
17ecb2d824
@ -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)
|
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]
|
# 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):
|
if isinstance(kwargs[k], dict):
|
||||||
kwargs.update(kwargs[k])
|
kwargs.update(kwargs[k])
|
||||||
del 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]
|
#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]
|
# 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):
|
if isinstance(kwargs[k], dict):
|
||||||
kwargs.update(kwargs[k])
|
kwargs.update(kwargs[k])
|
||||||
del 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)
|
module.exit_json(changed=True, msg="VM %s with vmid %s deployed" % (name, vmid), **results)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if update:
|
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:
|
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:
|
else:
|
||||||
module.fail_json(msg="creation of %s VM %s with vmid %s failed with exception=%s" % (VZ_TYPE, name, vmid, e))
|
module.fail_json(msg="creation of %s VM %s with vmid %s failed with exception=%s" % (VZ_TYPE, name, vmid, e))
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ def dict_merge(dct, merge_dct):
|
|||||||
:param merge_dct: dct merged into dct
|
:param merge_dct: dct merged into dct
|
||||||
:return: None
|
: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)
|
if (k in dct and isinstance(dct[k], dict)
|
||||||
and isinstance(merge_dct[k], collections.Mapping)):
|
and isinstance(merge_dct[k], collections.Mapping)):
|
||||||
dict_merge(dct[k], merge_dct[k])
|
dict_merge(dct[k], merge_dct[k])
|
||||||
@ -115,7 +115,7 @@ def get_steps(node, steps_list):
|
|||||||
|
|
||||||
def filter_dict(src, pred):
|
def filter_dict(src, pred):
|
||||||
p = eval(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):
|
def format2(what, fmt):
|
||||||
return fmt % what
|
return fmt % what
|
||||||
|
@ -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}}
|
Host {{node_name}}.{{stack.domain}} {{node_name}}
|
||||||
HostName {{node.net.eth0.ipv4[0]|ipaddr('address')}}
|
HostName {{node.net.eth0.ipv4[0]|ipaddr('address')}}
|
||||||
User root
|
User root
|
||||||
|
@ -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}}
|
Host {{node_name}}.{{stack.domain}} {{node_name}}
|
||||||
{% if node.nics is defined %}
|
{% if node.nics is defined %}
|
||||||
HostName {{node.nics.eth0.addrs[0]|ipaddr('address')}}
|
HostName {{node.nics.eth0.addrs[0]|ipaddr('address')}}
|
||||||
|
Loading…
Reference in New Issue
Block a user