Example #1
0
    def _replace_device(self):
        """Replace the nonexistent device with a new one.

        If something has changed but the device does not exist,
        there is no need to schedule actions on the device. It
        is only necessary to create a new device object which
        reflects the current choices.
        """
        log.debug("Replacing a nonexistent device.")
        device = self._device

        if self._should_remove_device():
            # Remove the current device.
            destroy_device(self._storage, device)

            # We don't want to pass the device if we removed it.
            self._request.device_spec = ""

        # Create a new device.
        log.debug("Creating a new device.")
        arguments = get_device_factory_arguments(self._storage, self._request)
        device = self._storage.factory_device(**arguments)

        # Update the device.
        self._device = device
Example #2
0
    def destroy_device(self, device_name):
        """Destroy the specified device in the storage model.

        :param device_name: a name of the device
        :raise: StorageConfigurationError in case of failure
        """
        device = self._get_device(device_name)
        utils.destroy_device(self.storage, device)
Example #3
0
    def reset_device(self, device_name):
        """Reset the specified device in the storage model.

        FIXME: Merge with destroy_device.

        :param device_name: a name of the device
        :raise: StorageConfigurationError in case of failure
        """
        device = self._get_device(device_name)

        if device.exists:
            # Revert changes done to an existing device.
            self.storage.reset_device(device)
        else:
            # Destroy a non-existing device.
            utils.destroy_device(self.storage, device)