# VM\_PREFIX Implementation

**URL:** <https://forum.opennebula.io/t/vm-prefix-implementation/6306>\
**Category:** Product Support\
**Created:** [August 27, 2018, 4:59pm UTC](https://forum.opennebula.io/t/vm-prefix-implementation/6306 "2018-08-27T16:59:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![beaz2890](https://avatars.discourse-cdn.com/v4/letter/b/f4b2a3/32.png) [@beaz2890](https://forum.opennebula.io/u/beaz2890)\
**Post date:** [August 27, 2018, 4:59pm UTC](https://forum.opennebula.io/t/vm-prefix-implementation/6306/1 "2018-08-27T16:59:12Z")

</div>

Please, describe the problem here and provide additional information below (if applicable) …

Hello,  
I am attempting to change the VM naming convention from the default one-- structure to a custom prefix using the VM\_PREFIX as denoted in the user guide (see quote below) but have been unsuccessful getting it to work.

> [@One-$ prefix when deploying new vm from vCenter templete](https://forum.opennebula.io/t/one-prefix-when-deploying-new-vm-from-vcenter-templete/2843/2):
>
> OpenNebula will add by default a one-- prefix to the name of the vCenter VMs it spawns, where is the id of the VM in OpenNebula. This value can be changed using a special attribute set in the vCenter cluster representation in OpenNebula, ie, the OpenNebula host. This attribute is called VM\_PREFIX (which can be set in the OpenNebula host template), and will evaluate one variable, $i, to the id of the VM. A value of one-$i- in that parameter would have the same behavior as the default.

Within the VM template, I have added it manually at the bottom of the template file using the advanced editor in the following ways (each without success):  
VM\_PREFIX = $i  
VM\_PREFIX = ‘$i’  
VM\_PREFIX = ($i)

I have also attempted to change the setting using the key-value tags method, but the resulting template file (and results) appear to be identical.

I have noticed that after making each of the changes, it appears that the system automatically adds a set of double-quotes (“”) around the string, and I am wondering if this is what is causing the system to not recognize the variable. However, I have been unable to escape the quotes so far.

Please let me know if you need any additional information.

* * *

**Versions of the related components and OS (frontend, hypervisors, VMs):**  
vOneCloud 3.2.0, OpenNebula 5.6.0  
**Steps to reproduce:**  
See description above  
**Current results:**  
VM naming would match the name description (passed through to VM\_Prefix)  
**Expected results:** ’  
VM naming retains “One-” syntax

---

<div class="post-metadata">

**Author:** ![Semedi](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/semedi/32/5365_2.png) [@Semedi](https://forum.opennebula.io/u/Semedi)\
**Post date:** [September 6, 2018, 8:23am UTC](https://forum.opennebula.io/t/vm-prefix-implementation/6306/2 "2018-09-06T08:23:16Z")

</div>

> [@beaz2890](#):
>
> Within the VM template, I have added it manually at the bottom of the template

Im trying it right now and its working as expected.

i can see two problems:

- you need to update the OpenNebula host (pointing to one vCenter cluster), **not the template**. that means that if you have for example:

(updating host templates)  
vCenter “Cluster a” -\>OpenNebula host\_id 0: VM\_PREFIX = “a-$i-”  
vCenter “Cluster b” -\>OpenNebula host\_id 1: VM\_PREFIX = “b-$i-”

when you deploy a machine from a OpenNebula template if the new vm go to cluster a it will have the name a-0-templatename.

- use double quotes when using your editor with onehost update:  
VM\_PREFIX=“custom\_name-$i”

Regards
