Merge branch 'devel' of https://github.com/ansible/ansible into devel
This commit is contained in:
commit
6d78d6c6b1
2 changed files with 39 additions and 9 deletions
|
@ -496,7 +496,7 @@ def reconfigure_vm(vsphere_client, vm, module, esxi, resource_pool, cluster_name
|
||||||
# Change Memory
|
# Change Memory
|
||||||
if vm_hardware['memory_mb']:
|
if vm_hardware['memory_mb']:
|
||||||
|
|
||||||
if vm_hardware['memory_mb'] != vm.properties.config.hardware.memoryMB:
|
if int(vm_hardware['memory_mb']) != vm.properties.config.hardware.memoryMB:
|
||||||
spec = spec_singleton(spec, request, vm)
|
spec = spec_singleton(spec, request, vm)
|
||||||
|
|
||||||
if vm.is_powered_on():
|
if vm.is_powered_on():
|
||||||
|
@ -504,7 +504,7 @@ def reconfigure_vm(vsphere_client, vm, module, esxi, resource_pool, cluster_name
|
||||||
# No hot add but force
|
# No hot add but force
|
||||||
if not memoryHotAddEnabled:
|
if not memoryHotAddEnabled:
|
||||||
shutdown = True
|
shutdown = True
|
||||||
elif vm_hardware['memory_mb'] < vm.properties.config.hardware.memoryMB:
|
elif int(vm_hardware['memory_mb']) < vm.properties.config.hardware.memoryMB:
|
||||||
shutdown = True
|
shutdown = True
|
||||||
else:
|
else:
|
||||||
# Fail on no hot add and no force
|
# Fail on no hot add and no force
|
||||||
|
@ -514,7 +514,7 @@ def reconfigure_vm(vsphere_client, vm, module, esxi, resource_pool, cluster_name
|
||||||
"required for shutdown")
|
"required for shutdown")
|
||||||
|
|
||||||
# Fail on no force and memory shrink
|
# Fail on no force and memory shrink
|
||||||
elif vm_hardware['memory_mb'] < vm.properties.config.hardware.memoryMB:
|
elif int(vm_hardware['memory_mb']) < vm.properties.config.hardware.memoryMB:
|
||||||
module.fail_json(
|
module.fail_json(
|
||||||
msg="Cannot lower memory on a live VM. force is "
|
msg="Cannot lower memory on a live VM. force is "
|
||||||
"required for shutdown")
|
"required for shutdown")
|
||||||
|
@ -525,7 +525,7 @@ def reconfigure_vm(vsphere_client, vm, module, esxi, resource_pool, cluster_name
|
||||||
|
|
||||||
# ====( Config Memory )====#
|
# ====( Config Memory )====#
|
||||||
if vm_hardware['num_cpus']:
|
if vm_hardware['num_cpus']:
|
||||||
if vm_hardware['num_cpus'] != vm.properties.config.hardware.numCPU:
|
if int(vm_hardware['num_cpus']) != vm.properties.config.hardware.numCPU:
|
||||||
spec = spec_singleton(spec, request, vm)
|
spec = spec_singleton(spec, request, vm)
|
||||||
|
|
||||||
if vm.is_powered_on():
|
if vm.is_powered_on():
|
||||||
|
@ -533,7 +533,7 @@ def reconfigure_vm(vsphere_client, vm, module, esxi, resource_pool, cluster_name
|
||||||
# No hot add but force
|
# No hot add but force
|
||||||
if not cpuHotAddEnabled:
|
if not cpuHotAddEnabled:
|
||||||
shutdown = True
|
shutdown = True
|
||||||
elif vm_hardware['num_cpus'] < vm.properties.config.hardware.numCPU:
|
elif int(vm_hardware['num_cpus']) < vm.properties.config.hardware.numCPU:
|
||||||
if not cpuHotRemoveEnabled:
|
if not cpuHotRemoveEnabled:
|
||||||
shutdown = True
|
shutdown = True
|
||||||
else:
|
else:
|
||||||
|
@ -544,7 +544,7 @@ def reconfigure_vm(vsphere_client, vm, module, esxi, resource_pool, cluster_name
|
||||||
"required for shutdown")
|
"required for shutdown")
|
||||||
|
|
||||||
# Fail on no force and cpu shrink without hot remove
|
# Fail on no force and cpu shrink without hot remove
|
||||||
elif vm_hardware['num_cpus'] < vm.properties.config.hardware.numCPU:
|
elif int(vm_hardware['num_cpus']) < vm.properties.config.hardware.numCPU:
|
||||||
if not cpuHotRemoveEnabled:
|
if not cpuHotRemoveEnabled:
|
||||||
module.fail_json(
|
module.fail_json(
|
||||||
msg="Cannot lower CPU on a live VM without "
|
msg="Cannot lower CPU on a live VM without "
|
||||||
|
|
|
@ -151,9 +151,39 @@ def db_import(module, host, user, password, db_name, target, port, socket=None):
|
||||||
cmd += " --host=%s --port=%s" % (pipes.quote(host), pipes.quote(port))
|
cmd += " --host=%s --port=%s" % (pipes.quote(host), pipes.quote(port))
|
||||||
cmd += " -D %s" % pipes.quote(db_name)
|
cmd += " -D %s" % pipes.quote(db_name)
|
||||||
if os.path.splitext(target)[-1] == '.gz':
|
if os.path.splitext(target)[-1] == '.gz':
|
||||||
cmd = 'gunzip < ' + pipes.quote(target) + ' | ' + cmd
|
gunzip_path = module.get_bin_path('gunzip')
|
||||||
|
if gunzip_path:
|
||||||
|
rc, stdout, stderr = module.run_command('%s %s' % (gunzip_path, target))
|
||||||
|
if rc != 0:
|
||||||
|
return rc, stdout, stderr
|
||||||
|
cmd += " < %s" % pipes.quote(os.path.splitext(target)[0])
|
||||||
|
rc, stdout, stderr = module.run_command(cmd, use_unsafe_shell=True)
|
||||||
|
if rc != 0:
|
||||||
|
return rc, stdout, stderr
|
||||||
|
gzip_path = module.get_bin_path('gzip')
|
||||||
|
if gzip_path:
|
||||||
|
rc, stdout, stderr = module.run_command('%s %s' % (gzip_path, os.path.splitext(target)[0]))
|
||||||
|
else:
|
||||||
|
module.fail_json(msg="gzip command not found")
|
||||||
|
else:
|
||||||
|
module.fail_json(msg="gunzip command not found")
|
||||||
elif os.path.splitext(target)[-1] == '.bz2':
|
elif os.path.splitext(target)[-1] == '.bz2':
|
||||||
cmd = 'bunzip2 < ' + pipes.quote(target) + ' | ' + cmd
|
bunzip2_path = module.get_bin_path('bunzip2')
|
||||||
|
if bunzip2_path:
|
||||||
|
rc, stdout, stderr = module.run_command('%s %s' % (bunzip2_path, target))
|
||||||
|
if rc != 0:
|
||||||
|
return rc, stdout, stderr
|
||||||
|
cmd += " < %s" % pipes.quote(os.path.splitext(target)[0])
|
||||||
|
rc, stdout, stderr = module.run_command(cmd, use_unsafe_shell=True)
|
||||||
|
if rc != 0:
|
||||||
|
return rc, stdout, stderr
|
||||||
|
bzip2_path = module.get_bin_path('bzip2')
|
||||||
|
if bzip2_path:
|
||||||
|
rc, stdout, stderr = module.run_command('%s %s' % (bzip2_path, os.path.splitext(target)[0]))
|
||||||
|
else:
|
||||||
|
module.fail_json(msg="bzip2 command not found")
|
||||||
|
else:
|
||||||
|
module.fail_json(msg="bunzip2 command not found")
|
||||||
else:
|
else:
|
||||||
cmd += " < %s" % pipes.quote(target)
|
cmd += " < %s" % pipes.quote(target)
|
||||||
rc, stdout, stderr = module.run_command(cmd, use_unsafe_shell=True)
|
rc, stdout, stderr = module.run_command(cmd, use_unsafe_shell=True)
|
||||||
|
|
Loading…
Reference in a new issue