7046207 TI throwing exception when deleting non-existant Filesystem
7046335 TC should set slice.force, shadow/physical should check force before throwing in use error
--- a/usr/src/lib/install_target/controller.py Thu May 19 14:18:19 2011 -0700
+++ b/usr/src/lib/install_target/controller.py Fri May 20 11:20:00 2011 -0600
@@ -548,6 +548,7 @@
else:
new_slice = disk.add_slice("0", start, slice_size,
Size.sector_units)
+ new_slice.force = True
else:
# Compile a list of the usable slices, if any
slice_list = list()
@@ -568,6 +569,7 @@
disk.delete_children(class_type=Slice)
new_slice = disk.add_slice("0", start, slice_size,
Size.sector_units)
+ new_slice.force = True
else:
for partition in partitions:
if partition.is_solaris and disk.label == "VTOC":
@@ -589,6 +591,7 @@
partition.delete_children(class_type=Slice)
new_slice = partition.add_slice("0", start,
slice_size, Size.sector_units)
+ new_slice.force = True
break
else:
return
@@ -1000,6 +1003,7 @@
Size.sector_units)
new_slice.tag = V_ROOT
+ new_slice.force = True
if self._vdev is not None:
new_slice.in_vdev = self._vdev.name
--- a/usr/src/lib/install_target/logical.py Thu May 19 14:18:19 2011 -0700
+++ b/usr/src/lib/install_target/logical.py Fri May 20 11:20:00 2011 -0600
@@ -415,13 +415,20 @@
@property
def full_name(self):
- """ keep a full_name attribute with the entire ZFS path for the
- filesystem. This is done because Filesystem objects can either be
- created via Zpool.add_filesystem or by simple instantiation
- (Filesystem("tank/fs"))
+ """ Keep a full_name attribute with the entire ZFS path for the
+ filesystem. This is done because Filesystem objects can be created via
+ Zpool.add_filesystem, simple instantiation, or with the in_be attribute
+ set.
"""
if self.parent is not None:
- return os.path.join(self.parent.name, self.name)
+ if self.in_be:
+ # for in_be Filesystem objects, we need to get the BE and add
+ # it instead of the parent
+ be = self.parent.get_first_child(class_type=BE)
+ return os.path.join(self.parent.name, "ROOT", be.name,
+ self.name.lstrip("/"))
+ else:
+ return os.path.join(self.parent.name, self.name.lstrip("/"))
else:
return self.name
@@ -593,17 +600,18 @@
def destroy(self, dry_run, snapshot=None, recursive=False):
""" destroy the filesystem
"""
- cmd = [ZFS, "destroy"]
- if recursive:
- cmd.append("-r")
- if snapshot is not None:
- cmd.append(self.snapname(snapshot))
- else:
- cmd.append(self.full_name)
+ if self.exists:
+ if not dry_run:
+ cmd = [ZFS, "destroy"]
+ if recursive:
+ cmd.append("-r")
+ if snapshot is not None:
+ cmd.append(self.snapname(snapshot))
+ else:
+ cmd.append(self.full_name)
- if not dry_run:
- Popen.check_call(cmd, stdout=Popen.STORE, stderr=Popen.STORE,
- logger=ILN)
+ Popen.check_call(cmd, stdout=Popen.STORE, stderr=Popen.STORE,
+ logger=ILN)
@property
def exists(self):
--- a/usr/src/lib/install_target/shadow/physical.py Thu May 19 14:18:19 2011 -0700
+++ b/usr/src/lib/install_target/shadow/physical.py Fri May 20 11:20:00 2011 -0600
@@ -277,7 +277,7 @@
# check for in_use conflicts. Re-query libdiskmgt due to circular
# import issues with trying to navigate the DOC
stats = self.in_use_check(ctds)
- if stats:
+ if stats and value.action != "preserve" and not value.force:
self.set_error(self.SliceInUseError(stats))
# insert the corrected Slice object
@@ -485,7 +485,7 @@
# check for in_use conflicts. Re-query libdiskmgt due to circular
# import issues with trying to navigate the DOC
stats = self.in_use_check(ctds)
- if stats:
+ if stats and not value.force:
self.set_error(self.SliceInUseError(stats))
# remove the object
--- a/usr/src/lib/install_target/test/test_shadow_list.py Thu May 19 14:18:19 2011 -0700
+++ b/usr/src/lib/install_target/test/test_shadow_list.py Fri May 20 11:20:00 2011 -0600
@@ -1562,3 +1562,11 @@
error = errsvc._ERRORS[0]
self.assertTrue(isinstance(error.error_data[ES_DATA_EXCEPTION],
ShadowPhysical.SliceInUseError))
+
+ def test_force_delete_slice_in_use(self):
+ # the add slice will set an error, but we want to test delete.
+ s = self.disk.add_slice(self.index, 0, 1, Size.gb_units)
+ s.force = True
+ errsvc.clear_error_list()
+ s.delete()
+ self.assertFalse(errsvc._ERRORS)