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.

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).

  1. Go to Configuration > Costs, and click the Cost Models tab.
  2. Select Default from the listed cost models, and click Edit Cost Model.
  3. In the Edit Cost Model dialog, go to the Custom page.
  4. Edit Cost Model

  5. Click the Create a new custom attribute option.
  6. In the Configure Attribute wizard, type "Backup Frequency" in the Name field.
  7. Define Attribute dialog

  8. 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.
  9. 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:
  10. "None, Daily, Monthly"

    Configure Attribute page

  11. Click Add and then click Finish.
  12. Back on Custom page of the Edit Cost Model wizard, from Select an Attribute to Configure, select Backup Frequency, then click Configure.
  13. In the Custom Costs dialog, select Custom Calculation.
  14. 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

  15. Here's what it looks like when we enter the formulas:

    Custom Costs

  16. Click OK, and then click Finish to exit the cost model wizard.

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.

  1. Go to Configuration > Self-Service > Forms.
  2. In the Form Library, select the Default Service form.
  3. 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.

  4. In the Toolbox on the right, click Header to add a text header component to the form.
  5. In the new header service form component, enter "Backup Requirements" in the text field, and select Heading 2 for the style.
  6. Backup Requirements component

  7. Click OK to accept these changes.
  8. In the Toolbox, click the Custom Attribute element to add it to the form.
  9. In the new custom attribute service form component, select Backup Frequency from the Custom Attribute list.
  10. Backup Requirements service

  11. Click OK and Save.

Test the Calculation

To test the calculation for new requests:

  1. Click Preview.
  2. Specify a value for Backup Frequency on the form.
  3. The cost in the pie chart should update accordingly.

To test the calculation on an existing VM:

  1. Navigate to a VM covered by the cost model you configured.
  2. Right-click the VM, and select Lifecycle Management > Set Custom Attributes.
  3. Select a value.
  4. Click OK.
  5. 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.