Options

Options are user-defined custom inputs that are used throughout Morpheus. Depending on the type of Input being created, users may need to create only an Input, or it might need to be paired with an Option List. Option Lists are static or dynamic lists of selections that would be associated with an Input if the user must make choices from a select list or typeahead field. This section discusses how to create different types of Inputs depending on the situation and powerful tools the user can take advantage of, such as dynamically filtered cascading inputs, logically generated Option Lists called from local or remote sources, and more.

Inputs

Inputs are custom input fields that can be added to Instance Types and Layouts, then presented in Instance, App, and Cloning wizards. The resulting value is available in the Instance config map as <%=customOptions.fieldName%>. The fieldName and value can also be exported as Tags.

../../_images/new_option_type.png

Create Input

Note

All possible fields listed. Displayed fields depend on TYPE selection

NAME

Name of the Input

DESCRIPTION

Description for reference in Input list view

FIELD NAME

This is the input fieldName property that the value gets assigned to

Note

Field names should only contain letters, numbers, and hyphen (-), underscore (_), or dot’.’ for separation.

EXPORT AS TAG

Creates Tags for fieldName/value (key/value) on Instances

DEPENDENT FIELD

The Field Name value for a field that will reload this Option List to present a different set of selections. Take a look at the section below on Cascading Inputs as well as the associated article in our KnowledgeBase for documented examples of this feature

VISIBILITY FIELD

A Field Name and selection value that will trigger this field to become visible. Currently, this only works when the Input is associated with a Service Catalog Item and viewed from the Service Catalog Persona perspective. See the section below on the Visibility Field for instructions on configuring this value

DISPLAY VALUE ON DETAILS

When selected, the Input label and value (label: value) will be visible in a list of custom options on the Instance detail page

TYPE
  • Text: Text Input Field

  • Text Area: A text area input, when selected an additional option appears to allow the user to configure the default number of visible rows in the text area

  • Select List: Populated by Option Lists, presents a manual or REST-populated dropdown list

  • Checkbox: Checkbox for on or off values

  • Number: Input field allowing only numbers

  • Typeahead: Populated by Option Lists: Rather than presenting a potentially-large dropdown menu, the user can begin typing a selection into a text field and choose the desired option. Multiple selections can be allowed with this type by marking the ‘ALLOW MULTIPLE SELECTIONS’ box

  • Hidden: No field will be displayed, but the field name and default value will be added to the Instance config map for reference

  • Password: An input field with suitable encryption for accepting passwords

  • Radio List: Populated by Option Lists, presents a selection of radio buttons for the provisioning user

LABEL

This is the input label that typically shows to the left of a custom option

ROWS

For Textarea type Option Lists, determines how many text rows will be given when the Input is presented

PLACEHOLDER

Background text that populates inside a field for adding example values, does not set a value

DEFAULT VALUE

Pre-populates field with a default value

HELP BLOCK

Helpful text that will appear under your Input field to inform users about their selection

REQUIRED

Prevents User from proceeding without setting value

DEFAULT CHECKED

For Checkbox types, when marked the Checkbox will be checked by default

OPTION LIST

For Select List types, select a pre-existing Option List to set dropdown values

Note

Select List and Typeahead Inputs require creation and association of an Option List

Cascading Inputs

One powerful facet of Morpheus Inputs is the ability to present users with different lists of input options based on their selections in other Inputs within the same wizard or modal. One common example, which is fully illustrated in this section, is to have a user select:

  • The Group they wish to provision into…

  • Then select the target Cloud from a list limited to Clouds which are in the selected Group…

  • Then select the target network from a list limited to networks which are available to the selected Cloud and Group

To set this up, we will first configure our Inputs (custom option fields that can be applied to Instance Types and other Morpheus constructs) and Option Lists (dynamic lists of possible choices which can be associated with Inputs and presented in a dropdown or typeahead format). Once the custom options are configured, we will associate them with a new service catalog item and take a look at how the user would interact with them.

