mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-23 17:33:56 +03:00
vCenter hooks located at: <ONE_LOCATION>/remotes/hooks/vcenter/templates are registered automatically when import a vcenter cluster with the command "onevcenter"
This commit is contained in:
parent
83f61b02cc
commit
28f07966cf
10
install.sh
10
install.sh
@ -344,6 +344,7 @@ VAR_DIRS="$VAR_LOCATION/remotes \
|
||||
$VAR_LOCATION/remotes/hooks \
|
||||
$VAR_LOCATION/remotes/hooks/ft \
|
||||
$VAR_LOCATION/remotes/hooks/vcenter \
|
||||
$VAR_LOCATION/remotes/hooks/vcenter/templates \
|
||||
$VAR_LOCATION/remotes/hooks/raft \
|
||||
$VAR_LOCATION/remotes/hooks/alias_ip \
|
||||
$VAR_LOCATION/remotes/datastore \
|
||||
@ -532,6 +533,7 @@ INSTALL_FILES=(
|
||||
FOLLOWER_CLEANUP_SHARE_FILE:$SHARE_LOCATION
|
||||
HOOK_FT_FILES:$VAR_LOCATION/remotes/hooks/ft
|
||||
HOOK_VCENTER_FILES:$VAR_LOCATION/remotes/hooks/vcenter
|
||||
HOOK_VCENTER_TMPLS:$VAR_LOCATION/remotes/hooks/vcenter/templates
|
||||
HOOK_RAFT_FILES:$VAR_LOCATION/remotes/hooks/raft
|
||||
HOOK_ALIAS_IP_FILES:$VAR_LOCATION/remotes/hooks/alias_ip
|
||||
COMMON_CLOUD_LIB_FILES:$LIB_LOCATION/ruby/cloud
|
||||
@ -1682,6 +1684,14 @@ HOOK_FT_FILES="share/hooks/ft/host_error.rb \
|
||||
HOOK_VCENTER_FILES="share/hooks/vcenter/create_vcenter_net.rb \
|
||||
share/hooks/vcenter/delete_vcenter_net.rb"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# HOOK templates, to be installed under
|
||||
# $VAR_LOCATION/remotes/hooks/vcenter/templates
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
HOOK_VCENTER_TMPLS="share/hooks/vcenter/templates/create_vcenter_net.tmpl \
|
||||
share/hooks/vcenter/templates/delete_vcenter_net.tmpl"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# HOOK RAFT scripts, to be installed under $VAR_LOCATION/remotes/hooks/raft
|
||||
#-------------------------------------------------------------------------------
|
||||
|
6
share/hooks/vcenter/templates/create_vcenter_net.tmpl
Normal file
6
share/hooks/vcenter/templates/create_vcenter_net.tmpl
Normal file
@ -0,0 +1,6 @@
|
||||
NAME = vcenter_net_create
|
||||
TYPE = api
|
||||
COMMAND = vcenter/create_vcenter_net.rb
|
||||
CALL = "one.vn.allocate"
|
||||
ARGUMENTS = "$API"
|
||||
ARGUMENTS_STDIN = yes
|
6
share/hooks/vcenter/templates/delete_vcenter_net.tmpl
Normal file
6
share/hooks/vcenter/templates/delete_vcenter_net.tmpl
Normal file
@ -0,0 +1,6 @@
|
||||
NAME = vcenter_net_delete
|
||||
TYPE = api
|
||||
COMMAND = vcenter/delete_vcenter_net.rb
|
||||
CALL = "one.vn.delete"
|
||||
ARGUMENTS = "$API"
|
||||
ARGUMENTS_STDIN = yes
|
@ -15,6 +15,18 @@
|
||||
#--------------------------------------------------------------------------- #
|
||||
|
||||
module VCenterDriver
|
||||
|
||||
ONE_LOCATION = ENV['ONE_LOCATION'] unless defined?(ONE_LOCATION)
|
||||
|
||||
if !ONE_LOCATION
|
||||
RUBY_LIB_LOCATION = '/usr/lib/one/ruby' unless defined?(RUBY_LIB_LOCATION)
|
||||
GEMS_LOCATION = '/usr/share/one/gems' unless defined?(GEMS_LOCATION)
|
||||
HOOK_LOCATION = '/var/lib/one/remotes/hooks' unless defined?(HOOK_LOCATION)
|
||||
else
|
||||
RUBY_LIB_LOCATION = ONE_LOCATION + '/lib/ruby' unless defined?(RUBY_LIB_LOCATION)
|
||||
GEMS_LOCATION = ONE_LOCATION + '/share/gems' unless defined?(GEMS_LOCATION)
|
||||
HOOK_LOCATION = ONE_LOCATION + '/remotes/hooks' unless defined?(HOOK_LOCATION)
|
||||
end
|
||||
class VcImporter
|
||||
attr_accessor :list
|
||||
|
||||
@ -508,6 +520,8 @@ module VCenterDriver
|
||||
STDOUT.puts
|
||||
}
|
||||
}
|
||||
VCenterDriver::VcImporter.register_hooks
|
||||
|
||||
rescue Interrupt => e
|
||||
puts "\n"
|
||||
exit 0 #Ctrl+C
|
||||
@ -521,5 +535,21 @@ module VCenterDriver
|
||||
|
||||
end
|
||||
|
||||
def self.register_hooks
|
||||
hooks_path = HOOK_LOCATION + '/vcenter/templates'
|
||||
client = OpenNebula::Client.new
|
||||
hook = OpenNebula::Hook.new(OpenNebula::Hook.build_xml, client)
|
||||
hook_pool = OpenNebula::HookPool.new(client)
|
||||
rc = hook_pool.info
|
||||
if OpenNebula.is_error?(rc)
|
||||
STDERR.puts rc.message
|
||||
exit 1
|
||||
end
|
||||
hook_files = Dir["#{hooks_path}/*.tmpl"]
|
||||
hook_files.each do |hook_file|
|
||||
hook.allocate(File.open(hook_file).read)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user