1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-16 22:50:10 +03:00

B #1463: VCENTER ONE_MANAGED && vnet hooks working as expected (#1508)

* B #1463: ONE_MANAGED attribute is required

* B #1463: vcenter_hooks activates properly

* B #1463: vn_mad changed to vcenter, error checking on hook
This commit is contained in:
Sergio Semedi Barranco 2017-11-22 17:05:11 +01:00 committed by Tino Vázquez
parent 212de23fab
commit 4aea67a709
3 changed files with 23 additions and 18 deletions

View File

@ -40,29 +40,32 @@ network_id = ARGV[0]
#template = OpenNebula::XMLElement.new
#template.initialize_xml(Base64.decode64(base64_temp), 'VNET')
# waits for a vlan_id attribute to be generated
# only if automatic_vlan activated
def wait_vlanid(vnet)
retries = 5
i = 0
while vnet["VLAN_ID"].nil?
raise "cannot get vlan_id" if i >= retries
sleep 1
i +=1
vnet.info
end
end
template = OpenNebula::VirtualNetwork.new_with_id(network_id, OpenNebula::Client.new)
rc = template.info
if OpenNebula.is_error?(rc)
STDERR.puts rc.message
exit 1
end
if template["VLAN_ID_AUTOMATIC"] == '1'
RETRIES = 5
i = 0
while template["VLAN_ID"].nil?
raise "cannot get vlan_id" if i >= RETRIES
sleep 1
i +=1
template.info
end
end
esx_rollback = [] #Track hosts that require a rollback
managed = template["TEMPLATE/OPENNEBULA_MANAGED"] != "NO"
begin
# Step 0. Only execute for vcenter network driver
if template["VN_MAD"] == "vcenter"
# Step 0. Only execute for vcenter network driver && managed by one
if template["VN_MAD"] == "vcenter" && managed
wait_vlanid(template) if template["VLAN_ID_AUTOMATIC"] == '1'
# Step 1. Extract vnet settings
host_id = template["TEMPLATE/VCENTER_ONE_HOST_ID"]
raise "We require the ID of the OpenNebula host representing a vCenter cluster" if !host_id

View File

@ -37,10 +37,12 @@ require 'base64'
base64_temp = ARGV[1]
template = OpenNebula::XMLElement.new
template.initialize_xml(Base64.decode64(base64_temp), 'VNET')
managed = template["TEMPLATE/OPENNEBULA_MANAGED"] != "NO"
error = template["TEMPLATE/VCENTER_NET_STATE"] == "ERROR"
begin
# Step 0. Only execute for vcenter network driver
if template["VN_MAD"] == "vcenter"
if template["VN_MAD"] == "vcenter" && managed && !error
# Step 1. Extract vnet settings
host_id = template["TEMPLATE/VCENTER_ONE_HOST_ID"]
raise "We require the ID of the OpenNebula host representing a vCenter cluster" if !host_id

View File

@ -125,14 +125,14 @@ class Network
template = "NAME=\"#{network_import_name}\"\n"\
"BRIDGE=\"#{network_name}\"\n"\
"VN_MAD=\"dummy\"\n"\
"VN_MAD=\"vcenter\"\n"\
"VCENTER_PORTGROUP_TYPE=\"#{network_type}\"\n"\
"VCENTER_NET_REF=\"#{network_ref}\"\n"\
"VCENTER_INSTANCE_ID=\"#{vcenter_uuid}\"\n"
"VCENTER_INSTANCE_ID=\"#{vcenter_uuid}\"\n"\
"OPENNEBULA_MANAGED=\"NO\"\n"
if unmanaged == "wild"
template += "VCENTER_FROM_WILD=\"#{template_id}\"\n"
template += "OPENNEBULA_MANAGED=\"NO\"\n"
end
template += "VCENTER_CCR_REF=\"#{ccr_ref}\"\n" if !unmanaged