Exemple #1
0
 def _createMsgTask(self, child, task_type):
     """ Creates a MsgTask by getting attributes out of child.
         Arguments:
             child: Child XML element
             task_type: A string representing the type of the task;
             one of pause, escape or notice
         Returns:
             None if found error in element
             array of PauseTask, EscapeTask or NoticeTask on success
     """
     dependency = child.get("dependency")
     if dependency is not None:
         if not self._checkValidDependency(dependency):
             log.error("Dependency {0} for task {1} is invalid".format(
                 dependency, child.attrib["id"]))
             return None
     depsinglehost = utils.get_boolean(child, "depsinglehost")
     optional = utils.get_boolean(child, "optional")
     dynamic = utils.get_boolean(child, "dynamic")
     server = child.attrib["server"]
     swversion = child.get("swversion")
     if swversion is not None and self._hasMissingIniParam(swversion):
         log.debug("swversion " \
           "%s contains parameters that are not present in the ini file" % \
           swversion)
         return None
     osversion = child.get("osversion")
     if osversion is not None and self._hasMissingIniParam(osversion):
         log.debug("osversion " \
           "%s contains parameters that are not present in the ini file" % \
           osversion)
         return None
     checkparams = utils.get_dictionary(child, "checkparams")
     gid = child.get("gid")
     msgVal = child.get("msg")
     if msgVal is not None and self._hasMissingIniParam(msgVal):
         log.debug(("%s msg element %s contains parameters that are not " \
                    "present in the ini file") % (task_type, msgVal))
         return None
     if task_type == "escape":
         task = EscapeTask(child.attrib["id"], self.config,
                           child.attrib["msg"], child.attrib["hosts"],
                           server, swversion, osversion, dependency,
                           optional, depsinglehost, checkparams, gid,
                           dynamic)
     elif task_type == "pause":
         task = PauseTask(child.attrib["id"], self.config,
                          child.attrib["msg"], child.attrib["hosts"],
                          server, swversion, osversion, dependency,
                          optional, depsinglehost, checkparams, gid,
                          dynamic)
     elif task_type == "notice":
         task = NoticeTask(child.attrib["id"], self.config,
                           child.attrib["msg"], child.attrib["hosts"],
                           server, swversion, osversion, dependency,
                           optional, depsinglehost, checkparams, gid)
     else:
         log.debug("Task type %s is not a valid task type" % task_type)
     return task
Exemple #2
0
    def _parseTask(self, child, phasename):
        """ Parses a child element that is a task.

            Args:
                child: Child element
                phasename: Name of phase parsing
            Returns:
                FabricTask instance
        """
        cmd = child.get("cmd")
        #if cmd is present then we need to check that any parameters are valid
        if cmd is not None and self._hasMissingIniParam(cmd):
                log.debug(("cmd %s contains parameters that are not " \
                          "present in the ini file") % cmd)
                return None

        id = child.get("id")
        hosts = child.get("hosts")
        server = child.get("server")
        optional = utils.get_boolean(child, "optional")
        duration = child.get("estimatedDur")
        if duration is not None and self._hasMissingIniParam(duration):
                log.debug(("duration %s contains parameters that are not " \
                          "present in the ini file") % duration)
                return None
        dependency = child.get("dependency")
        depsinglehost = utils.get_boolean(child, "depsinglehost")
        run_local = utils.get_boolean(child, "runLocal")

        if dependency != None:
            if not self._checkValidDependency(dependency):
                log.error("Dependency {0} for task {1} is invalid".\
                        format(dependency, id))
                return None
        swversion = child.get("swversion")
        if swversion is not None and self._hasMissingIniParam(swversion):
            log.debug(("swversion %s contains parameters that are not " \
                      "present in the ini file") % swversion)
            return None
        osversion = child.get("osversion")
        if osversion is not None and self._hasMissingIniParam(osversion):
            log.debug(("osversion %s contains parameters that are not " \
                      "present in the ini file") % osversion)
            return None
        checkparams = utils.get_dictionary(child, "checkparams")
        if phasename == constants.EXECUTE:
            continueOnFail = utils.get_boolean(child, "continueOnFail")
        else:
            continueOnFail = True
        task = self.taskmgr.createTask(id, self.config, cmd, hosts, server,
                                           continueOnFail, optional,
                                           duration, dependency, swversion,
                                           osversion,
                                           run_local, depsinglehost,
                                           checkparams)
        return task
