From 855bbab9418adacebc1abe36140574c0438951f2 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Mon, 5 Apr 2021 13:43:21 +0200 Subject: [PATCH] M #-: Minor Fix for NIC_ALIAS & Elastic --- src/vnm_mad/remotes/elastic/elastic.rb | 7 ++++--- src/vnm_mad/remotes/elastic/pre | 11 ++++------- src/vnm_mad/remotes/lib/vnm_driver.rb | 20 ++++++++++---------- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/vnm_mad/remotes/elastic/elastic.rb b/src/vnm_mad/remotes/elastic/elastic.rb index 4968c1d5cc..ceba0a6927 100644 --- a/src/vnm_mad/remotes/elastic/elastic.rb +++ b/src/vnm_mad/remotes/elastic/elastic.rb @@ -100,9 +100,10 @@ class ElasticDriver < VNMMAD::VNMDriver provider.deactivate(cmds, nic) if provider.respond_to? :deactivate - next if nic[:parent_nic] || nic[:conf][:keep_empty_bridge] - - cmds.add :ip, "link delete #{nic[:bridge]} | true" + # TODO: MUST check if bridge is empty. Move to remote_clean + #next if nic[:parent_nic] || nic[:conf][:keep_empty_bridge] + # + #cmds.add :ip, "link delete #{nic[:bridge]} | true" end cmds.run_remote(@ssh) diff --git a/src/vnm_mad/remotes/elastic/pre b/src/vnm_mad/remotes/elastic/pre index 22a097a24c..55c94e60ce 100755 --- a/src/vnm_mad/remotes/elastic/pre +++ b/src/vnm_mad/remotes/elastic/pre @@ -44,17 +44,14 @@ $LOAD_PATH << File.join(File.dirname(__FILE__), '..') require 'vnmmad' template64 = STDIN.read +deploy_id = ARGV[0] -deploy_id = ARGV[0] +xpath = "TEMPLATE/NIC[VN_MAD='elastic']" begin - drv = VNMMAD::VLANDriver.from_base64(template64, - "TEMPLATE/NIC[VN_MAD='elastic']", - deploy_id) + drv = VNMMAD::NoVLANDriver.from_base64(template64, xpath, deploy_id) - drv.create_bridges - - drv.run_hooks(ARGV, template64) + drv.run_hooks(ARGV, template64) if drv.activate == 0 rescue StandardError => e OpenNebula.log_error(e.message) OpenNebula.log_error(e.backtrace) diff --git a/src/vnm_mad/remotes/lib/vnm_driver.rb b/src/vnm_mad/remotes/lib/vnm_driver.rb index 014b466ebb..6c10cb6369 100644 --- a/src/vnm_mad/remotes/lib/vnm_driver.rb +++ b/src/vnm_mad/remotes/lib/vnm_driver.rb @@ -71,11 +71,7 @@ module VNMMAD # Executes the given block on each NIC def process @vm.each_nic do |nic| - add_nic_conf(nic) - add_bridge_conf(nic) - add_ovs_bridge_conf(nic) - add_ip_link_conf(nic) - + nic_confs(nic) yield(nic) end end @@ -83,19 +79,23 @@ module VNMMAD # Executes the given block on each NIC def process_all @vm.each_nic do |nic| - add_nic_conf(nic) - add_bridge_conf(nic) - add_ovs_bridge_conf(nic) - add_ip_link_conf(nic) - + nic_confs(nic) yield(nic) end @vm.each_nic_alias do |nic| + nic_confs(nic) yield(nic) end end + def nic_confs(nic) + add_nic_conf(nic) + add_bridge_conf(nic) + add_ovs_bridge_conf(nic) + add_ip_link_conf(nic) + end + # Parse network configuration and add it to the nic def add_nic_conf(nic) return if nic[:conf] && nic[:conf].instance_of?(Hash)