Auto-Naming

@Since Payara Server 5.193

The auto-naming feature is an asadmin feature added to help with the naming of instances, deployment groups, and other resources by resolving name conflicts and auto-generating names.

Usage

The autoname option is enabled either by specifying --autoname or -a on the command line before or after the command name. This is technically an asadmin option rather than a command parameter so should be specified before the command name - it will however still accept being specified after the command name (see examples).

Although it should work in most cases, there are some circumstances in which specifying the --autoname or -a option after the command name will result in the option not taking effect, which is why we recommend that you place it before the command name.

When enabled, this feature allows commands that accept String names as their primary parameter (the parameter that you don’t have to specify, e.g. the instancename parameter for the create-instance command) to generate a name. To automatically generate a name for your instances or resources, simply enable the autoname option and omit providing a name (example below).

Specifically for the create-instance and create-local-instance commands, the autoname option can also be used to automatically resolve any name conflicts. When resolving a name conflict, Payara Server Enterprise will simply append a new name to the existing name, like so: instance1-BamboozledBarracuda.

When creating an instance from the admin console, there is a new Auto Name checkbox present, which performs the same conflict resolution function as the autoname CLI option.

This checkbox does not currently allow you to generate an instance name from scratch - it simply resolves any name conflicts.

It should be stressed that these options are optional and disabled by default - if you wish to retain the original behaviour of prompting for a name or refusing to create an instance due to a name conflict, no action is necessary.

Examples

Name generation:

asadmin -a create-instance --node localhost-domain1    -> BemusedCatfish created
asadmin create-local-instance --node localhost-domain1 --autoname    -> ConfusedCarp created
asadmin create-instance --node localhost-domain1    -> Please enter an instance name: instance1    -> instance1 created
asadmin create-instance --node localhost-domain1    -> Please enter an instance name: instance1  -> command failed: instance name already in use

Name conflict resolution:

asadmin --autoname create-instance --node localhost-domain1 instance1    -> instance1 created
asadmin create-instance --node localhost-domain1 --autoname instance1    -> instance1-BemusedCatfish created
asadmin create-instance --node localhost-domain1 instance1    -> command failed: instance name already in use

The Extra Terse Option

The extraterse option is intended for use with scripts, adding an extra level of terseness to the command output to the CLI. Currently this feature only works with the create-instance and create-local-instance commands.

When enabled, the create-instance and create-local-instance commands should only return the name of the instance created. The intention behind this feature being that you should be able to set variables from this output for use with scripts, since you can’t know beforehand what the name of an instance is if a name conflict is resolved or a name is generated from scratch.

This option can be enabled either by specifying --extraterse or simply -T on the command line (in comparison, the normal terse option is enabled with --terse or -t) before or after the command name. Being a CLI option rather than a command parameter, it is recommended that you specify it before the command name, as the ability to specify asadmin options (like --host) after the command name is technically deprecated syntax and will be ignored in certain circumstances.

The extraterse option implicitly enables the terse option - this is true for all commands (not just create-instance and create-local-instance).

ExtraTerse Examples

$INSTANCE_NAME = asadmin create-local-instance --node localhost-domain1 --autoname --extraterse
asadmin start-instance $INSTANCE_NAME

$SECOND_INSTANCE_NAME = asadmin -a -T create-local-instance --node localhost-domain1