Exemple #3
0
    def _parseMsgTask(self, child, phasename):
        """ Parses a child element that is a message task.

            Args:
                child: Child element
                phasename: Name of phase parsing
            Returns:
                MsgTask instance
        """

        id = child.get("id")
        msg = child.get("msg")
        hosts = child.get("hosts")
        server = child.get("server")
        optional = utils.get_boolean(child, "optional")
        dependency = child.get("dependency")
        depsinglehost = utils.get_boolean(child, "depsinglehost")
        if dependency != None:
            if not self._checkValidDependency(dependency):
                log.error("Dependency {0} for task {1} is invalid".\
                        format(dependency, id))
                return None
        swversion = child.get("swversion")
        if swversion is not None and self._hasMissingIniParam(swversion):
            log.debug("swversion %s contains parameters that are not "
                      "present in the ini file" % swversion)
            return None
        osversion = child.get("osversion")
        gid = child.get("gid")
        if osversion is not None and self._hasMissingIniParam(osversion):
            log.debug("osversion %s contains parameters that are not "
                      "present in the ini file" % osversion)
            return None
        checkparams = utils.get_dictionary(child, "checkparams")
        if child.tag == "escape":
            msgtask = EscapeTask(id, self.config, msg, hosts, server,
                                           swversion, osversion,
                                           dependency, optional,
                                           depsinglehost, checkparams, gid)
        elif child.tag == "pause":
            msgtask = PauseTask(id, self.config, msg, hosts, server,
                                           swversion, osversion,
                                           dependency, optional,
                                           depsinglehost, checkparams, gid)
        elif child.tag == "notice":
            msgtask = NoticeTask(id, self.config, msg, hosts, server,
                                           swversion, osversion,
                                           dependency, optional,
                                           depsinglehost, checkparams, gid)
        else:
            log.error("Task tag type {0} for task {1} is invalid".\
                        format(child.tag, id))
            return None

        return msgtask
Exemple #4
0
    def _parseTask(self, child, phasename):
        """ Parses a child element that is a task.
            Arguments:
                child: Child element
                phasename: Name of phase parsing
            Returns:
                FabricTask instance
        """
        cmd = child.get("cmd")
        #if cmd is present then we need to check that any parameters are valid
        if cmd is not None and self._hasMissingIniParam(cmd):
            log.debug(("cmd %s contains parameters that are not " \
                      "present in the ini file") % cmd)
            return None

        id = child.get("id")
        hosts = child.get("hosts")
        server = child.get("server")
        optional = utils.get_boolean(child, "optional")
        duration = child.get("estimatedDur")
        if duration is not None and self._hasMissingIniParam(duration):
            log.debug(("duration %s contains parameters that are not " \
                      "present in the ini file") % duration)
            return None
        dependency = child.get("dependency")
        depsinglehost = utils.get_boolean(child, "depsinglehost")
        run_local = utils.get_boolean(child, "runLocal")

        if dependency != None:
            if not self._checkValidDependency(dependency):
                log.error("Dependency {0} for task {1} is invalid".\
                        format(dependency, id))
                return None
        swversion = child.get("swversion")
        if swversion is not None and self._hasMissingIniParam(swversion):
            log.debug(("swversion %s contains parameters that are not " \
                      "present in the ini file") % swversion)
            return None
        osversion = child.get("osversion")
        if osversion is not None and self._hasMissingIniParam(osversion):
            log.debug(("osversion %s contains parameters that are not " \
                      "present in the ini file") % osversion)
            return None
        checkparams = utils.get_dictionary(child, "checkparams")
        if phasename == constants.EXECUTE:
            continueOnFail = utils.get_boolean(child, "continueOnFail")
        else:
            continueOnFail = True
        task = self.taskmgr.createTask(id, self.config, cmd, hosts, server,
                                       continueOnFail, optional, duration,
                                       dependency, swversion, osversion,
                                       run_local, depsinglehost, checkparams)
        return task
