Exemplo n.º 1
0
    def audit_snapshots(self, clean):
        """
        Display a list of snapshots that should not exist and
        need to be cleaned up
        """
        helper = self.load_conf(self.config)
        first = audit.snapshots(helper)
        if not len(first):
            return 0

        # Sleep for a second, then check again
        sleep(1)
        second = audit.snapshots(helper)

        # If the lists do not match, something must have
        # changed while we were sleeping
        if not audit.compare_lists(first, second, key='snapshot'):
            return self.audit_snapshots(clean=clean)

        # At this point we know the snapshots in the first list
        # Are verifiably bad, and not apart of a transient backup,
        # or clone operation
        print "\nThe following Snapshots should not exist, " \
            "and need to be cleaned up (Use --clean to remove these snapshots)"
        self.display(first)
        if clean:
            lvs = [lv for lv in helper.volumes._scan_volumes()
                   if lv['origin'] != '']
            for snap in first:
                lv = audit.find(snap['snapshot'], lvs)
                helper.volumes.remove_lvm_snapshot(lv)
        return 1
Exemplo n.º 2
0
    def audit_snapshots(self, clean):
        """
        Display a list of snapshots that should not exist and
        need to be cleaned up
        """
        helper = self.load_conf(self.config)
        first = audit.snapshots(helper)
        if not len(first):
            return 0

        # Sleep for a second, then check again
        sleep(1)
        second = audit.snapshots(helper)

        # If the lists do not match, something must have
        # changed while we were sleeping
        if not audit.compare_lists(first, second, key='snapshot'):
            return self.audit_snapshots(clean=clean)

        # At this point we know the snapshots in the first list
        # Are verifiably bad, and not apart of a transient backup,
        # or clone operation
        print "\nThe following Snapshots should not exist, " \
            "and need to be cleaned up (Use --clean to remove these snapshots)"
        self.display(first)
        if clean:
            lvs = [
                lv for lv in helper.volumes._scan_volumes()
                if lv['origin'] != ''
            ]
            for snap in first:
                lv = audit.find(snap['snapshot'], lvs)
                helper.volumes.remove_lvm_snapshot(lv)
        return 1
Exemplo n.º 3
0
    def audit_volumes(self):
        """
        Report any inconsistencies with node
        volumes and what the API reports about the volumes
        """
        helper = self.load_conf(self.config)
        first = audit.volumes(helper)
        if not len(first):
            return 0
        sleep(1)
        second = audit.volumes(helper)

        # If the lists do not match, something must have
        # changed while we were sleeping
        if not audit.compare_lists(first, second, key='volume'):
            return self.audit_volumes()

        print "\n The following Volumes failed to pass audit"
        self.display(first)
        return 1
Exemplo n.º 4
0
    def audit_volumes(self):
        """
        Report any inconsistencies with node
        volumes and what the API reports about the volumes
        """
        helper = self.load_conf(self.config)
        first = audit.volumes(helper)
        if not len(first):
            return 0
        sleep(1)
        second = audit.volumes(helper)

        # If the lists do not match, something must have
        # changed while we were sleeping
        if not audit.compare_lists(first, second, key='volume'):
            return self.audit_volumes()

        print "\n The following Volumes failed to pass audit"
        self.display(first)
        return 1