Group Custom Option

To begin, we will create a new Option List. In this case, we will select type of “Morpheus Api” which will populate the list based on a call to the internal Morpheus API. Option Lists can also be populated by calls to external REST APIs or even from static lists that you enter manually. When dynamically populating Option Lists, whether via Morpheus API or an external API, translation and/or request scripts may be needed to prepare the request or translate the results. More on that as we build out the example.

I have called my Option List “Groups” and selected “Groups” from the OPTION LIST menu. This simply indicates that Groups are the construct we want to call into our list from Morpheus API. In this case, we want to present a list of all Groups to the user by their name and pass the Group database ID in the background. Since it is common to create Option Lists from Morpheus API where the construct name is displayed to the user and the ID is passed, we actually do not need to input any translation scripts in this case. However, I will include a translation script here which does the same thing simply to provide more clarity to the example. Morpheus Option List documentation includes additional details on available translation script inputs and which are available without translation as a convenience feature.

for (var x = 0; x < data.length; x++) {
  results.push({name: data[x].name, value:data[x].id});
}

After saving the Option List, create the Input that presents the list we just created. I gave my Input the name of “Selected Group”, field name of “selectedGroup”, and label of “Group”. For type, choose “Select List” and a new field will appear at the bottom of the modal where we can select the Option List we just created. With this configuration, the Input will present as a dropdown list containing the options called from our Option List.

Cloud Custom Option

Adding the Option List and Input for Clouds will be similar to the prior step with the exception that we will be including a request script which effectively filters the list of available Clouds to only those associated with the selected group. Follow the same process to start a new Option List, I have configured mine as follows:

  • NAME: Parsed Clouds

  • TYPE: Morpheus Api

  • OPTION LIST: Clouds

We also need a request script that loads the siteId attribute of the results variable with the Group ID if the user has made a group selection. Essentially it appends this input as a query parameter to the API call, calling (for example) .../api/clouds?siteId=1 rather than .../api/clouds. It should be similar to the script below. Note that we are referencing the selectedGroup field name we created previously and that a “site” is the term for Groups in the Morpheus database.

if (input.selectedGroup) {
  results.siteId = input.selectedGroup
}

We also need a translation script which will be identical to the one used previously with the exception that if there is no input on the selectedGroups field, nothing will be displayed for the Clouds option.

if (input.selectedGroup) {
for (var x = 0; x < data.length; x++) {
    results.push({name:data[x].name, value:data[x].id});
  }
}

We also need to create an Input to house this Option List. This process will be very similar to creating the previous Input except that we need to set selectedGroup as the Dependent Field. Setting a dependent field on an Input will trigger it to reload each time a selection is made in the indicated option. My configuration is as follows:

  • NAME: Parsed Cloud

  • FIELD NAME: parsedCloud

  • DEPENDENT FIELD: selectedGroup

  • TYPE: Select List

  • LABEL: Cloud

  • OPTION LIST: Parsed Clouds

Save your changes once done.

Network Custom Option

Finally, we will create an Option List/Input pair for network selection. In this case, it will be dependent on both the Group and Cloud selection. My Option List configuration is below:

  • NAME: Parsed Networks

  • TYPE: Morpheus Api

  • OPTION LIST: Networks

Request Script:

if (input.parsedCloud && input.selectedGroup) {
  results.cloudId = input.parsedCloud
  results.groupId = input.selectedGroup
}

Translation Script:

if (input.parsedCloud && input.selectedGroup) {
for (var x = 0; x < data.length; x++) {
    results.push({name:data[x].name, value:data[x].id});
  }
}

The Input is configured as follows:

  • NAME: Parsed Networks

  • FIELD NAME: parsedNetwork

  • DEPENDENT FIELD: parsedCloud

  • TYPE: Select List

  • LABEL: Network

  • OPTION LIST: Parsed Networks

Setting Custom Options at Provision Time

