For file-based instances, upon rename, the directory containing
the instance disks is moved. Therefore, the basename needs to
be preserved in this case. Fix this. Note that so far, this
worked by accident as before
94e252a3 file names used to be
"disk" followed by the index.
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Hrvoje Ribicic <riba@google.com>
Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
inst = self._config_data.instances[old_name].Copy()
inst.name = new_name
inst = self._config_data.instances[old_name].Copy()
inst.name = new_name
- for (idx, disk) in enumerate(inst.disks):
- if disk.dev_type == constants.LD_FILE:
+ for (_, disk) in enumerate(inst.disks):
+ if disk.dev_type in [constants.DT_FILE, constants.DT_SHARED_FILE]:
# rename the file paths in logical and physical id
file_storage_dir = os.path.dirname(os.path.dirname(disk.logical_id[1]))
disk.logical_id = (disk.logical_id[0],
utils.PathJoin(file_storage_dir, inst.name,
# rename the file paths in logical and physical id
file_storage_dir = os.path.dirname(os.path.dirname(disk.logical_id[1]))
disk.logical_id = (disk.logical_id[0],
utils.PathJoin(file_storage_dir, inst.name,
+ os.path.basename(disk.logical_id[1])))
disk.physical_id = disk.logical_id
# Actually replace instance object
disk.physical_id = disk.logical_id
# Actually replace instance object