From 4f144b2943840a3e06af590fe5004afdb5945d81 Mon Sep 17 00:00:00 2001 From: Angel Luis Moya Gonzalez Date: Tue, 2 Jun 2020 16:51:18 +0200 Subject: [PATCH] F #4302: Fix NSX Security Groups errors (#4866) Co-authored-by: mouyaq --- src/vmm_mad/remotes/lib/nsx_driver/nsxt_dfw.rb | 8 ++------ src/vmm_mad/remotes/lib/nsx_driver/nsxv_dfw.rb | 14 ++++++-------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/vmm_mad/remotes/lib/nsx_driver/nsxt_dfw.rb b/src/vmm_mad/remotes/lib/nsx_driver/nsxt_dfw.rb index c0ca898666..38a20edb41 100644 --- a/src/vmm_mad/remotes/lib/nsx_driver/nsxt_dfw.rb +++ b/src/vmm_mad/remotes/lib/nsx_driver/nsxt_dfw.rb @@ -37,12 +37,8 @@ module NSXDriver # its section_id. Returns its section_id if OpenNebula # section already exists def init_section - one_section = section_by_name( - NSXConstants::ONE_SECTION_NAME - ) - one_section ||= create_section( - NSXConstants::ONE_SECTION_NAME - ) + one_section = section_by_name(NSXConstants::ONE_SECTION_NAME) + one_section ||= create_section(NSXConstants::ONE_SECTION_NAME) return one_section['id'] if one_section end diff --git a/src/vmm_mad/remotes/lib/nsx_driver/nsxv_dfw.rb b/src/vmm_mad/remotes/lib/nsx_driver/nsxv_dfw.rb index 76321e7817..9e813778b9 100644 --- a/src/vmm_mad/remotes/lib/nsx_driver/nsxv_dfw.rb +++ b/src/vmm_mad/remotes/lib/nsx_driver/nsxv_dfw.rb @@ -38,12 +38,8 @@ module NSXDriver # its section_id. Returns its section_id if OpenNebula # section already exists def init_section - one_section = section_by_name( - NSXConstants::ONE_SECTION_NAME - ) - one_section ||= create_section( - NSXConstants::ONE_SECTION_NAME - ) + one_section = section_by_name(NSXConstants::ONE_SECTION_NAME) + one_section ||= create_section(NSXConstants::ONE_SECTION_NAME) return one_section.xpath('@id').text if one_section end @@ -91,10 +87,12 @@ module NSXDriver # - nil | [Nokogiri::XML::NodeSet] section def section_by_name(section_name) url = @url_sections + '?name=' + section_name - result = @nsx_client.get(url) + result = @nsx_client.get(url) rescue nil + return nil if result.nil? + xp = NSXConstants::NSXV_DFW_SECTION_XPATH section = result.xpath(xp) - return section unless section.empty? + section end # Create new section