From d9aab984142ff714c2b1d5369f9cd1e4611c1e7b Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Sat, 24 Dec 2011 00:32:15 +0100 Subject: [PATCH] feature #1020: Do not fail deployments if the domain is already defined. IDs are unique. --- src/mad/ruby/vmwarelib.rb | 21 ++++++++++++++++----- src/vmm_mad/remotes/vmware/deploy | 3 ++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/mad/ruby/vmwarelib.rb b/src/mad/ruby/vmwarelib.rb index 6de5172548..217fa784c1 100644 --- a/src/mad/ruby/vmwarelib.rb +++ b/src/mad/ruby/vmwarelib.rb @@ -60,11 +60,16 @@ class VMwareDriver # ------------------------------------------------------------------------ # # Deploy & define a VM based on its description file # # ------------------------------------------------------------------------ # - def deploy(dfile) - # Define the VM - deploy_id = define_domain(dfile) + def deploy(dfile, id) + # Define the domain if it is not already defined (e.g. from UNKNOWN) - exit -1 if deploy_id.nil? + if not domain_defined?(id) + deploy_id = define_domain(dfile) + + exit -1 if deploy_id.nil? + else + deploy_id = "one-#{id}" + end OpenNebula.log_debug("Successfully defined domain #{deploy_id}.") @@ -273,8 +278,14 @@ class VMwareDriver end } - deploy_id.strip! + deploy_id.strip! return deploy_id end + + def domain_defined?(one_id) + rc, info = do_action("virsh -c #{@uri} dominfo one-#{one_id}") + + return rc + end end diff --git a/src/vmm_mad/remotes/vmware/deploy b/src/vmm_mad/remotes/vmware/deploy index fe0e4106dd..290bd60a74 100755 --- a/src/vmm_mad/remotes/vmware/deploy +++ b/src/vmm_mad/remotes/vmware/deploy @@ -31,8 +31,9 @@ require 'vmwarelib' dfile = ARGV[0] host = ARGV[1] +id = ARGV[3] -vmware_drv = VMwareDriver.new(host) +vmware_drv = VMwareDriver.new(host, id) puts vmware_drv.deploy(dfile)