コード例 #1
0
class PackageUpdateModel(object):
    def __init__(self, **kargs):
        self.task = TaskModel(**kargs)
        self.objstore = kargs['objstore']
        self.pkgs2update = []
        try:
            self.host_swupdate = SoftwareUpdate()
        except:
            self.host_swupdate = None

    def lookup(self, name):
        if self.host_swupdate is None:
            raise OperationFailed('GGBPKGUPD0004E')

        return self.host_swupdate.getUpdate(name)

    def _resolve_dependencies(self, package=None, dep_list=None):
        """
        Resolve the dependencies for a given package from the dictionary of
        eligible packages to be upgraded.
        """
        if dep_list is None:
            dep_list = []
        if package is None:
            return []
        dep_list.append(package)
        deps = self.host_swupdate.getUpdate(package)['depends']
        for pkg in set(deps).intersection(self.pkgs2update):
            if pkg in dep_list:
                break
            self._resolve_dependencies(pkg, dep_list)
        return dep_list

    def upgrade(self, name):
        """
        Execute the update of a specific package (and its dependencies, if
        necessary) in the system.

        @param: Name
        @return: task
        """
        if self.host_swupdate is None:
            raise OperationFailed('GGBPKGUPD0004E')

        self.pkgs2update = self.host_swupdate.getUpdates()
        pkgs_list = self._resolve_dependencies(name)
        msg = 'The following packages will be updated: ' + ', '.join(pkgs_list)
        wok_log.debug(msg)
        taskid = add_task('/plugins/gingerbase/host/packagesupdate/%s/upgrade'
                          % name, self.host_swupdate.doUpdate,
                          self.objstore, pkgs_list)
        return self.task.lookup(taskid)
コード例 #2
0
class PackageUpdateModel(object):
    def __init__(self, **kargs):
        self.task = TaskModel(**kargs)
        self.objstore = kargs['objstore']
        self.pkgs2update = []
        try:
            self.host_swupdate = SoftwareUpdate()
        except:
            self.host_swupdate = None

    def lookup(self, name):
        if self.host_swupdate is None:
            raise OperationFailed('GGBPKGUPD0004E')

        return self.host_swupdate.getUpdate(name)

    def _resolve_dependencies(self, package=None, dep_list=None):
        """
        Resolve the dependencies for a given package from the dictionary of
        eligible packages to be upgraded.
        """
        if dep_list is None:
            dep_list = []
        if package is None:
            return []
        dep_list.append(package)
        deps = self.host_swupdate.getUpdate(package)['depends']
        for pkg in set(deps).intersection(self.pkgs2update):
            if pkg in dep_list:
                break
            self._resolve_dependencies(pkg, dep_list)
        return dep_list

    def upgrade(self, name):
        """
        Execute the update of a specific package (and its dependencies, if
        necessary) in the system.

        @param: Name
        @return: task
        """
        if self.host_swupdate is None:
            raise OperationFailed('GGBPKGUPD0004E')

        self.pkgs2update = self.host_swupdate.getUpdates()
        pkgs_list = self._resolve_dependencies(name)
        msg = 'The following packages will be updated: ' + ', '.join(pkgs_list)
        wok_log.debug(msg)
        taskid = AsyncTask('/plugins/gingerbase/host/packagesupdate/%s/upgrade'
                           % name, self.host_swupdate.doUpdate, pkgs_list).id
        return self.task.lookup(taskid)
コード例 #3
0
ファイル: host.py プロジェクト: popbjc/kimchi
    def lookup(self, name):
        try:
            swupdate = SoftwareUpdate()
        except Exception:
            raise OperationFailed('GGBPKGUPD0004E')

        return swupdate.getUpdate(name)
コード例 #4
0
    def lookup(self, name):
        try:
            swupdate = SoftwareUpdate()
        except Exception:
            raise OperationFailed('GGBPKGUPD0004E')

        return swupdate.getUpdate(name)