At this point, our dependent options are ready to be applied to custom Instance Types, Workflows or Service Catalog items as needed. When creating them, we can select an unlimited number of Inputs from a typeahead field on the create modal and they will be presented when a user goes to provision that element or run that Workflow. As an example, I have created a Service Catalog item that incorporates the three Inputs we have created. You can see how the dependent fields reload and present different options based on my selections.

../../_images/cascadingOptionList.gif

Visibility Field

The Visibility field for Inputs allows users to set conditions under which the Input being created or edited is displayed. A very simple visibility configuration would look like the following: config.customOptions.color:(red) where “color” represents the fieldName for any other Input which will determine the visibility of the current one and “red” represents any JavaScript regular expression that matches to the values that meet your desired conditions.

Expanding on the simplified example above, we could trigger visibility based on any one of multiple selections from the same Input by using a different regular expression, such as config.customOptions.color:(red|blue|yellow). Additionally, we aren not restricted to the conditions of just one Input to determine visibility as the following would also be valid: config.customOptions.color:(red|blue|yellow),config.customOptions.shape:(square). In the previous example, the Input “Color” would have to be set to red, blue, or yellow OR the Input “Shape” would have to be set to square in order to trigger visibility of the Input currently being configured. Prepend the previous example with matchAll:: in order to require both conditions to be met rather than one or the other (ex. matchAll::config.customOptions.color:(red|blue|yellow),config.customOptions.shape:(square)).

Putting it all together, you will first configure visibility for your selected Inputs as described above. You can see in the screenshot below I have set the Input being edited to have a visibility dependent on another Input which you can see in the background.

../../_images/1optionType.png

Next, ensure the relevant Inputs are associated with the Service Catalog Item (Tools > Self Service).

../../_images/2configCatalogItem.png

Finally, when Service Catalog Persona users interact with my Catalog Item, they will be able to toggle additional Inputs to be visible based on their selections.

../../_images/3toggleOption.gif

Option Lists

Option Lists allow you to give the user more choices during provisioning to then be passed to scripts and/or automation. Option Lists, however, are pre-defined insofar as they are not free-form. They can be manually entered CSV or JSON, they can be dynamically compiled from REST calls via GET or POST requests, or populated by LDAP queries.

../../_images/newOptionList.png

Generic Option List Fields

The displayed fields in the create/edit Option List modal depend on the TYPE value selected.

NAME

Name of the Option List

DESCRIPTION

Description of the Option List for reference in Option List list view

TYPE
  • REST: REST API call to populate Option List

  • Manual: Manually entered dataset, CSV or JSON

  • Morpheus API: Call to internal Morpheus API to populate the Option List

  • LDAP: Searches and returns a list of Active Directory objects

VISIBILITY

If the account currently signed in is not in the master tenant, visibility will automatically change to private

Manual Option List Fields

DATASET

Appears only for manual Option Lists. Add your CSV or JSON list to this field

Note

JSON entries must be formatted like the following example: [{"name":"Test","value":1},{"name":"Testing","value":2}]

REST Option List Fields

SOURCE URL

A REST URL used to fetch list data which is cached in the appliance database

REAL TIME

When checked, a REST call will be made to update the Option List at the time its presented to the User

IGNORE SSL ERRORS

Do not fail API query for self-signed or invalid certs on REST call target

SOURCE METHOD

GET or POST

SOURCE HEADERS

Custom HTTP Headers to include in the source request

INITIAL DATASET

Create an initial JSON or CSV dataset to be used as the collection for this option list. It should be a list containing objects with properties ‘name’ and ‘value’

TRANSLATION SCRIPT

Create a JS script to translate the result data object into an array containing objects with properties ‘name’ and ‘value’. The input data is provided as ‘data’ and the result should be put on the global variable ‘results’.

Example:

for(var x=0;x < data.length; x++) {
  results.push({name: data[x].name,value:data[x].id});
}
REQUEST SCRIPT

