- Community Home
- >
- Software
- >
- HPE Morpheus Software
- >
- HPE Morpheus Enterprise Software
- >
- Option List conditional statement
Categories
Company
Local Language
Forums
Discussions
- Integrity Servers
- Server Clustering
- HPE NonStop Compute
- HPE Apollo Systems
- High Performance Computing
Knowledge Base
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Knowledge Base
Forums
Discussions
- Cloud Mentoring and Education
- Software - General
- HPE OneView
- HPE Ezmeral Software platform
- HPE OpsRamp Software
Knowledge Base
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2023 08:48 AM
03-29-2023 08:48 AM
Option List conditional statement
Hi Team,
We created the catalog and added the option list like below:
1.Web 2.app 3.DB based on this selection we are planning to add relative network configuration.
As I tried with this condition I am getting the expected result
“${customOptions.ocategory == 'Web ’ ? ‘web’: ‘app’}”
If I tried with below condition because we required 3 conditions in place but tis not woking.
“${customOptions.ocategory == ‘web’ ? ‘web’: ${customOptions. == ‘app’ ? ‘app’:‘db’}}”
- Tags:
- catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2023 08:49 PM
03-29-2023 08:49 PM
Re: Option List conditional statement
Thanks a lot for the detailed information its working as expected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2023 10:55 PM
03-29-2023 10:55 PM
Re: Option List conditional statement
Hi @kgawronski ,
Currently I have created one catalog and based the above options selections network configuration needs to change. So I have modified the network configurations as below:
Default:
“network”: {
“id”: “network-5”,
“hasPool”: true,
“idName”: “vxw-dvs-41-virtualwire-96-sid-6087-DEV MORPHEUS DB01”,
“pool”: {
“id”: 8,
“name”: “DEV MORPHEUS DB01”
}
}
Updated:
“network”: {
“id”: “${customOptions.platform == ‘W’ ? ‘network-341’: customOptions.platform == ‘A’ ? ‘network-8’ : ‘network-5’}”,
“hasPool”: true,
“idName”: “${customOptions.platform == ‘W’ ? ‘vxw-dvs-41-virtualwire-97-sid-6088-DEV MORPHEUS WEB01’: customOptions.platform == ‘A’ ? ‘vxw-dvs-41-virtualwire-95-sid-6086-DEV MORPHEUS APP01’ : ‘vxw-dvs-41-virtualwire-96-sid-6087-DEV MORPHEUS DB01’}”,
"pool": {
"id": "${customOptions.platform == 'W' ? '6': customOptions.platform == 'A' ? '5' : '8'}",
"name": "${customOptions.platform == 'W' ? 'DEV MORPHEUS WEB01': customOptions.platform == 'A' ? 'DEV MORPHEUS APP01' : 'DEV MORPHEUS DB01'}"
}
Post this configuration as I tried to provision it always pick the 1 condition value.For validating this thing I put this value into name I am getting the expected output as name but not sure why its not working on the network side.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2023 11:13 AM
03-29-2023 11:13 AM
Re: Option List conditional statement
Hello @ibrahim,
There are a few items that I can see that might be affecting your results. There are different ways to perform this. Also, check your caps if they are needed or not.
Using your current example:
"${customOptions.ocategory == 'web' ? 'web': ${customOptions. == 'app' ? 'app':'db'}}"
In the above, you only need one set of ${ }, which everything inside of it will be evaluated as code. Alternatively, you can also use <%= %> instead of ${ }.
Also, It looks like you might be missing the ocategory after customOptions. This is what I would expect a finished item to look like:
"${customOptions.ocategory == 'web' ? 'web' : customOptions.ocategory == 'app' ? 'app':'db'}"
Another way to write this in a more expanded way:
"${if(customOptions.ocategory == 'web'){'web'}else if(customOptions.ocategory == 'app'){'app'}else{'db'}}"
Shorter ways possibly:
"${if(customOptions.ocategory != 'db'){customOptions.ocategory}else{'db'}}"
or
"${customOptions.ocategory != 'db' ? customOptions.ocategory : 'db'}"
That said, there is another alternative than building in logic, if it is as simple as the above. You can do the following using an Option List:
In the above Manual Option List, it is in CSV format (JSON and others work as well). The first item (before the comma) is what shows in the Input in the UI and the second item (after the comma) is the value that is passed into the variables.
In this case, you would just need to use:
"${customOptions.ocategory}"
Depending on the choice the user made, it will just fill in the correct value.
Hope that helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2023 09:01 AM
03-30-2023 09:01 AM
Re: Option List conditional statement
Hi @ibrahim,
I did a test here to validate, and I was able to have the network change based on my choice on the input. I’m doing the process slightly differently but this is what I have currently.
Option List:
Catalog Deployment:
Snippet from my Catalog Item:
"networkInterfaces": [
{
"primaryInterface": true,
"network": {
"id": "<%= customOptions.testnetwork %>"
},
"networkInterfaceTypeId": 4,
"networkInterfaceTypeIdName": "VMXNET 3",
"showNetworkPoolLabel": true,
"showNetworkDhcpLabel": false
}
],
Note that this is VMware I am deploying in, so it may be slightly different for other clouds. I’ve removed portions of the JSON, as some are not needed. For example, the second option I have is IP Pools, which is a network I have that has an IP Pool attached. I don’t need to include or change these items, because the network has it attached, it will be assigned automatically. I could have left it too, it would not have hurt it.
When deploying, depending on the network I chose, it would deploy to the correct network in my environment.
I’d recommend looking over your Option List and make sure the correct items are being passed. You can try removing the additional items as well, just specifying the id to make it cleaner. Verify the items coming from the Option List matches up to the data in the conditional code.
If you continue to have issues, you may want to use tokens to have us assist directly. Please reach out to your account manager for any questions on tokens usage.
Hope that helps!