예제 #1
0
    def find_dependencies(self, nodePath, triggerRule="queued"):
        """
        Return a list of nodePaths that need to be complete before the
        input nodePath can be run.
        """

        #cdpCommand = 'cdp -c "%s;info /%s"' % (self.cdpAlias, nodePath)
        #newProcess = subprocess.Popen(cdpCommand, shell=True,
        #                              stdin=subprocess.PIPE,
        #                              stdout=subprocess.PIPE,
        #                              stderr=subprocess.PIPE)
        #stdoutData, stderrData = newProcess.communicate()
        #stdoutList = [line for line in stdoutData.split("\n")if not line.startswith("#")]
        cdpCommand = 'info /%s' % nodePath
        stdoutList, stderrList, retCode = utils.run_cdp_command(
            self.cdpAlias, cdpCommand)
        triggers = []
        triggerLine = False
        for line in stdoutList:
            if not triggerLine:
                if line.startswith("Nodes that trigger this node"):
                    triggerLine = True
            else:
                if line.startswith("Goodbye"):
                    triggerLine = False
                else:
                    triggerExp, triggerStatus = line.split()
                    triggerStatus = triggerStatus[
                        1:-1]  # removing the square brackets
                    triggers.append((triggerExp, triggerStatus))
        return [tExp for tExp, tRule in triggers if tRule == triggerRule]
예제 #2
0
    def find_dependencies(self, nodePath, triggerRule="queued"):
        """
        Return a list of nodePaths that need to be complete before the
        input nodePath can be run.
        """

        #cdpCommand = 'cdp -c "%s;info /%s"' % (self.cdpAlias, nodePath)
        #newProcess = subprocess.Popen(cdpCommand, shell=True,
        #                              stdin=subprocess.PIPE,
        #                              stdout=subprocess.PIPE, 
        #                              stderr=subprocess.PIPE)
        #stdoutData, stderrData = newProcess.communicate()
        #stdoutList = [line for line in stdoutData.split("\n")if not line.startswith("#")]
        cdpCommand = 'info /%s' % nodePath
        stdoutList, stderrList, retCode = utils.run_cdp_command(self.cdpAlias,
                                                                cdpCommand)
        triggers = []
        triggerLine = False
        for line in stdoutList:
            if not triggerLine:
                if line.startswith("Nodes that trigger this node"):
                    triggerLine = True
            else:
                if line.startswith("Goodbye"):
                    triggerLine = False
                else:
                    triggerExp, triggerStatus = line.split()
                    triggerStatus = triggerStatus[1:-1] # removing the square brackets
                    triggers.append((triggerExp, triggerStatus))
        return [tExp for tExp, tRule in triggers if tRule == triggerRule]
예제 #3
0
    def cancel_node(self, nodePath):
        """
        Run an external CDP command to cancel the node.

        Inputs:
            nodePath - A string specifying the CDP path to the node.

        Returns: the return code of the external CDP process.
        """

        cdpCancelCommand = 'cancel -yf %s' % nodePath
        stdoutList, stderrList, returnCode = utils.run_cdp_command(
            self.cdpAlias, cdpCancelCommand)
        return returnCode
예제 #4
0
    def cancel_node(self, nodePath):
        """
        Run an external CDP command to cancel the node.

        Inputs:
            nodePath - A string specifying the CDP path to the node.

        Returns: the return code of the external CDP process.
        """

        cdpCancelCommand = 'cancel -yf %s' % nodePath
        stdoutList, stderrList, returnCode = utils.run_cdp_command(
                self.cdpAlias, cdpCancelCommand)
        return returnCode
예제 #5
0
    def get_node_status(self, nodePath):
        """
        Run an external CDP command to get the status of a node.

        Inputs:
            nodePath - A string specifying the CDP path to the node.

        Returns: The status of the input nodePath, or None.
        """

        cdpStatusCommand = 'status -m full %s' % nodePath
        stdoutList = utils.run_cdp_command(self.cdpAlias, cdpStatusCommand)[0]
        statusLine = stdoutList[2]
        foundStatus = re.search(r"[[{][a-z]+ *[]}]", statusLine)
        if foundStatus is not None:
            pathStatus = foundStatus.group()[1:-1].strip()
        else:
            pathStatus = None
        return pathStatus
예제 #6
0
    def get_node_status(self, nodePath):
        """
        Run an external CDP command to get the status of a node.

        Inputs:
            nodePath - A string specifying the CDP path to the node.

        Returns: The status of the input nodePath, or None.
        """

        cdpStatusCommand = 'status -m full %s' % nodePath
        stdoutList = utils.run_cdp_command(self.cdpAlias, cdpStatusCommand)[0]
        statusLine = stdoutList[2]
        foundStatus = re.search(r"[[{][a-z]+ *[]}]", statusLine)
        if foundStatus is not None:
            pathStatus = foundStatus.group()[1:-1].strip()
        else:
            pathStatus = None
        return pathStatus