Exemplo n.º 1
0
    def _mark_protected_devices(self):
        """Mark protected devices.

        If a device is protected, mark it as such now. Once the tree
        has been populated, devices' protected attribute is how we will
        identify protected devices.
        """
        protected = []

        # Resolve the protected device specs to devices.
        for spec in self.protected_devices:
            dev = self.devicetree.resolve_device(spec)

            if dev is not None:
                log.debug("Protected device spec %s resolved to %s.", spec,
                          dev.name)
                protected.append(dev)

        # Find the live backing device and its parents.
        live_device_name = find_live_backing_device()

        if live_device_name:
            log.debug("Resolved live device to %s.", live_device_name)
            dev = self.devicetree.get_device_by_name(live_device_name,
                                                     hidden=True)
            protected.append(dev)
            protected.extend(dev.parents)

        # Mark the collected devices as protected.
        for dev in protected:
            log.debug("Marking device %s as protected.", dev.name)
            dev.protected = True
Exemplo n.º 2
0
    def _mark_protected_devices(self):
        """Mark protected devices.

        If a device is protected, mark it as such now. Once the tree
        has been populated, devices' protected attribute is how we will
        identify protected devices.
        """
        protected = []

        # Resolve the protected device specs to devices.
        for spec in self.protected_devices:
            dev = self.devicetree.resolve_device(spec)

            if dev is not None:
                log.debug("Protected device spec %s resolved to %s.", spec, dev.name)
                protected.append(dev)

        # Find the live backing device and its parents.
        live_device_name = find_live_backing_device()

        if live_device_name:
            log.debug("Resolved live device to %s.", live_device_name)
            dev = self.devicetree.get_device_by_name(live_device_name, hidden=True)
            protected.append(dev)
            protected.extend(dev.parents)

        # Mark the collected devices as protected.
        for dev in protected:
            log.debug("Marking device %s as protected.", dev.name)
            dev.protected = True
Exemplo n.º 3
0
    def _mark_protected_devices(self):
        """Mark protected devices.

        If a device is protected, mark it as such now. Once the tree
        has been populated, devices' protected attribute is how we will
        identify protected devices.
        """
        protected = []

        # Resolve the protected device specs to devices.
        for spec in self.protected_devices:
            dev = self.devicetree.resolve_device(spec)

            if dev is not None:
                log.debug("Protected device spec %s resolved to %s.", spec,
                          dev.name)
                protected.append(dev)

        # Find the live backing device and its parents.
        live_device = find_live_backing_device(self.devicetree)

        if live_device:
            log.debug("Resolved live device to %s.", live_device.name)
            protected.append(live_device)
            protected.extend(live_device.parents)

        # For image installation setup_disk_images method marks all local
        # storage disks as ignored so they are protected from teardown.
        # Here we protect also cdrom devices from tearing down that, in case of
        # cdroms, involves unmounting which is undesirable (see bug #1671713).
        if conf.target.is_image:
            protected.extend(dev for dev in self.devicetree.devices
                             if dev.type == "cdrom")

        # Mark the collected devices as protected.
        for dev in protected:
            log.debug("Marking device %s as protected.", dev.name)
            dev.protected = True