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
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
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)
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)
def msc_script_list_file(): return qa_list_files()