diff --git a/opennebula_api/models.py b/opennebula_api/models.py
index eb6d64a2..e225ce0f 100644
--- a/opennebula_api/models.py
+++ b/opennebula_api/models.py
@@ -146,26 +146,56 @@ class OpenNebulaManager():
{memory}
{vcpu}
{cpu}
-
+
+ {ssh}
+
+ """
+ try:
+ disk = template.template.disks[0]
+ image_id = disk.image_id
+ vm_specs = vm_specs_formatter.format(
+ vcpu=int(specs['cpu']),
+ cpu=0.1* int(specs['cpu']),
+ memory=1024 * int(specs['memory']),
+ ssh=ssh_key
+
+ )
+ vm_specs += """
fs
{size}
vd
-
-
- {ssh}
-
-
- """
- vm_id = template.instantiate(name ='',
- pending=False,
- extra_template=vm_specs_formatter.format(
+ {image_id}
+
+
+ """.format(size=1024 * int(specs['disk_size']),
+ image_id=image_id)
+
+ except:
+ disk = template.template.disks[0]
+ image = disk.image
+ image_uname = disk.image_uname
+
+ vm_specs = vm_specs_formatter.format(
vcpu=int(specs['cpu']),
cpu=0.1* int(specs['cpu']),
- size=1024 * int(specs['disk_size']),
memory=1024 * int(specs['memory']),
ssh=ssh_key
- )
- )
+
+ )
+ vm_specs += """
+ fs
+ {size}
+ vd
+ {image}
+ {image_uname}
+
+
+ """.format(size=1024 * int(specs['disk_size']),
+ image=image,
+ image_uname=image_uname)
+ vm_id = template.instantiate(name ='',
+ pending=False,
+ extra_template=vm_specs, )
try:
self.oneadmin_client.call(