By default, shared services will use the global naming convention defined on the provisioning configuration page, but you can follow the procedure outlined in this article to bypass this in favor of another naming pattern you want to follow. This is accomplished by checking whether or not the service was added to the catalog by a user sharing a VM, and then running a script to set the name only if it was shared.


Creating the Approval Workflow

This solution requires that the script to set the shared VM name be available on the vCommander server, where it will be called by the workflow.

  1. Download the Share Name script package to the vCommander application server.
  2. Extract the script to C:\scripts\sharename\.

The script is a simple batch file that echoes back the desired name as a deployment parameter:


@echo $VMNAME=%1-#{uniqueNumber[3]}$


Next, create an Approval workflow which uses this file in a script step. You can also use the same basic instructions to add the step to your existing workflows.

  1. Browse to Configuration > Service Request Configuration and switch to the Approval Workflow tab.
  2. Click Add.
  3. Provide a Name and choose to Apply this workflow: when a new request is created. Click Next.

  4.  On the Assignment page, choose to either make the workflow apply globally, or assign to specific Organizations, Users and Groups. Click Next.
  5. On the Steps page, click Add > Execute Script. Configure as follows:

    Step Name:  Add a suitable name.
    Step Execution: Execute when conditions are met
    Timeout: 300
    Script Output: Capture script output as comment
    When Step Fails: Mark workflow step as failed: do not proceed
    Command Line: c:\scripts\sharename\sharename.bat #{[1].publishedName}

  6. Click Edit and enter the condition #{[1].type} -eq SHARED_IMAGE, then click OK. Click Next.

  7. Choose whether or not to deploy the requests manually or automatically. Check Set primary owner as administrator if suitable. Click Next.

  8. Review your choices and click Finish.

Expanding this Solution

In the example provided here, the variables used will cause all VMs deployed from shared services to use the shared service name with three unique digits as the name. For example, in the image below, the shared service name is dev-build875. So, VMs deployed dev-build875-001dev-build875-002dev-build875-003, and so on.

You can update this naming with any number of variables. For each variable you pass in, simply add the variable to the command line, and update the batch file to accept these as inputs. The first variable's value will be substituted for %1, the second variable %2, and so on. Just make sure you are always enclosing the information in the deployment parameter format.