1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-04-01 06:50:25 +03:00

B #5418: vcenter automatic vlan_id working! (#515)

* B #5419: generating vlan id 4 vcenter

* B #5419: vcenter_create_vnet hook waits VLAN_ID attribute
This commit is contained in:
Sergio Semedi Barranco 2017-10-06 18:22:51 +02:00 committed by Tino Vázquez
parent 773a4cb29b
commit 139f448a76
3 changed files with 31 additions and 5 deletions

View File

@ -58,7 +58,8 @@ public:
EBTABLES = 3,
FW = 4,
OVSWITCH = 5,
VXLAN = 6
VXLAN = 6,
VCENTER = 7
};
static string driver_to_str(VirtualNetworkDriver ob)
@ -72,6 +73,7 @@ public:
case FW: return "fw";
case OVSWITCH: return "ovswitch";
case VXLAN: return "vxlan";
case VCENTER: return "vcenter";
}
};
@ -101,6 +103,10 @@ public:
{
return VXLAN;
}
else if ( ob == "vcenter" )
{
return VCENTER;
}
else
{
return NONE;

View File

@ -35,10 +35,29 @@ require 'vcenter_driver'
require 'base64'
network_id = ARGV[0]
base64_temp = ARGV[1]
#base64_temp = ARGV[1]
#template = OpenNebula::XMLElement.new
#template.initialize_xml(Base64.decode64(base64_temp), 'VNET')
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
template = OpenNebula::XMLElement.new
template.initialize_xml(Base64.decode64(base64_temp), 'VNET')
esx_rollback = [] #Track hosts that require a rollback
begin
@ -53,13 +72,13 @@ begin
pg_type = template["TEMPLATE/VCENTER_PORTGROUP_TYPE"]
sw_name = template["TEMPLATE/VCENTER_SWITCH_NAME"]
mtu = template["TEMPLATE/MTU"]
vlan_id = template["VLAN_ID"] || 0
if template["TEMPLATE/VCENTER_SWITCH_NPORTS"]
nports = template["TEMPLATE/VCENTER_SWITCH_NPORTS"]
else
nports = pg_type == "Port Group" ? 128 : 8
end
vlan_id = template["VLAN_ID"] || template["AUTOMATIC_VLAN_ID"] || 0
# Step 2. Contact cluster and extract cluster's info
vi_client = VCenterDriver::VIClient.new_from_host(host_id)

View File

@ -381,6 +381,7 @@ int VirtualNetworkPool::set_vlan_id(VirtualNetwork * vn)
break;
case VirtualNetwork::VLAN:
case VirtualNetwork::VCENTER:
case VirtualNetwork::OVSWITCH:
start_vlan = vlan_id_bitmap.get_start_bit();
hint_vlan = start_vlan + (vn->get_oid() % (4095 - start_vlan ));