Skip to content

How To: Author a ForgeTree

Travis Jensen edited this page May 28, 2020 · 29 revisions

How-To: Author a ForgeTree

Suggested Readings

Using the ForgeEditor

Creating your first ForgeTree

Roslyn and C#|

Adding a TreeNode

How to Execute a ForgeAction with ActionInput

Native ForgeActions

Adding a Subroutine Tree

Using Session

Using UserContext

Using RetryPolicy and Timeout

How-To: Author a ForgeTree

This page provides a detailed guide how to author a ForgeTree and utilize the various features of Forge.

Suggested Readings

Overview of ForgeTree Properties

How Forge TreeWalker Walks the ForgeTree

Using the ForgeEditor

ForgeTree and Subroutines

Crafting your ForgeTree

Basic ForgeTree Template

{
    "Tree": {
        "Root": {
            "Type": "Selection",
            "ChildSelector": [
                {
                    "Label": "Container",
                    "ShouldSelect": "C#|UserContext.ResourceType == \"Container\"",
                    "Child": "Container"
                },
                {
                    "Label": "Node",
                    "ShouldSelect": "C#|UserContext.ResourceType == \"Node\"",
                    "Child": "Node"
                }
            ]
        },
        "Container": {
            "Type": "Action",
            "Actions": {
                "Container_CollectDiagnosticsAction": {
                    "Action": "CollectDiagnosticsAction"
                }
            },
            "ChildSelector": [
                {
                    "Label": "Tardigrade",
                    "ShouldSelect": "C#|Session.GetLastActionResponse().Status == \"Success\"",
                    "Child": "Tardigrade"
                }
            ]
        },
        "Tardigrade": {
            "Type": "Action",
            "Actions": {
                "Tardigrade_TardigradeAction": {
                    "Action": "TardigradeAction",
                    "Input": {
                        "Context": "ContainerFault",
                        "EnableV2": true,
                        "DiagnosticData": "C#|Session.GetLastActionResponse().Output"
                    }
                }
            },
            "ChildSelector": [
                {
                    "Label": "Tardigrade_Success",
                    "ShouldSelect": "C#|(await Session.GetOutputAsync(\"Tardigrade_TardigradeAction\")).Status == \"Success\"",
                    "Child": "Tardigrade_Success"
                },
                {
                    "Label": "Tardigrade_Failure",
                    "Child": "Tardigrade_Failure"
                }
            ]
        },
        "Tardigrade_Success": {
            "Type": "Leaf"
        },
        "Tardigrade_Failure": {
            "Type": "Leaf",
                "Actions": {
                    "Tardigrade_Failure_LeafNodeSummaryAction": {
                        "Action": "LeafNodeSummaryAction",
                        "Input": {
                            "Status": "TestStatusValue",
                            "Output": "C#|TreeInput as string ?? \"NA\""
                        }
                    }
                }
        },
        "Node": {
            "Type": "Selection",
            "ChildSelector": [
                {
                    "Label": "Reboot",
                    "ShouldSelect": "C#|UserContext.ShouldReboot()",
                    "Child": "Reboot"
                },
                {
                    "Label": "Evacuate",
                    "Child": "Evacuate"
                }
            ]
        },
        "Reboot": {
            "Type": "Action",
            "Actions": {
                "Reboot_RebootAction": {
                    "Action": "RebootAction",
                    "RetryPolicy": {
                        "Type": "FixedCount",
                        "MaxRetryCount": 3,
                        "MinBackoffMs": 1000
                    },
                    "ContinuationOnRetryExhaustion": true
                }
            }
        },
        "Evacuate": {
            "Type": "Action",
            "Actions": {
                "Evacuate_EvacuateAction": {
                    "Action": "EvacuateAction",
                        "Timeout": 60000,
                        "ContinuationOnTimeout": true
                }
            }
        }
    }
}

Creating your first ForgeTree

Roslyn and C#|

Adding a TreeNode

How to Execute a ForgeAction with ActionInput

Native ForgeActions

Adding a Subroutine Tree

Using Session

Using UserContext

Using RetryPolicy and Timeout

Clone this wiki locally