示例#1
0
文件: __init__.py 项目: tekmans/mmc
    def add_command_quick_with_id(self, idcmd, target, lang, gid = None):
        """
        @param idcmd: id of the quick action
        @type idcmd: str

        @param target: targets, list of computers UUIDs
        @type target: list

        @param lang: language to use for the command title (two characters)
        @type lang: str

        @param gid: if not None, apply command to a group of machine
        @type gid: str
        """
        ctx = self.currentContext
        result, qas = qa_list_files()
        if result and idcmd in qas:
            try:
                desc = qas[idcmd]["title" + lang]
            except KeyError:
                desc = qas[idcmd]["title"]
            if gid:
                # Get all targets corresponding to the computer given group ID
                target = ComputerGroupManager().get_group_results(ctx, gid, 0, -1, '', True)
            # Use maybeDeferred because addCommandQuick will return an error
            # code in case of failure
            d = defer.maybeDeferred(MscDatabase().addCommandQuick, ctx, qas[idcmd]["command"], target, desc, gid)
            d.addCallback(xmlrpcCleanup)
            ret = d
        else:
            ret = -1
        return ret
示例#2
0
    def add_command_quick_with_id(self, idcmd, target, lang, gid=None):
        """
        @param idcmd: id of the quick action
        @type idcmd: str

        @param target: targets, list of computers UUIDs
        @type target: list

        @param lang: language to use for the command title (two characters)
        @type lang: str

        @param gid: if not None, apply command to a group of machine
        @type gid: str
        """
        ctx = self.currentContext
        result, qas = qa_list_files()
        if result and idcmd in qas:
            try:
                desc = qas[idcmd]["title" + lang]
            except KeyError:
                desc = qas[idcmd]["title"]
            if gid:
                # Get all targets corresponding to the computer given group ID
                target = ComputerGroupManager().get_group_results(
                    ctx, gid, 0, -1, '', True)
            # Use maybeDeferred because addCommandQuick will return an error
            # code in case of failure
            d = defer.maybeDeferred(MscDatabase().addCommandQuick, ctx,
                                    qas[idcmd]["command"], target, desc, gid)
            d.addCallback(xmlrpcCleanup)
            ret = d
        else:
            ret = -1
        return ret
示例#3
0
    def send(self):
        if (self.pid == None or self.pid == "") and self.params.has_key("launchAction"):
            # this is a QA passing by the advanced page
            idcmd = self.params["launchAction"]
            result, qas = qa_list_files()
            if result and idcmd in qas:
                self.params["command"] = qas[idcmd]["command"]
            else:
                logging.getLogger().warn("Failed to get the QA %s" % (idcmd))

            self.pinfos = {"files": None, "command": {"command": self.params["command"]}}
            self.pid = None
            self.setRoot("")
        else:
            d = PackageGetA(self.p_api).getPackageDetail(self.pid)
            d.addCallbacks(self.setPackage, self.onError)
示例#4
0
    def send(self):
        if (self.pid == None or self.pid == '') and self.params.has_key('launchAction'):
            # this is a QA passing by the advanced page
            idcmd = self.params['launchAction']
            result, qas = qa_list_files()
            if result and idcmd in qas:
                self.params['command'] = qas[idcmd]['command']
            else:
                logging.getLogger().warn("Failed to get the QA %s"%(idcmd))

            self.pinfos = {
                    "files":None,
                    "command":{"command":self.params['command']}
            }
            self.pid = None
            self.setRoot('')
        else:
            d = PackageGetA(self.p_api).getPackageDetail(self.pid)
            d.addCallbacks(self.setPackage, self.onError)
示例#5
0
文件: __init__.py 项目: tekmans/mmc
def msc_script_list_file():
    return qa_list_files()
示例#6
0
def msc_script_list_file():
    return qa_list_files()