save_to_file() function breaks symbolic link when saving configuration
save_to_file() function breaks symbolic link when saving configuration

Currently the location of the targetcli configuration file is not
configurable (saveconfig.json). The location is : /etc/target
Some users use stateless VMs, with just a persistent device
mounted under /var/lib/diskless.

In order to circumvent the non configurable location of
saveconfig.json, they create a symbolic link in /etc/target
pointing to /var/lib/diskless

Unfortunately, the rtslib save_to_file() function breaks
this symbolic link and creates a new regular file in place of it,
due to the creation of a saveconfig.json.temp file which is
then renamed to saveconfig.json using the os.rename() function.

This patch replace os.rename() with shutil.copyfile() + os.remove(),
using copyfile() instead of rename() will preserve the symbolic link

Signed-off-by: Maurizio Lombardi <954d0c936553fa022eb0631b7a3a263f1388ea3d@redhat.com>

cvubrugier/rtslib-fb