Esempio n. 1
0
    def insert(self, index, value):
        """
        insert() - overridden method for validation of logical DOC objects

        the following checks are done as part of validation:

        - duplicate dataset name (zfs filesystems and zvolss)

        - duplicate dataset mountpoint (zfs filesystems)

        - verifies the <logical> tag's noswap and nodump values do not conflict
          with the use attribute of a Zvol object

        - more than 1 zvol with maximum size per pool
        """
        # reset the errsvc for Logical errors
        errsvc.clear_error_list_by_mod_id(self.mod_id)

        # check the existing datasets for name and mountpoint overlap
        for dataset in self._shadow:
            # look for name duplication if not an Options object
            if not hasattr(value, "OPTIONS_PARAM_STR") and \
               value.name == dataset.name:
                self.set_error(self.DuplicateDatasetNameError(dataset.name))

            # check the mountpoint if this is a Filesystem object
            if hasattr(value, "mountpoint") and hasattr(dataset, "mountpoint"):
                if value.mountpoint is not None and \
                   value.mountpoint.lower() not in ["none", "legacy"] and \
                   value.mountpoint == dataset.mountpoint:
                    self.set_error(
                        self.DuplicateMountpointError(dataset.name,
                                                      dataset.mountpoint))

            # check for multiple zvol with max size in same pool
            if hasattr(value, "use") and hasattr(dataset, "use"):
                if isinstance(value.size, str) and \
                   isinstance(dataset.size, str) and  value.size == "max" and \
                   dataset.size == "max" and \
                   self.container.name == dataset.parent.name:
                    self.set_error(
                        self.MaxSizeZvolError(value.name, dataset.name))

        # check the 'use' attribute for Zvol objects.  The grandparent of the
        # entry is the <logical> element
        if hasattr(value, "use") and value.use is not "none":
            if value.use == "swap" and self.container.parent.noswap:
                self.set_error(self.NoswapMismatchError())
            if value.use == "dump" and self.container.parent.nodump:
                self.set_error(self.NodumpMismatchError())

        # insert the filesystem
        ShadowList.insert(self, index, value)
Esempio n. 2
0
    def remove(self, value):
        # reset the errsvc for Physical errors
        errsvc.clear_error_list_by_mod_id(self.mod_id)

        # Check slices or GPT partitions for in use conclicts
        if hasattr(value, "force"):
            # check for in_use conflicts.
            stats = self.in_use_check(value)
            if stats and not value.force:
                self.set_error(self.SliceInUseError(stats))

        # remove the object
        ShadowList.remove(self, value)
Esempio n. 3
0
    def insert(self, index, value):
        # check the container object's adjust_boundaries attribute.  If False,
        # simply insert the object into the shadow list
        if hasattr(self.container, "validate_children") and \
           not self.container.validate_children:
            ShadowList.insert(self, index, value)
        else:
            # reset the errsvc for Physical errors
            errsvc.clear_error_list_by_mod_id(self.mod_id)

            # Check the value to see what kind of DOC object we're trying to
            # insert. We can't import the classes from target.physical because
            # it results in a circular import, so look at class name instead.
            insert_map = {"GPTPartition": self.insert_gptpartition,
                          "Slice": self.insert_slice,
                          "Partition": self.insert_partition}
            insert_map[value.__class__.__name__](index, value)
Esempio n. 4
0
    def insert(self, index, value):
        # check the container object's adjust_boundaries attribute.  If False,
        # simply insert the object into the shadow list
        if hasattr(self.container, "validate_children") and \
           not self.container.validate_children:
            ShadowList.insert(self, index, value)
        else:
            # reset the errsvc for Physical errors
            errsvc.clear_error_list_by_mod_id(self.mod_id)

            # check the value to see what kind of DOC object we're trying to
            # insert.
            if hasattr(value, "force"):
                # this is a Slice object, so call insert_slice
                self.insert_slice(index, value)
            elif hasattr(value, "part_type"):
                # this is a Partition object, so call insert_partition
                self.insert_partition(index, value)
    def insert(self, index, value):
        # check the container object's adjust_boundaries attribute.  If False,
        # simply insert the object into the shadow list
        if hasattr(self.container, "validate_children") and \
           not self.container.validate_children:
            ShadowList.insert(self, index, value)
        else:
            # reset the errsvc for Physical errors
            errsvc.clear_error_list_by_mod_id(self.mod_id)

            # check the value to see what kind of DOC object we're trying to
            # insert.
            if hasattr(value, "force"):
                # this is a Slice object, so call insert_slice
                self.insert_slice(index, value)
            elif hasattr(value, "part_type"):
                # this is a Partition object, so call insert_partition
                self.insert_partition(index, value)
Esempio n. 6
0
    def test_clear_error_list_by_mod_id(self):
        '''Testing: clear_error_list_by_mod_id(mod_id)'''

        errsvc.clear_error_list()

        # add two errors, each with their own mod_id
        error1 = errsvc.ErrorInfo(self.mod_id, self.error_types[0])
        error2 = errsvc.ErrorInfo("mod2", self.error_types[0])

        # verify there are 2 errors in the list
        self.assertEqual(len(errsvc.get_all_errors()), 2)

        # remove all "mod1" mod_ids from the list
        errsvc.clear_error_list_by_mod_id(self.mod_id)

        # verify there is only 1 error in the list and that it's mod_id is
        # correct
        self.assertEqual(len(errsvc.get_all_errors()), 1)

        errors = errsvc.get_errors_by_mod_id("mod2")
        self.assertEqual(len(errors), 1)
        self.assertEqual(errors[0].mod_id, "mod2")
Esempio n. 7
0
    def remove(self, value):
        # reset the errsvc for Physical errors
        errsvc.clear_error_list_by_mod_id(self.mod_id)

        # look for slices only
        if hasattr(value, "force"):
            # set the ctds of the slice
            if hasattr(self.container, "geometry"):
                # container is a Disk object
                ctds = self.container.ctd + "s%s" % value.name
            elif hasattr(self.container, "part_type"):
                # container is a Partition object
                ctds = self.container.parent.ctd + "s%s" % value.name

            # 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 and not value.force:
                self.set_error(self.SliceInUseError(stats))

        # remove the object
        ShadowList.remove(self, value)
    def remove(self, value):
        # reset the errsvc for Physical errors
        errsvc.clear_error_list_by_mod_id(self.mod_id)

        # look for slices only
        if hasattr(value, "force"):
            # set the ctds of the slice
            if hasattr(self.container, "geometry"):
                # container is a Disk object
                ctds = self.container.ctd + "s%s" % value.name
            elif hasattr(self.container, "part_type"):
                # container is a Partition object
                ctds = self.container.parent.ctd + "s%s" % value.name

            # 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 and not value.force:
                self.set_error(self.SliceInUseError(stats))

        # remove the object
        ShadowList.remove(self, value)