예제 #1
0
    def set_sources(self, sources):
        """Set at most one source."""
        if len(sources) > 1:
            raise IncompatibleSourceError(
                "You can set only one source for this payload type.")

        super().set_sources(sources)
예제 #2
0
    def set_sources(self, sources):
        """Set a new list of sources to this payload.

        Before setting the sources, please make sure the sources are not initialized otherwise
        the SourceSetupError exception will be raised. Payload have to cleanup after itself.

        ..NOTE:
        The SourceSetupError is a reasonable effort to solve the race condition. However,
        there is still a possibility that the task to initialize sources (`SetupSourcesWithTask()`)
        was created with the old list but not run yet. In that case this check will not work and
        the initialization task will run with the old list.

        :param sources: set a new sources
        :type sources: instance of pyanaconda.modules.payloads.source.source_base.PayloadSourceBase
        :raise: IncompatibleSourceError when source is not a supported type
                SourceSetupError when attached sources are initialized
        """
        for source in sources:
            if source.type not in self.supported_source_types:
                raise IncompatibleSourceError(
                    "Source type {} is not supported by this payload.".format(
                        source.type.value))

        if any(source.get_state() == SourceState.READY
               for source in self.sources):
            raise SourceSetupError(
                "Can't change list of sources if there is at least one source "
                "initialized! Please tear down the sources first.")

        self._sources = sources
        log.debug("New sources %s were added.", sources)
        self.sources_changed.emit()
예제 #3
0
파일: live_os.py 프로젝트: lyj7890/anaconda
    def set_sources(self, sources):
        """Set new sources to this payload.

        This payload is specific that it can't have more than only one source attached. It will
        instead replace the old source with the new one.

        :param source: source object
        :type source: instance of pyanaconda.modules.payloads.source.source_base.PayloadSourceBase
        :raises: IncompatibleSourceError
        """
        if len(sources) > 1:
            raise IncompatibleSourceError(
                "You can set only one source for this payload type.")

        super().set_sources(sources)