--- OCCIServer.rb.orig	2013-02-04 14:53:40.469119840 +0100
+++ OCCIServer.rb	2013-02-04 15:01:13.483028529 +0100
@@ -48,6 +48,11 @@
 # Secs to sleep between checks to see if image upload&copy to repo is finished
 IMAGE_POLL_SLEEP_TIME = 5
 
+#  Allow read access to @vm_info
+class VirtualMachineOCCI
+    attr_reader :vm_info
+end
+
 class OCCIServer < CloudServer
     # Server initializer
     # config_file:: _String_ path of the config file
@@ -246,6 +251,22 @@
                     @config[:instance_types],
                     @config[:template_location])
 
+        # --- Get User's VMs ---
+        vmpool = VirtualMachinePoolOCCI.new(
+                        @client,
+                        POOL_FILTER)
+        
+        rc = vmpool.info
+        if OpenNebula.is_error?(rc)
+            return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
+        end
+
+        # --- Check for duplicate names ---
+        if vmpool.map{|user_vm| user_vm.name }.include?(vm.vm_info['/COMPUTE/NAME'])
+            rc=OpenNebula::Error.new("[VirtualMachineAllocate] A VM with the same name already exist")
+            return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]
+        end
+
         # --- Generate the template and Allocate the new Instance ---
         template = vm.to_one_template
         return template, 500 if OpenNebula.is_error?(template)
