mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-24 21:34:01 +03:00
Bug #285 filetutils instead of ftools
This commit is contained in:
parent
f81e546629
commit
c20cef8287
@ -30,7 +30,7 @@ $: << RUBY_LIB_LOCATION
|
||||
|
||||
require 'OpenNebula'
|
||||
require 'client_utilities'
|
||||
require 'ftools'
|
||||
require 'fileutils'
|
||||
|
||||
TYPES=%w{OS CDROM DATABLOCK}
|
||||
|
||||
@ -40,15 +40,15 @@ end
|
||||
|
||||
vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
|
||||
vm.info
|
||||
template=vm.to_hash
|
||||
template=template['VM']['TEMPLATE']
|
||||
disks=[template['DISK']].flatten if template['DISK']
|
||||
disks.each_with_index do |disk,i|
|
||||
template=vm['VM/TEMPLATE']
|
||||
if template['DISK']
|
||||
i = 0
|
||||
template.each('DISK') do |disk|
|
||||
source_path=VMDIR+"/#{vm_id}/disk.#{i}"
|
||||
if disk["NAME"] and File.exists?(source_path)
|
||||
if disk["SAVE_AS"]
|
||||
# Get Type
|
||||
image=OpenNebula::Image.new_with_id(disk['IID'], get_one_client)
|
||||
image=OpenNebula::Image.new_with_id(disk['IMAGE_ID'], get_one_client)
|
||||
image.info
|
||||
type=image['TYPE']
|
||||
# Perform the allocate if all goes well
|
||||
@ -62,21 +62,22 @@ disks.each_with_index do |disk,i|
|
||||
# Get the allocated image
|
||||
image=OpenNebula::Image.new_with_id(image.id, get_one_client)
|
||||
image.info
|
||||
template=image.to_hash
|
||||
template=template['IMAGE']['TEMPLATE']
|
||||
template=image['IMAGE/TEMPLATE']
|
||||
|
||||
if !is_successful?(result)
|
||||
exit -1
|
||||
end
|
||||
elsif disk["OVERWRITE"]
|
||||
# Get the allocated image
|
||||
image=OpenNebula::Image.new_with_id(disk['IID'], get_one_client)
|
||||
image=OpenNebula::Image.new_with_id(disk['IMAGE_ID'], get_one_client)
|
||||
image.info
|
||||
image.disable
|
||||
end
|
||||
# Perform the copy to the image repo if needed
|
||||
if File.copy(source_path, image['SOURCE'])
|
||||
if FileUtils.copy(source_path, image['SOURCE'])
|
||||
result=image.enable
|
||||
end
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
end
|
@ -17,7 +17,6 @@
|
||||
|
||||
require 'pp'
|
||||
require 'open3'
|
||||
require 'ftools'
|
||||
require 'CommandManager'
|
||||
|
||||
=begin rdoc
|
||||
@ -84,7 +83,7 @@ class TMPlugin < Hash
|
||||
scripts_text=""
|
||||
|
||||
if File.exist?(scripts_file)
|
||||
scripts_text = open(scripts_file).read
|
||||
scripts_text = File.read(scripts_file)
|
||||
else
|
||||
STDERR.puts("Can not open #{scripts_file}")
|
||||
STDERR.flush
|
||||
|
Loading…
Reference in New Issue
Block a user