示例#1
0
    def update_destination_no_check(self,
                                    flow,
                                    node,
                                    destination,
                                    rule=None):  # pragma: no cover
        """ Update the destination without doing a cycle check """
        # look up our destination, we need this in order to set the correct destination_type
        destination_type = FlowStep.TYPE_ACTION_SET
        action_destination = Flow.get_node(flow, destination, destination_type)
        if not action_destination:
            destination_type = FlowStep.TYPE_RULE_SET
            ruleset_destination = Flow.get_node(flow, destination,
                                                destination_type)
            self.assertTrue(
                ruleset_destination,
                "Unable to find new destination with uuid: %s" % destination)

        actionset = ActionSet.get(flow, node)
        if actionset:
            actionset.destination = destination
            actionset.destination_type = destination_type
            actionset.save()

        ruleset = RuleSet.get(flow, node)
        if ruleset:
            rules = ruleset.get_rules()
            for r in rules:
                if r.uuid == rule:
                    r.destination = destination
                    r.destination_type = destination_type
            ruleset.set_rules(rules)
            ruleset.save()
        else:
            self.fail("Couldn't find node with uuid: %s" % node)
示例#2
0
    def update_destination_no_check(self, flow, node, destination, rule=None):  # pragma: no cover
        """ Update the destination without doing a cycle check """
        # look up our destination, we need this in order to set the correct destination_type
        destination_type = ACTION_SET
        action_destination = Flow.get_node(flow, destination, destination_type)
        if not action_destination:
            destination_type = RULE_SET
            ruleset_destination = Flow.get_node(flow, destination, destination_type)
            self.assertTrue(ruleset_destination, "Unable to find new destination with uuid: %s" % destination)

        actionset = ActionSet.get(flow, node)
        if actionset:
            actionset.destination = destination
            actionset.destination_type = destination_type
            actionset.save()

        ruleset = RuleSet.get(flow, node)
        if ruleset:
            rules = ruleset.get_rules()
            for r in rules:
                if r.uuid == rule:
                    r.destination = destination
                    r.destination_type = destination_type
            ruleset.set_rules(rules)
            ruleset.save()
        else:
            self.fail("Couldn't find node with uuid: %s" % node)
示例#3
0
    def update_destination_no_check(self, flow, node, destination, rule=None):
        """ Update the destination without doing a cycle check """
        actionset = ActionSet.get(flow, node)
        if actionset:
            actionset.destination = destination
            actionset.save()

        ruleset = RuleSet.get(flow, node)
        rules = ruleset.get_rules()
        for r in rules:
            if r.uuid == rule:
                r.destination = destination
        ruleset.set_rules(rules)
        ruleset.save()
示例#4
0
    def update_destination_no_check(self, flow, node, destination, rule=None):
        """ Update the destination without doing a cycle check """
        actionset = ActionSet.get(flow, node)
        if actionset:
            actionset.destination = destination
            actionset.save()

        ruleset = RuleSet.get(flow, node)
        rules = ruleset.get_rules()
        for r in rules:
            if r.uuid == rule:
                r.destination = destination
        ruleset.set_rules(rules)
        ruleset.save()
示例#5
0
        def as_ruleset_obj(self):
            # look for it in the current flow
            ruleset = self.flow.rule_sets.filter(uuid=self.uuid).first()
            if ruleset:
                return ruleset

            # if it no longer exists in the flow, create it in memory
            return RuleSet(
                uuid=self.uuid,
                flow=self.flow,
                label=self.node_json.get("label"),
                operand=self.node_json.get("operand"),
                ruleset_type=self.node_json["ruleset_type"],
                rules=self.node_json["rules"],
                config=self.node_json.get("config"),
                value_type=self.node_json.get("value_type"),
            )