Create a JS script to prepare the request. Return a data object as the body for a POST request, and return an array containing properties ‘name’ and ‘value’ for a GET request. The input data is provided as ‘data’ and the result should be put on the global variable ‘results’

Example:

results.push({name: 'userId', value : data.users})

Morpheus API Option List Fields

OPTION LIST

A list of available object types to return

TRANSLATION SCRIPT

Create a JS script to translate the result data object into an array containing objects with properties ‘name’ and ‘value’. The input data is provided as ‘data’ and the result should be put on the global variable ‘results’.

Example:

var i=0;
results = [];
for(i; i<data.length; i++) {
  results.push({name: data[i].name, value: data[i].value});
}

Translation script inputs:

Clouds

  • id: <Number>

  • value: <Number> // id, convenience

  • name: <String>

  • displayName: <String>

  • category: <String>

  • description: <String>

  • apiKey: <String>

  • status: <String>

  • hourlyPrice: <Number>

  • hourlyCost: <Number>

  • instanceType: <Object>

    • id: <Number>

    • name: <String>

  • plan:<Object>

    • id: <Number>

    • name: <String>

  • site:<Object>

    • id: <Number>

    • name: <String>

Environments

  • id: <Number>

  • value: <Number> // id, convenience attribute to avoid requiring translation

  • code: <String>

  • name: <String>

Groups

  • id: <Number>

  • value: <Number> // id, convenience attribute to avoid requiring translation

  • name: <String>

  • code: <String>

  • uuid: <String>

  • location: <String>

  • datacenterId: <Number>

Instances

  • id: <Number>

  • value: <Number> // id, convenience

  • name: <String>

  • displayName: <String>

  • category: <String>

  • description: <String>

  • apiKey: <String>

  • status: <String>

  • hourlyPrice: <Number>

  • hourlyCost: <Number>

  • instanceType: <Object>

    • id: <Number>

    • name: <String>

  • plan: <Object>

    • id: <Number>

    • name: <String>

  • site: <Object>

    • id: <Number>

    • name: <String>

Instances Wiki

  • id: <Number>

  • value: <Number> // id, convenience

  • name: <String>

  • urlName: <String>

  • category: <String>

  • instanceId: <String>

  • content: <String>

  • contentFormatted: <String>

  • format: <String>

  • createdByUsername: <String>

  • updatedByUsername: <String>

Networks

  • id: <Number>

  • value: <Number> // id, convenience

  • code: <String>

  • category: <String>

  • name: <String>

  • status: <String>

  • cloudId: <Number>

  • groupId: <Number>

  • networkType:<Object>

    • id: <Number>

    • code: <String>

    • name: <String>

  • externalId: <String>

  • externalNetworkType: <String>

  • networkDomain: <Object>

    • id: <Number>

    • name: <String>

  • networkPool: <Object>

    • id: <Number>

    • name: <String>

  • createdBy: <String>

Plans

  • id: <Number>

  • value: <Number> // id, convenience

  • code: <String>

  • name: <String>

  • storage: <Integer, bytes>

  • memory: <Integer, bytes>

  • cores: <Number>

Resource Pools

  • id: <Number>

  • value: <Number> // id, convenience

  • code: <String>

  • externalId: <String>

  • name: <String>

  • serverGroupId: <Number>

  • status: <String>

  • regionCode: <String>

  • parentPoolId: <Number>

  • type: <String>

Security Groups

  • id: <Number>

  • value: <Number> // id, convenience

  • code: <String>

  • name: <String>

  • externalType: <String>

  • externalId: <String>

  • cloudId: <Number>

  • scopeMode: <String>

  • scopeId: <Number>

