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

F #3440: Fix bug creating NSX networks (#3821)

* F #3440: Fix bug creating NSX networks

Fix bug when creating NSX network without
transport zone. Added more checks and
exceptions to manage them.

* F #3440: Added backtrace to error message
This commit is contained in:
Angel Luis Moya Gonzalez 2019-10-08 10:40:24 +02:00 committed by Tino Vázquez
parent bb04178ad5
commit 0accfb2c6d
3 changed files with 43 additions and 31 deletions

View File

@ -158,8 +158,13 @@ begin
<controlPlaneMode>UNICAST_MODE</controlPlaneMode>\
<guestVlanAllowed>false</guestVlanAllowed>\
</virtualWireCreateSpec>"
logical_switch = NSXDriver::VirtualWire
.new(nsx_client, nil, tz_id, virtual_wire_spec)
begin
logical_switch = NSXDriver::VirtualWire
.new(nsx_client, nil, tz_id, virtual_wire_spec)
rescue StandardError => e
STDERR.puts "ERROR: #{e.message} #{e.backtrace}"
exit(-1)
end
# Get reference will have in vcenter and vni
vnet_ref = logical_switch.ls_vcenter_ref
ls_vni = logical_switch.ls_vni
@ -180,9 +185,14 @@ begin
"description": "#{ls_description}"
}
)
logical_switch = NSXDriver::OpaqueNetwork
.new(nsx_client, nil, nil, opaque_network_spec)
# Get NSX_VNI
begin
logical_switch = NSXDriver::OpaqueNetwork
.new(nsx_client, nil, tz_id, opaque_network_spec)
rescue StandardError => e
STDERR.puts "ERROR: #{e.message} #{e.backtrace}"
exit(-1)
end
# Get reference will have in vcenter and vni
vnet_ref = dc.nsx_network(logical_switch.ls_id, pg_type)
ls_vni = logical_switch.ls_vni
ls_name = logical_switch.ls_name

View File

@ -24,7 +24,7 @@ module NSXDriver
SECTION_LS = '/logical-switches/'
# CONSTRUCTOR
def initialize(nsx_client, ls_id = nil, _tz_id = nil, ls_data = nil)
def initialize(nsx_client, ls_id = nil, tz_id = nil, ls_data = nil)
super(nsx_client)
# Construct base URLs
@base_url = "#{@nsx_client.nsxmgr}/api/v1"
@ -32,18 +32,19 @@ module NSXDriver
if ls_id
initialize_with_id(ls_id)
else
if tz_id
if ls_data
@ls_id = new_logical_switch(ls_data)
# Construct URL of the created logical switch
@url_ls = @base_url + SECTION_LS + @ls_id
@ls_vni = ls_vni
@ls_name = ls_name
@tz_id = ls_tz
@admin_display = 'UP'
end
raise 'Missing logical switch data' unless ls_data
end
raise 'Missing transport zone id' unless tz_id
raise 'Missing logical switch data' unless ls_data
@ls_id = new_logical_switch(ls_data)
raise 'Opaque Network not created in NSX' unless @ls_id
# Construct URL of the created logical switch
@url_ls = @base_url + SECTION_LS + @ls_id
@ls_vni = ls_vni
@ls_name = ls_name
@tz_id = ls_tz
@admin_display = 'UP'
end
end

View File

@ -38,19 +38,20 @@ module NSXDriver
if ls_id
initialize_with_id(ls_id)
else
if tz_id
if ls_data
@ls_id = new_logical_switch(ls_data, tz_id)
# Construct URL of the created logical switch
@url_ls = @base_url + SECTION_LS + @ls_id
@ls_vni = ls_vni
@ls_name = ls_name
@tz_id = ls_tz
@tenant_id = 'virtual wire tenant'
@guest_vlan_allowed = false
end
raise 'Missing logical switch data' unless ls?
end
raise 'Missing transport zone id' unless tz_id
raise 'Missing logical switch data' unless ls_data
@ls_id = new_logical_switch(ls_data, tz_id)
raise 'Virtual Wire not created in NSX' unless @ls_id
# Construct URL of the created logical switch
@url_ls = @base_url + SECTION_LS + @ls_id
@ls_vni = ls_vni
@ls_name = ls_name
@tz_id = ls_tz
@tenant_id = 'virtual wire tenant'
@guest_vlan_allowed = false
end
end