Hi @Marco,
Did you look at the alias_ip hook.rb in the hooks folder for inspiration?
I’d put the shebang as a first line in the script and include the folloing common magic that will include the neeed rubygems provided by opennebula
#!/usr/bin/env ruby
ONE_LOCATION = ENV['ONE_LOCATION']
if !ONE_LOCATION
RUBY_LIB_LOCATION = '/usr/lib/one/ruby'
GEMS_LOCATION = '/usr/share/one/gems'
LOG_FILE = '/var/log/one/hook-alias_ip.log'
else
RUBY_LIB_LOCATION = ONE_LOCATION + '/lib/ruby'
GEMS_LOCATION = ONE_LOCATION + '/share/gems'
LOG_FILE = ONE_LOCATION + '/var/hook-alias_ip.log'
end
if File.directory?(GEMS_LOCATION)
$LOAD_PATH.reject! {|l| l =~ /vendor_ruby/ }
require 'rubygems'
Gem.use_paths(File.realpath(GEMS_LOCATION))
end
$LOAD_PATH << RUBY_LIB_LOCATION
`
It is better to provide the VM template via stdin because the VM’s metadata could become a huge…
Best Regards,
Anton Todorov