Servers

  • id: <Number>

  • value: <Number> // id, convenience

  • name: <String>

  • displayName: <String>

  • description: <String>

  • category: <String>

  • osType: <String>

  • powerState: <String>

  • lastStats: <String>

  • zone: <Object>

    • id: <Number>

    • name: <String>

  • capacityInfo: <Object>

    • maxStorage: <Integer, bytes>

    • maxMemory: <Integer, bytes>

    • maxCores: <Number>

    • usedMemory: <Integer, bytes>

    • usedStorage: <Integer, bytes>

  • computeServerType: <Object>

    • id: <Number>

    • name: <String>

    • nodeType: <String>

    • vmHypervisor: <String>

    • containerHypervisor: <String>

Servers Wiki

  • id: <Number>

  • value: <Number> // id, convenience

  • name: <String>

  • urlName: <String>

  • category: <String>

  • serverId: <String>

  • content: <String>

  • contentFormatted: <String>

  • format: <String>

  • createdByUsername: <String>

  • updatedByUsername: <String>

REQUEST SCRIPT

The request script is used differently for Morpheus API Option List types. A Morpheus API option list type will use an internal API to return a list of objects instead of performing HTTP(S) requests to the Morpheus API. Due to this approach, the results object will not be used to generate query parameters or a JSON body. The results object will instead be used to contain a map of accepted key:value pairs that can be used to filter, sort and order the list of objects that get returned.

Below is a list of accepted key:value pairs for each object type:

Generic options available for all object types

  • max: <integer> // Maximum number of results to return. Default: 25

  • offset: <integer> // Offset for returned results. Default: 0

  • sort: <string> // Field to sort on. Default: ‘name’

  • order: <string> // Order of returned values. Accepted values: ‘asc’, ‘desc’. Default: ‘asc’

    Example: results = {max: 5, order : 'desc'}

Networks

  • zoneId

  • siteId

  • planId

  • provisionTypeId: <Number> // Id of the provision type (technology), filters to only networks associated with this provision type

  • layoutId: <Number> // Id of an Instance Layout, ignored if provisionTypeId is supplied, otherwise used to look up the provision type

  • poolId: <Number> // Id of a network pool, filters to only networks within the specified network pool

Plans

  • zoneId

  • siteId

  • layoutId

  • provisionTypeId: <Number> // Id of the provision type (technology), filters to only plans associated with this provision type

Resource Pools

  • zoneId

  • siteId

  • planId

  • layoutId: <Number> // Id of an Instance Layout, used to get the associated provision type and filter to that provision type

Security Groups

  • zoneId // required

  • poolId

Clouds

  • zoneId : <integer>  // Database ID of cloud to return

  • tenantId : <integer> // Database ID of tenant where clouds are added. Filters to only clouds added within the specified tenant. Only available in Master Tenant

  • zoneTypeId : <integer> // Database ID of cloud type. Filters to only clouds with the specified cloud type

  • siteId : <integer> // Database ID of group. Filters to only clouds within the specified group

  • tagName : <string> // Filters to clouds with servers with tags containing the tagName

  • tagValue : <mixed> // Requires tagName. Filters to clouds with servers that have tags containing the tagName and specified tagValue

  • phrase : <string> // Fuzzy matches phrase on cloud name and description

    Example: results = {tenantId: 1, siteId: 1, tagName: "morpheus"}

Instances

  • appsId : <integer> // Database ID of app to filter by. Returns instances linked to the app

  • tenantId : <integer> // Database ID of tenant where instances are located. Filters to only instances within the specified tenant. Only available in Master Tenant

  • serverId : <integer> // Database ID of server. Filters to the instance that contains the specified server

  • tagName : <string> // Filters to instances with tags containing the tagName

  • tagValue : <mixed> // Requires tagName. Filters to instances with tags containing the tagName and specified tagValue

  • phrase : <string> // Fuzzy matches phrase on instance name and description

    Example: results = {tenantId:1, phrase: "ha"}