Exemple #5
0
    def _parseMsgTask(self, child, phasename):
        """ Parses a child element that is a message task.
            Arguments:
                child: Child element
                phasename: Name of phase parsing
            Returns:
                MsgTask instance
        """

        id = child.get("id")
        msg = child.get("msg")
        hosts = child.get("hosts")
        server = child.get("server")
        optional = utils.get_boolean(child, "optional")
        dependency = child.get("dependency")
        depsinglehost = utils.get_boolean(child, "depsinglehost")
        if dependency != None:
            if not self._checkValidDependency(dependency):
                log.error("Dependency {0} for task {1} is invalid".\
                        format(dependency, id))
                return None
        swversion = child.get("swversion")
        if swversion is not None and self._hasMissingIniParam(swversion):
            log.debug("swversion %s contains parameters that are not "
                      "present in the ini file" % swversion)
            return None
        osversion = child.get("osversion")
        gid = child.get("gid")
        if osversion is not None and self._hasMissingIniParam(osversion):
            log.debug("osversion %s contains parameters that are not "
                      "present in the ini file" % osversion)
            return None
        checkparams = utils.get_dictionary(child, "checkparams")
        if child.tag == "escape":
            msgtask = EscapeTask(id, self.config, msg, hosts, server,
                                 swversion, osversion, dependency, optional,
                                 depsinglehost, checkparams, gid)
        elif child.tag == "pause":
            msgtask = PauseTask(id, self.config, msg, hosts, server, swversion,
                                osversion, dependency, optional, depsinglehost,
                                checkparams, gid)
        elif child.tag == "notice":
            msgtask = NoticeTask(id, self.config, msg, hosts, server,
                                 swversion, osversion, dependency, optional,
                                 depsinglehost, checkparams, gid)
        else:
            log.error("Task tag type {0} for task {1} is invalid".\
                        format(child.tag, id))
            return None

        return msgtask
Exemple #6
0
 def _createMsgTask(self, child, task_type):
     """ Creates a MsgTask by getting attributes out of child.
         Arguments:
             child: Child XML element
             task_type: A string representing the type of the task;
             one of pause, escape or notice
         Returns:
             None if found error in element
             array of PauseTask, EscapeTask or NoticeTask on success
     """
     dependency = child.get("dependency")
     if dependency is not None:
         if not self._checkValidDependency(dependency):
             log.error(
             "Dependency {0} for task {1} is invalid".format(
                                         dependency, child.attrib["id"]))
             return None
     depsinglehost = utils.get_boolean(child, "depsinglehost")
     optional = utils.get_boolean(child, "optional")
     dynamic = utils.get_boolean(child, "dynamic")
     server = child.attrib["server"]
     swversion = child.get("swversion")
     if swversion is not None and self._hasMissingIniParam(swversion):
         log.debug("swversion " \
           "%s contains parameters that are not present in the ini file" % \
           swversion)
         return None
     osversion = child.get("osversion")
     if osversion is not None and self._hasMissingIniParam(osversion):
         log.debug("osversion " \
           "%s contains parameters that are not present in the ini file" % \
           osversion)
         return None
     checkparams = utils.get_dictionary(child, "checkparams")
     gid = child.get("gid")
     msgVal = child.get("msg")
     if msgVal is not None and self._hasMissingIniParam(msgVal):
         log.debug(("%s msg element %s contains parameters that are not " \
                    "present in the ini file") % (task_type, msgVal))
         return None
     if task_type == "escape":
         task = EscapeTask(child.attrib["id"], self.config,
                           child.attrib["msg"],
                           child.attrib["hosts"],
                           server, swversion, osversion,
                           dependency, optional,
                           depsinglehost, checkparams,
                           gid, dynamic)
     elif task_type == "pause":
         task = PauseTask(child.attrib["id"], self.config,
                          child.attrib["msg"],
                          child.attrib["hosts"],
                          server, swversion, osversion,
                          dependency, optional,
                          depsinglehost, checkparams,
                          gid, dynamic)
     elif task_type == "notice":
         task = NoticeTask(child.attrib["id"], self.config,
                           child.attrib["msg"],
                           child.attrib["hosts"],
                           server, swversion, osversion,
                           dependency, optional,
                           depsinglehost, checkparams,
                           gid)
     else:
         log.debug("Task type %s is not a valid task type" % task_type)
     return task