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.
Requirements
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.
- Download the Share Name script package to the vCommander application server.
- Extract the script to C:\scripts\sharename\.
@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.
- Browse to Configuration > Service Request Configuration and switch to the Approval Workflow tab.
- Click Add.
- Provide a Name and choose to Apply this workflow: when a new request is created. Click Next.
- On the Assignment page, choose to either make the workflow apply globally, or assign to specific Organizations, Users and Groups. Click Next.
- 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 #{request.services[1].publishedName} - Click Edit and enter the condition #{request.services[1].type} -eq SHARED_IMAGE, then click OK. Click Next.
- Choose whether or not to deploy the requests manually or automatically. Check Set primary owner as administrator if suitable. Click Next.
- 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-001, dev-build875-002, dev-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.