Groups

  • tenantId : <integer> // Database ID of tenant where groups are located. Filters to only groups added within the specified tenant. Only available in Master Tenant

  • zoneTypeId : <integer> Database ID of cloud type. Filters to only groups that contain clouds with the specified cloud type

  • zoneId : <integer>  // Database ID of cloud. Filters to only groups that contain the cloud with the specified ID

  • siteId : <integer> // Database ID of group to return

  • phrase : <string> // Fuzzy matches phrase on group name and location.

Servers

  • tenantId : <integer> // Database ID of tenant where servers are located. Filters to only servers within the specified tenant. Only available in Master Tenant

  • serverId : <integer> // Database ID of server. Filters to the server specified by the ID

  • siteZoneId : <integer> // Database ID of cloud. Filters to servers contained within the specified cloud

  • serverType : <string> // Type of server. Accepted values: ‘host’, ‘baremetal’, ‘vm’

  • siteId : <integer> // Database ID of group. Filters to only servers contained within clouds that are added in the specified group

  • tagName : <string> // Filters to servers with tags containing the tagName

  • tagValue : <mixed> // Requires tagName. Filters to servers with tags containing the tagName and specified tagValue

  • phrase : <string> // Fuzzy matches phrase on server name and description.

    Example: results = {max: 50, siteZoneId : 3}

instance-wiki

Contains same options for Instances Morpheus API type.
  • phrase : <string> // Fuzzy matches phrase on wiki name, urlName and content

server-wiki

Contains same options for Servers Morpheus API type.
  • phrase : <string> // Fuzzy matches phrase on wiki name, urlName and content

LDAP Option List Fields

LDAP URL

The URL pointing to the LDAP server

USERNAME

The fully qualified username (with @ suffix syntax) for the binding account

PASSWORD

The password for the above account

LDAP Query

The LDAP query to pull the appropriate objects. See the next section for an example use case

TRANSLATION SCRIPT

Create a JS script to translate the result data object into an array containing objects with properties ‘name’ and ‘value’. The input data is provided as ‘data’ and the result should be put on the global variable ‘results’.

Note

Option Lists are set on one or multiple Select List or Typeahead Inputs. The Input is then set on an Instance Type, Layout, Cluster Layout, and/or Operational Workflow for input during provisioning or execution.

Creating an Option List Based on an LDAP Query

In Morpheus version 4.2.1 and higher, Option Lists can be populated from LDAP queries. This gives users the ability to search Active Directory, capture objects, and present them as custom options where needed.

It’s recommended that you connect LDAP-type Option Lists to Typeahead-type Inputs as the list of returned selections can be very large. This also allows you to select multiple options from the list, presuming you’ve allowed for that when creating the Input.

Populating LDAP-type Option Lists requires knowledge of LDAP query syntax. This guide provides one example and there are many publicly-available resources for help writing additional queries.

  1. Create a new Option List (Library > Options > Option Lists > ADD)

  2. Enter a name for the new LDAP Option List

  3. Change the Type value to LDAP and the relevant fields will appear as shown in the screenshot:

  4. Enter the LDAP URL in the following format (an example is also shown as a placeholder in the UI form field):

    ldap[s]://<hostname>:<port>/<base_dn>
    
  5. Enter the fully qualified username with @ suffix syntax, such as: user@ad.mycompany.com

  6. Enter the account password

  7. Enter your LDAP query. You can even inject variables into your query structure to query based on the value the user has entered into the typeahead field as shown in the example below:

    (&(objectClass=user)(cn=<%=phrase%>*))
    
  8. Finally, enter a translation script which will convert the returned LDAP object into a list of name:value pairs you can work with in Morpheus. The example script below shows the user DisplayName and sets the value to the SAMAccountName:

    for(var x=0;x < data.length ; x++) {
    
      var row = data[x];
      var a = {};
    
      if(row.displayName != null) {
        a['name'] = row.displayName;
    
      } else {
    
        a['name'] = row.sAMAccountName;
    
      }
    
      a['value'] = row.sAMAccountName;
      results.push(a);
    
    }
    
  9. Click SAVE CHANGES

    ../../_images/ldap_option_list.png