storage: drop rename support
Since VM name is immutable, rename method can be dropped from storage API. QubesOS/qubes-issues#2868
This commit is contained in:
parent
dd1e05dc83
commit
697eb05c20
@ -486,13 +486,6 @@ class Storage(object):
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def rename(self, old_name, new_name):
|
|
||||||
''' Notify the pools that the domain was renamed '''
|
|
||||||
volumes = self.vm.volumes
|
|
||||||
for name, volume in volumes.items():
|
|
||||||
pool = volume.pool
|
|
||||||
volumes[name] = pool.rename(volume, old_name, new_name)
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def verify(self):
|
def verify(self):
|
||||||
'''Verify that the storage is sane.
|
'''Verify that the storage is sane.
|
||||||
@ -722,10 +715,6 @@ class Pool(object):
|
|||||||
'''
|
'''
|
||||||
raise self._not_implemented("init_volume")
|
raise self._not_implemented("init_volume")
|
||||||
|
|
||||||
def rename(self, volume, old_name, new_name):
|
|
||||||
''' Called when the domain changes its name '''
|
|
||||||
raise self._not_implemented("rename")
|
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
''' Called when adding a pool to the system. Use this for implementation
|
''' Called when adding a pool to the system. Use this for implementation
|
||||||
specific set up.
|
specific set up.
|
||||||
|
@ -79,26 +79,6 @@ class FilePool(qubes.storage.Pool):
|
|||||||
self._volumes += [volume]
|
self._volumes += [volume]
|
||||||
return volume
|
return volume
|
||||||
|
|
||||||
def rename(self, volume, old_name, new_name):
|
|
||||||
assert issubclass(volume.__class__, FileVolume)
|
|
||||||
subdir, _, volume_path = volume.vid.split('/', 2)
|
|
||||||
|
|
||||||
if volume._is_origin:
|
|
||||||
# TODO: Renaming the old revisions
|
|
||||||
new_path = os.path.join(self.dir_path, subdir, new_name)
|
|
||||||
if not os.path.exists(new_path):
|
|
||||||
os.mkdir(new_path, 0o755)
|
|
||||||
new_volume_path = os.path.join(new_path, self.name + '.img')
|
|
||||||
if not volume.backward_comp:
|
|
||||||
os.rename(volume.path, new_volume_path)
|
|
||||||
new_volume_path_cow = os.path.join(new_path, self.name + '-cow.img')
|
|
||||||
if os.path.exists(new_volume_path_cow) and not volume.backward_comp:
|
|
||||||
os.rename(volume.path_cow, new_volume_path_cow)
|
|
||||||
|
|
||||||
volume.vid = os.path.join(subdir, new_name, volume_path)
|
|
||||||
|
|
||||||
return volume
|
|
||||||
|
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -157,9 +157,6 @@ class LinuxKernel(Pool):
|
|||||||
def import_volume(self, dst_pool, dst_volume, src_pool, src_volume):
|
def import_volume(self, dst_pool, dst_volume, src_pool, src_volume):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def rename(self, volume, old_name, new_name):
|
|
||||||
return volume
|
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -88,23 +88,6 @@ class ThinPool(qubes.storage.Pool):
|
|||||||
volume_config['pool'] = self
|
volume_config['pool'] = self
|
||||||
return ThinVolume(**volume_config)
|
return ThinVolume(**volume_config)
|
||||||
|
|
||||||
def rename(self, volume, old_name, new_name):
|
|
||||||
''' Called when the domain changes its name '''
|
|
||||||
new_vid = "{!s}/vm-{!s}-{!s}".format(self.volume_group, new_name,
|
|
||||||
volume.name)
|
|
||||||
if volume.save_on_stop:
|
|
||||||
cmd = ['clone', volume.vid, new_vid]
|
|
||||||
qubes_lvm(cmd, self.log)
|
|
||||||
cmd = ['remove', volume.vid]
|
|
||||||
qubes_lvm(cmd, self.log)
|
|
||||||
|
|
||||||
volume.vid = new_vid
|
|
||||||
|
|
||||||
if volume.snap_on_start:
|
|
||||||
volume._vid_snap = volume.vid + '-snap'
|
|
||||||
reset_cache()
|
|
||||||
return volume
|
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
pass # TODO Should we create a non existing pool?
|
pass # TODO Should we create a non existing pool?
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user