1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Replace lxc-clone with lxc-copy (#19890) (#20373)

The command lxc-clone is deprecated in favor of lxc-copy. This patch
changes the lxc module to use the new lxc-copy command by default. If
not present, it will fallback to the old lxc-clone command to keep it
backward compatible with older versions of lxc.
This commit is contained in:
Lucas Alvares Gomes 2017-08-17 17:01:47 +01:00 committed by ansibot
parent ff4fa6ac29
commit 119a79cf0c

View file

@ -477,7 +477,15 @@ LXC_COMMAND_MAP = {
}
},
'clone': {
'variables': {
'variables-lxc-copy': {
'backing_store': '--backingstorage',
'lxc_path': '--lxcpath',
'fs_size': '--fssize',
'name': '--name',
'clone_name': '--newname'
},
# lxc-clone is deprecated in favor of lxc-copy
'variables-lxc-clone': {
'backing_store': '--backingstore',
'lxc_path': '--lxcpath',
'fs_size': '--fssize',
@ -788,13 +796,20 @@ class LxcContainerManagement(object):
self.state_change = True
self.container.stop()
# lxc-clone is deprecated in favor of lxc-copy
clone_vars = 'variables-lxc-copy'
clone_cmd = self.module.get_bin_path('lxc-copy')
if not clone_cmd:
clone_vars = 'variables-lxc-clone'
clone_cmd = self.module.get_bin_path('lxc-clone', True)
build_command = [
self.module.get_bin_path('lxc-clone', True),
clone_cmd,
]
build_command = self._add_variables(
variables_dict=self._get_vars(
variables=LXC_COMMAND_MAP['clone']['variables']
variables=LXC_COMMAND_MAP['clone'][clone_vars]
),
build_command=build_command
)
@ -810,7 +825,7 @@ class LxcContainerManagement(object):
rc, return_data, err = self._run_command(build_command)
if rc != 0:
message = "Failed executing lxc-clone."
message = "Failed executing %s." % os.path.basename(clone_cmd)
self.failure(
err=err, rc=rc, msg=message, command=' '.join(
build_command