1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-23 17:33:56 +03:00

F #3380: adapt DDC to new hook system (#3727)

This commit is contained in:
Alejandro Huertas Herrero 2019-09-19 11:28:36 +02:00 committed by Ruben S. Montero
parent e96f6d0e24
commit 5f660a2c6b
5 changed files with 45 additions and 6 deletions

View File

@ -222,6 +222,7 @@ else
fi
SHARE_DIRS="$SHARE_LOCATION/examples \
$SHARE_LOCATION/examples/alias_ip \
$SHARE_LOCATION/websockify \
$SHARE_LOCATION/websockify/websockify \
$SHARE_LOCATION/esx-fw-vnc \
@ -522,6 +523,9 @@ INSTALL_FILES=(
NETWORK_VCENTER_FILES:$VAR_LOCATION/remotes/vnm/vcenter
NETWORK_ALIAS_SDNAT_FILES:$VAR_LOCATION/remotes/vnm/alias_sdnat
EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples
EXAMPLE_DDC_SHARE_FILES:$SHARE_LOCATION/examples/alias_ip
WEBSOCKIFY_SHARE_RUN_FILES:$SHARE_LOCATION/websockify
WEBSOCKIFY_SHARE_MODULE_FILES:$SHARE_LOCATION/websockify/websockify
WEBSOCKIFY_SHARE_RUN_FILES:$SHARE_LOCATION/websockify
WEBSOCKIFY_SHARE_MODULE_FILES:$SHARE_LOCATION/websockify/websockify
ESX_FW_VNC_SHARE_FILES:$SHARE_LOCATION/esx-fw-vnc
@ -1640,6 +1644,14 @@ EXAMPLE_SHARE_FILES="share/examples/vm.template \
share/examples/private.net \
share/examples/public.net"
#-------------------------------------------------------------------------------
# Sample files, to be installed under $SHARE_LOCATION/examples/alias_ip
#-------------------------------------------------------------------------------
EXAMPLE_DDC_SHARE_FILES="share/examples/alias_ip/running_hook \
share/examples/alias_ip/hotplug_hook \
share/examples/alias_ip/done_hook"
#-------------------------------------------------------------------------------
# Files required to interact with the websockify server
#-------------------------------------------------------------------------------

View File

@ -0,0 +1,8 @@
ARGUMENTS = "$TEMPLATE"
ARGUMENTS_STDIN = "yes"
COMMAND = "alias_ip/alias_ip.rb"
NAME = "alias_ip_done"
ON = "DONE"
REMOTE = "NO"
RESOURCE = "VM"
TYPE = "state"

View File

@ -0,0 +1,10 @@
ARGUMENTS = "$TEMPLATE"
ARGUMENTS_STDIN = "yes"
COMMAND = "alias_ip/alias_ip.rb"
LCM_STATE = "HOTPLUG_NIC"
NAME = "alias_ip_hotplug"
ON = "CUSTOM"
REMOTE = "NO"
RESOURCE = "VM"
STATE = "ACTIVE"
TYPE = "state"

View File

@ -0,0 +1,10 @@
ARGUMENTS = "$TEMPLATE"
ARGUMENTS_STDIN = "yes"
COMMAND = "alias_ip/alias_ip.rb"
LCM_STATE = "RUNNING"
NAME = "alias_ip_running"
ON = "CUSTOM"
REMOTE = "NO"
RESOURCE = "VM"
STATE = "ACTIVE"
TYPE = "state"

View File

@ -43,18 +43,17 @@ include OpenNebula
# rubocop:enable Style/MixinUsage
require 'base64'
require 'nokogiri'
require 'open3'
require 'packet'
###
VM_ID = ARGV[0]
VM_XML = Base64.decode64(ARGV[1])
raw_vm_template = Base64.decode64(STDIN.read)
xml_vm_template = Nokogiri::XML(raw_vm_template)
if VM_ID.nil? || VM_ID.empty? || VM_XML.nil? || VM_XML.empty?
STDERR.puts 'USAGE: <VM ID> <VM XML>'
exit(-1)
end
VM_ID = xml_vm_template.xpath('VM/ID').text
VM_XML = raw_vm_template
##########
# Helpers