Feature #1726: Minor modifications to the driver

This commit is contained in:
Ruben S. Montero committed 2013-01-18 02:20:06 +01:00
1 parent af47048709
commit 8ab717132d
2 files changed
+9 -16

No files matched your search

+4 -1
View File
@@ -434,7 +434,10 @@ int LibVirtDriver::deployment_description_vmware(
file << "\t" << data << endl;
data_vmx = raw->vector_value("DATA_VMX");
file << "\t<metadata>" << data_vmx << "</metadata>" << endl;
if ( !data_vmx.empty() )
{
file << "\t<metadata>" << data_vmx << "</metadata>" << endl;
}
}
}
+5 -15
View File
@@ -287,15 +287,15 @@ class VMwareDriver
end
#Performs a remote action using ssh
def do_ssh_action(cmd, log=true)
rc = SSHCommand.run("'#{cmd}'", @host)
def do_ssh_action(cmd, stdin=nil)
rc = SSHCommand.run("'#{cmd}'", @host, nil, stdin)
if rc.code == 0
return [true, rc.stdout]
else
err = "Error executing: #{cmd} on host: #{@host} " <<
"err: #{rc.stderr} out: #{rc.stdout}"
OpenNebula.log_error(err) if log
OpenNebula.log_error(err)
return [false, rc.code]
end
end
@@ -337,26 +337,16 @@ class VMwareDriver
if metadata
# Get the ds_id for system_ds from the first disk
metadata = metadata.text
disk = XPath.first(dfile_hash, "//disk").text
source = XPath.first(dfile_hash, "//disk/source").attributes['file']
ds_id = source.match(/^\[(.*)\](.*)/)[1]
name = XPath.first(dfile_hash, "//name").text
vm_id = name.match(/^one-(.*)/)[1]
# Reconstruct path to vmx
# Reconstruct path to vmx & add metadata
path_to_vmx = "/vmfs/volumes/#{ds_id}/#{vm_id}/disk.0/#{name}.vmx"
# Create temp file with metadata
File.open("/tmp/one-tmp-file", 'w') {|f|
f.write(metadata.gsub("\\n","\n"))
}
`scp /tmp/one-tmp-file #{@host}:/tmp`
# Add metadata to .vmx file
cmd = "cat /tmp/one-tmp-file >> #{path_to_vmx}"
do_ssh_action(cmd)
do_ssh_action("cat >> #{path_to_vmx}", metadata.gsub("\\n","\n"))
end