Custom Options for Service plans

I am trying to create a catalog to provision the VM. I have created a service plan with customisation enabled for memory and CPU and added that to inputs. The generated configuration in the catalog expects the plan as follows

“id”: 1326
“Code”: “vm-1234”
“ServicePlanOptions”: {
“maxCores” : 4
“CoresPerSocket” : 1
“maxMemory” : 8589934592

I am inserting my customOptions here to replace the maxcores and maxMemory.
Here The value for memory is expected to be provided in bytes whereas I want the user to enter in GB
Is there any way to insert arithmetic operations in order to convert GB to bytes.


you can try this <%=customOptions.memGb* 1024 * 1024 * 1024%>


1 Like

Also, life get’s easier if you update to the 6.1.X branch where we introduced form builder. There is a native disk and plan form field. Additionally, we have a Byte Size field that will do the arithmetic for you.

It’s important to note, if you need a value to be passed as an integer like the above example of @vsenthilkarasu you should add a toLong() on it so it’s evaluated properly like:

<%=customOptions.memGb.toLong() * 1024 * 1024 * 1024%>


Thanks Senthilkarasu and cbunge for your inputs

The solution from cbunge worked.

Hi @cbunge , I created a catalog input option for Memory using as you said:

<%=customOptions.memGB.toLong() * 1024 * 1024 * 1024%>

but when I click on the catalog after editing, it returns an error, How can I fix it? Thank you!

You must wrap that entire string in quotes. The toLong() is going to convert the string to an integer on submission.

The JSON validation errors on non-string Morpheus variables until at least 6.2.1, where we removed the validation of JSON to allow more free form entry and creative ideas.

Hi @cbunge , I put it in both single and double quotes but it still gets the same result. My version is 6.1.2 Did I do it correctly, didn’t? Sorry if I don’t understand what you mentioned

It appears you now have a % in your variable:

1 Like

Thanks for your help
I edited it again and tried both but it returns the same :roll_eyes: Maybe I need to upgrade to 6.2.1 version.

‘<%=customOptions.memGB.toLong() * 1024 * 1024 * 1024%>’

and "<%=customOptions.memGB.toLong() * 1024 * 1024 * 1024%>"

Are you still getting a 500? That should be putting something in your logs. Though I just noticed you are doing an app so it’s yaml

Yes I’m still getting the 500 error. I’m creating a catalog to create 2 VMs that refer to an existing blueprint, and the only input field I want to change is ‘maxMemory’ inside ‘ServicePlanOptions’. I try some of the formats but it’s returned 500. The only format that can be done is <%=customOptions.memGB%> without quotes or toLong().*1024*1024*1024 like this:

'maxMemory': <%=customOptions.memGB * 1024 * 1024 * 1024%>
'maxMemory': <%=customOptions.memGB.toLong() * 1024 * 1024 * 1024%>