Adding conditions to patterns
In addition to linking services together with parameters, you can also create branching paths so that one branch or the other is selected based on criteria that you set. The conditional rule that determines what branch to take is defined as a node just like the services themselves. When a condition node is reached, the set of rules in that node are evaluated in the same order as they were defined. When a rule is matched, that branch of the pattern is selected and those services will be displayed to the user for provisioning.The nodes on any branch that is not taken are orphaned and will not be included when the order is submitted. You can include multiple additional nodes, including other conditional rules, within a branch. Any nodes that are come after the branch should have the conditional rule node set as their parent so they will be provisioned after the branch has been completed.
All services that are part of a branch are exclusive to that branch. If you want to use the same service in multiple branches, create duplicates of that service and add them to each branch.
To create a branching pattern, use the following API. In this pattern, NodeIds 1 and 2 are first. After NodeId 2, nodeId 5 is invoked that determines whether the operating system is Linux or Windows. If it is Linux, the chain continues with nodeId 3. Otherwise it continues with nodeId 4. After one of those branches is complete, the provisioning continues with nodeId 6.
API
:
POST /catalog/v2/admin/patterns
{
"providers": [
"aws"
],
"source": [
"serviceoffering"
],
"status": "WorkInProgress",
"chainedSOs": [
{
"nodeId": "1",
"serviceOfferingId": "9ded9fa4-b3af-497f-a6fb-62458c35cf42",
"name": "vpc-for-chaining",
"alias": "",
"additionalOutputParams": [],
"bindingParameters": {},
"provider": "aws",
"providerCode": "aws",
"nodeType": "serviceoffering",
"parents": []
},
{
"nodeId": "2",
"serviceOfferingId": "e5c41b98-b887-43d7-b1ac-0ba4ad0cb897",
"name": "subnet-for-chaining",
"alias": "",
"additionalOutputParams": [],
"bindingParameters": {
"vpc_id": "${chained.1.output.vpc_id}"
},
"provider": "aws",
"providerCode": "aws",
"nodeType": "serviceoffering",
"parents": [
"1"
]
},
{
"nodeId": "3",
"serviceOfferingId": "2235db11-36be-4f06-8fd9-1cd0b2a0e310",
"name": "ec2-for-chaining-linux",
"alias": "",
"additionalOutputParams": [],
"bindingParameters": {
"subnet_id": "${chained.2.output.subnet_id}"
},
"provider": "aws",
"providerCode": "aws",
"nodeType": "serviceoffering",
"parents": []
},
{
"nodeId": "4",
"serviceOfferingId": "fa8d27e1-8675-4827-bdc1-6e3ce67a9942",
"name": "ec2-for-chaining-windows",
"alias": "",
"additionalOutputParams": [],
"bindingParameters": {
"subnet_id": "${chained.2.output.subnet_id}"
},
"provider": "aws",
"providerCode": "aws",
"nodeType": "serviceoffering",
"parents": []
},
{
"nodeId": "6",
"serviceOfferingId": "beb0c57e-d8fb-4a3b-89eb-d81fdf69f27f",
"name": "network-interface-for-chaining",
"alias": "",
"additionalOutputParams": [],
"bindingParameters": {
"subnet_id": "${chained.2.output.subnet_id}",
"instance_id": "${chained.5.output.instance_id}"
},
"provider": "aws",
"providerCode": "aws",
"nodeType": "serviceoffering",
"parents": [
"5"
]
}
],
"conditions": [
{
"name": "OS Condition",
"alias": "",
"nodeId": "5",
"nodeType": "decision",
"parents": [
"2"
],
"rules": {
"3": [
"chainedSO.2.input.items[1].configGroups[2].configs[0].selectedValues[0].label==linux"
],
"4": [
"chainedSO.2.input.items[1].configGroups[2].configs[0].selectedValues[0].label==windows"
]
}
}
],
"patternName": "conditioning-test-6",
"description": "",
"rollbackOnError": true,
"logo": "",
"category": [
"compute"
],
"labels": []
}
Keep in mind the following guidelines when adding conditions:
All branching service nodes belonging to a condition must have empty parents array and cannot be sequenced together with other regular service nodes.
Any regular service node pointing to the condition node as its parent will eventually point to the selected branch node after the condition's rule evaluation.
The selected branch node will eventually point to the parent of the condition node as its parent
It is possible to have a chain of regular service nodes originating from the all or some branch nodes, In this case all the unselected branch nodes are considered orphaned and child nodes of the orphaned nodes are also considered orphaned nodes and all orphaned nodes are deleted in the final result at the time of order submission
Condition nodes should only have a single parent, otherwise the behavior is not known or undefined.
You can create multiple condition nodes and have them sequenced in multiple different ways in the pattern definition.
To submit an order for a pattern with conditions, use this API:
API
:
POST /orders/v2/submit
{
"patternId": "07c23c98-dbe0-11ee-b967-be34a138c43a",
"patternInstancePrefix": "mytest-pattern",
"patternName": "conditioning-test-6",
"context": [
{
"tagValueCode": "Consume_Team1",
"tagType": "team"
},
{
"tagValueCode": "admin_org",
"tagType": "org"
}
],
"requestorAdditionalInfo": {
"presetParams": {}
},
"items": [
{
"providerCode": "aws",
"serviceOfferingId": "9ded9fa4-b3af-497f-a6fb-62458c35cf42",
"providerAccountRefId": "1e55349d-db54-4b9b-8a85-529d601e6837",
"providerCredentialRefId": "ef608a71-c648-4e1a-970f-2e194c225b73",
"nodeId": "1",
"serviceInstancePrefix": "vpc-for-chaining",
"quantity": 1,
"configGroups": [
{
"configGroupCode": "Configure Region",
"sections": [],
"configs": [
{
"configId": "AWS::Region",
"selectedValues": [
{
"label": "us-east-1",
"valueId": "us-east-1"
}
]
}
]
},
{
"configGroupCode": "Aws vpc main",
"sections": [],
"configs": [
{
"configId": "cidr_block",
"selectedValues": [
{
"label": "10.0.0.0/16",
"valueId": "10.0.0.0/16"
}
]
},
{
"configId": "instance_tenancy",
"selectedValues": [
{
"label": "default",
"valueId": "default"
}
]
}
]
}
],
"additionalServices": [],
"alias": "vpc-for-chaining"
},
{
"providerCode": "aws",
"serviceOfferingId": "e5c41b98-b887-43d7-b1ac-0ba4ad0cb897",
"providerAccountRefId": "1e55349d-db54-4b9b-8a85-529d601e6837",
"providerCredentialRefId": "ef608a71-c648-4e1a-970f-2e194c225b73",
"nodeId": "2",
"serviceInstancePrefix": "subnet-for-chaining",
"quantity": 1,
"configGroups": [
{
"configGroupCode": "Configure Region",
"sections": [],
"configs": [
{
"configId": "AWS::Region",
"selectedValues": [
{
"label": "us-east-1",
"valueId": "us-east-1"
}
]
}
]
},
{
"configGroupCode": "Aws subnet public_subnet",
"sections": [],
"configs": [
{
"configId": "vpc_id",
"selectedValues": [
{
"label": "_binding_parameter_",
"valueId": "_binding_parameter_"
}
]
},
{
"configId": "cidr_block",
"selectedValues": [
{
"label": "10.0.1.0/24",
"valueId": "10.0.1.0/24"
}
]
},
{
"configId": "availability_zone",
"selectedValues": [
{
"label": "us-east-1a",
"valueId": "us-east-1a"
}
]
}
]
},
{
"configGroupCode": "Configurations",
"sections": [],
"configs": [
{
"configId": "operating_system",
"selectedValues": [
{
"label": "windows",
"valueId": "windows"
}
]
}
]
}
],
"additionalServices": [],
"alias": "subnet-for-chaining"
},
{
"providerCode": "aws",
"serviceOfferingId": "2235db11-36be-4f06-8fd9-1cd0b2a0e310",
"providerAccountRefId": "1e55349d-db54-4b9b-8a85-529d601e6837",
"providerCredentialRefId": "ef608a71-c648-4e1a-970f-2e194c225b73",
"nodeId": "3",
"serviceInstancePrefix": "ec2-for-chaining-linux",
"quantity": 1,
"configGroups": [
{
"configGroupCode": "Configure Region",
"sections": [],
"configs": [
{
"configId": "AWS::Region",
"selectedValues": [
{
"label": "us-east-1",
"valueId": "us-east-1"
}
]
}
]
},
{
"configGroupCode": "Aws instance server",
"sections": [],
"configs": [
{
"configId": "ami",
"selectedValues": [
{
"label": "ami-0b5eea76982371e91",
"valueId": "ami-0b5eea76982371e91"
}
]
},
{
"configId": "instance_type",
"selectedValues": [
{
"label": "t2.micro",
"valueId": "t2.micro"
}
]
},
{
"configId": "subnet_id",
"selectedValues": [
{
"label": "_binding_parameter_",
"valueId": "_binding_parameter_"
}
]
}
]
}
],
"additionalServices": [],
"alias": "ec2-for-chaining-linux"
},
{
"providerCode": "aws",
"serviceOfferingId": "fa8d27e1-8675-4827-bdc1-6e3ce67a9942",
"providerAccountRefId": "1e55349d-db54-4b9b-8a85-529d601e6837",
"providerCredentialRefId": "ef608a71-c648-4e1a-970f-2e194c225b73",
"nodeId": "4",
"serviceInstancePrefix": "ec2-for-chaining-windows",
"quantity": 1,
"configGroups": [
{
"configGroupCode": "Configure Region",
"sections": [],
"configs": [
{
"configId": "AWS::Region",
"selectedValues": [
{
"label": "us-east-1",
"valueId": "us-east-1"
}
]
}
]
},
{
"configGroupCode": "Aws instance server",
"sections": [],
"configs": [
{
"configId": "ami",
"selectedValues": [
{
"label": "ami-0ee25f582ea1faaac",
"valueId": "ami-0ee25f582ea1faaac"
}
]
},
{
"configId": "instance_type",
"selectedValues": [
{
"label": "t2.micro",
"valueId": "t2.micro"
}
]
},
{
"configId": "subnet_id",
"selectedValues": [
{
"label": "_binding_parameter_",
"valueId": "_binding_parameter_"
}
]
}
]
}
],
"additionalServices": [],
"alias": "ec2-for-chaining-windows"
},
{
"providerCode": "aws",
"serviceOfferingId": "beb0c57e-d8fb-4a3b-89eb-d81fdf69f27f",
"providerAccountRefId": "1e55349d-db54-4b9b-8a85-529d601e6837",
"providerCredentialRefId": "ef608a71-c648-4e1a-970f-2e194c225b73",
"serviceInstancePrefix": "ec2-for-chaining-windows",
"quantity": 1,
"nodeId": "6",
"configGroups": [
{
"configGroupCode": "Configure Region",
"sections": [],
"configs": [
{
"configId": "AWS::Region",
"selectedValues": [
{
"label": "us-east-1",
"valueId": "us-east-1"
}
]
}
]
},
{
"configGroupCode": "Aws network interface network_interface",
"sections": [],
"configs": [
{
"configId": "subnet_id",
"selectedValues": [
{
"label": "_binding_parameter_",
"valueId": "_binding_parameter_"
}
]
},
{
"configId": "instance_id",
"selectedValues": [
{
"label": "_binding_parameter_",
"valueId": "_binding_parameter_"
}
]
}
]
}
],
"additionalServices": []
}
]
}