Calculate Custom Costs
Commander allows you to use formulas to create custom cost calculations. List-type custom attributes are used to apply these cost calculations. When you add a custom cost attribute to a cost model and then assign a value for the attribute to a VM, template, or virtual service covered by that cost model, the custom cost is included in the total cost for the service.
When you also add the custom cost attribute to a request form, user selections provide input to the calculation, so that the custom cost is added to the displayed cost of the requested service. If the custom cost attribute on the form is also configured for VMs and virtual services, the custom cost is also assigned to the deployed VM.
The variables supported in custom cost calculations are context-aware, meaning that you can use them to calculate costs at request time as well as for existing VMs and virtual services. For existing VMs and virtual services, the cost is retrieved from the nightly billing record.
If any variables in the formula are undefined, the custom cost calculation won't be included in the VM cost.
Example: Calculate custom backup costs
In this example, we want to allow users to specify the backup frequency for requested services. We want to include the cost of backups in the total service cost, so that users are aware of the added cost when requesting a service, and so that the cost is included in the VM billing records.
First, we need to edit the cost model to include a custom attribute that will calculate backup cost based on frequency. Next, we need to edit the VM request form to allow users to specify the backup frequency required for the requested service.
Add custom calculations to the cost model
We'll add the custom calculation for each selectable backup frequency to the default private cloud cost model (named Default).
- Go to Configuration > Costs, and click the Cost Models tab.
- Select Default from the listed cost models, and click Edit Cost Model.
- In the Edit Cost Model dialog, go to the Custom page.
- Click the Create a new custom attribute option.
- In the Configure Attribute wizard, type "Backup Frequency" in the Name field.
- From Applies To, choose All Types so that this attribute can be applied to VMs and Virtual Services as well as added to the request form, then click Next.
- On the Configure Attribute page, you can enter a comma-separated list of values that users can select on the form (or that can be applied to an existing VM). Enter the following in the text field:
- Click Add and then click Finish.
- Back on Custom page of the Edit Cost Model wizard, from Select an Attribute to Configure, select Backup Frequency, then click Configure.
- In the Custom Costs dialog, select Custom Calculation.
- Enter a formula for each value.
You can use parentheses as well as the following operators: + - * /
For simplicity, we're assuming that:
- expected incremental backup size is 20% of total backup size
- backup storage costs 5 USD per GB
Add the formulas from the following table:
Backup Frequency
Backups to Keep
Formula
Daily (1 full backup plus 6 incremental backups)
4 weeks
((#{target.storage.gb} * 4) + (#{target.storage.gb} * 0.20 * 24)) * 5
Monthly
6 months
(#{target.storage.gb} * 6) * 5
- Click OK, and then click Finish to exit the cost model wizard.
"None, Daily, Monthly"
Here's what it looks like when we enter the formulas:
Add a control to the request form
Now we'll add the new custom attribute to the request form, so that users can specify the backup frequency when requesting a new service.
- Go to Configuration > Self-Service > Forms.
- In the Form Library, select the Default Service form.
- In the Toolbox on the right, click Header to add a text header component to the form.
- In the new header service form component, enter "Backup Requirements" in the text field, and select Heading 2 for the style.
- Click OK to accept these changes.
- In the Toolbox, click the Custom Attribute element to add it to the form.
- In the new custom attribute service form component, select Backup Frequency from the Custom Attribute list.
- Click OK and Save.
When you add a custom calculation to a Service form, Commander totals all costs for that custom attribute for all components in the service. You can also add a custom calculation to a VM or Virtual Service form.
Test the Calculation
To test the calculation for new requests:
- Click Preview.
- Specify a value for Backup Frequency on the form.
The cost in the pie chart should update accordingly.
To test the calculation on an existing VM:
- Navigate to a VM covered by the cost model you configured.
- Right-click the VM, and select Lifecycle Management > Set Custom Attributes.
- Select a value.
- Click OK.
The cost of the VM should increase accordingly.
To view a VM's cost:
- Click the Details link next to Annual Cost in the Details section of the VM's Summary tab.