Skip to content

Commit bd61d0f

Browse files
authored
Merge pull request ManageIQ#23 from kbrock/sm-md-lg
Add small medium large provisioning example
2 parents ab14156 + 8c8f0a5 commit bd61d0f

File tree

2 files changed

+179
-0
lines changed

2 files changed

+179
-0
lines changed

provision-sm-md-lg/README.md

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Provision VM Service Small Medium Large Example
2+
3+
This example shows creating a provisioning dialog that modifies provisioning parameters.
4+
5+
## Architecture
6+
7+
- `provision-vm-small-med-large.asl`: This workflow is run for every vm provisioned and is responsible for modifying the vm size. This is the ManageIQ Service's Provisioning Entry Point.
8+
9+
Set the ManageIQ provisioning service entry point to this script. For example, this workflow is run for every provisioned Virtual Machine (VM), and modifies the VM size.
10+
11+
## Add a Workflow Repository
12+
13+
1. **Click Automation** > **Embedded Workflows** > **Repositories**.
14+
2. **Click Configuration** > **Add new Repository**.
15+
3. Provide the `Name` and `URL` for the repository:
16+
- **Name**: Local name to identify this repository. For example, `Example Workflows`.
17+
- **Url**: Git repository URL. For example, `https://github.com/ManageIQ/workflows-examples`.
18+
4. Click **Save**.
19+
20+
## Create a Provisioning Dialog
21+
22+
1. Click **Automation** > **Embedded Automate** > **Customization**.
23+
2. Click **Service Dialogs** > **All Dialogs**.
24+
3. Click **Configuration** > **Add a new Dialog**.
25+
4. Provide a `Name` and `Description` for the dialog:
26+
- **Name**: Name used in the Service Catalog. For example, `sm-med-lg dialog`.
27+
- **Description**: More information. For example, `Dialog choosing vm size`.
28+
5. Add a text box named **vm_name**.
29+
6. Add a dropdown named **size**.
30+
7. Click the edit pencil icon for the **size** dropdown.
31+
8. Under **Options** > **Entries** enter the dropdown values:
32+
- Change the first entry:
33+
- For **Name** field, enter **Large**.
34+
- For **Value** field, enter **large**.
35+
- Change the second entry:
36+
- For **Name** field, enter **Medium**.
37+
- For **Value** field, enter **medium**.
38+
- Change the third entry:
39+
- For **Name** field, enter **Small**.
40+
- For **Value** field, enter **small**.
41+
9. Click **Save**.
42+
43+
## Create a Service Catalog Item
44+
45+
1. Click **Service** > **Catalogs**.
46+
2. Click **Catalogs** > **All Catalogs**.
47+
3. Click **Configuration** > **Add a New Catalog**.
48+
4. Provide a `Name` and `Description`:
49+
- **Name**: Name displayed in the catalog. For example, `Provision Vm`.
50+
- **Description**: More information. For example, `Provisioning Vm by size`.
51+
5. Click **Save**.
52+
6. Click **Catalog Items** > **All Catalog Items** > **Provisioning**.
53+
7. Click **Configuration** > **Add a New Catalog Item**.
54+
- 8. **Catalog Item Type**: The functionality of this catalog item. Choose `VmWare`.
55+
9. Under the **Basic Information** tab, provide the default VM values:
56+
- **Name**: Name displayed in the catalog. For example, `Provision Vm with Size`.
57+
- **Description**: More information. For example, `Provision a vm choosing size`.
58+
- **Display in Catalog**: Check to display this catalog item.
59+
- **Catalog**: Organization concept. For example, `My Company/Provisioning`.
60+
- **Dialog**: The dialog created above. For example, `sm-med-lg dialog`.
61+
- **Provisioning Entry Point**:
62+
- For **endpoint type**, choose **Embedded Workflow**.
63+
- For the **endpoint value** choose the workflow chosen above. For example, `provision-vm-small-med-large.asl`.
64+
17. Under the **Request Info** > **Catalog** tab enter the following values:
65+
- **VM Name**: Name that will be overwritten by the **VM name** in the dialog. Enter anything here.
66+
20. Under the **Environment** tab, choose an appropriate **Host** and **Datastore**:
67+
- **Host**: Host that runs the VM.
68+
- **Datastore**: Disk that stores the VM.
69+
22. Under the **Networking** tab, choose an appropriate **Network Adapter**.
70+
24. Click **Add**.
71+
72+
## Provisioning a Virtual Machine
73+
74+
1. Click **Services** > **Catalogs** > **Service Catalogs**.
75+
2. Click **Order** under the newly created service, **Vm with Size**.
76+
3. Provide the following fields:
77+
- **VM name**: Name for the newly created vm. For example `demo-1`.
78+
- **size**: The desired vm size. For example, **small**.
79+
1. Click **Submit**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
{
2+
"Comment": "Provision VM with choice for small medium large",
3+
"StartAt": "DetermineSize",
4+
"States": {
5+
"DetermineSize": {
6+
"Comment": "Determine dialog value",
7+
"Type": "Choice",
8+
"Choices": [
9+
{
10+
"Variable": "$.size",
11+
"StringEquals": "small",
12+
"Next": "SmallSizeState"
13+
},
14+
{
15+
"Variable": "$.size",
16+
"StringEquals": "medium",
17+
"Next": "MediumSizeState"
18+
},
19+
{
20+
"Variable": "$.size",
21+
"StringEquals": "large",
22+
"Next": "LargeSizeState"
23+
}
24+
],
25+
"Default": "SmallSizeState"
26+
},
27+
"SmallSizeState": {
28+
"Type": "Pass",
29+
"Next": "SmallSetMemory"
30+
},
31+
"SmallSetMemory": {
32+
"Comment": "set vm_memory=2GB for small",
33+
"Type": "Pass",
34+
"ResultPath": "$.vm_memory",
35+
"Result": "2048",
36+
"Next": "SmallSetCpus"
37+
},
38+
"SmallSetCpus": {
39+
"Comment": "1 cpu for small",
40+
"Type": "Pass",
41+
"ResultPath": "$.number_of_sockets",
42+
"Result": "1",
43+
"Next": "Provision"
44+
},
45+
"MediumSizeState": {
46+
"Type": "Pass",
47+
"Next": "MediumSetMemory"
48+
},
49+
"MediumSetMemory": {
50+
"Comment": "set vm_memory=4GB for medium",
51+
"Type": "Pass",
52+
"ResultPath": "$.vm_memory",
53+
"Result": "4096",
54+
"Next": "MediumSetCpus"
55+
},
56+
"MediumSetCpus": {
57+
"Comment": "2 cpus for medium",
58+
"Type": "Pass",
59+
"ResultPath": "$.number_of_sockets",
60+
"Result": "2",
61+
"Next": "Provision"
62+
},
63+
"LargeSizeState": {
64+
"Type": "Pass",
65+
"Next": "LargeSetMemory"
66+
},
67+
"LargeSetMemory": {
68+
"Comment": "set vm_memory=8GB for large",
69+
"Type": "Pass",
70+
"ResultPath": "$.vm_memory",
71+
"Result": "8192",
72+
"Next": "LargeSetCpus"
73+
},
74+
"LargeSetCpus": {
75+
"Comment": "4 cpus for large",
76+
"Type": "Pass",
77+
"ResultPath": "$.number_of_sockets",
78+
"Result": "4",
79+
"Next": "Provision"
80+
},
81+
"Provision": {
82+
"Type": "Task",
83+
"Resource": "manageiq://provision_execute",
84+
"Next": "SendEmail"
85+
},
86+
"SendEmail": {
87+
"Type": "Task",
88+
"Resource": "manageiq://email",
89+
"Parameters": {
90+
91+
"Title": "Your provisioning has completed",
92+
"Body": "Your provisioning request has completed"
93+
},
94+
"Next": "Finished"
95+
},
96+
"Finished": {
97+
"Type": "Succeed"
98+
}
99+
}
100+
}

0 commit comments

Comments
 (0)