NSX|V: learn the default L3 section ID
Do not use a hard coded value for the defualt section ID. Change-Id: I74f6f3ae3d2347e1f8cf60ec8e4b99da04082057
This commit is contained in:
parent
909cd6d1d4
commit
fcb42c73e4
@ -426,7 +426,11 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
|||||||
self.nsx_v.vcns.update_section_by_id(
|
self.nsx_v.vcns.update_section_by_id(
|
||||||
section_id, 'ip', section_req_body)
|
section_id, 'ip', section_req_body)
|
||||||
else:
|
else:
|
||||||
h, c = self.nsx_v.vcns.create_section('ip', section_req_body)
|
# cluster section does not exists. Create it above the
|
||||||
|
# default l3 section
|
||||||
|
l3_id = self.nsx_v.vcns.get_default_l3_id()
|
||||||
|
h, c = self.nsx_v.vcns.create_section('ip', section_req_body,
|
||||||
|
insert_before=l3_id)
|
||||||
section_id = self.nsx_sg_utils.parse_and_get_section_id(c)
|
section_id = self.nsx_sg_utils.parse_and_get_section_id(c)
|
||||||
return section_id
|
return section_id
|
||||||
|
|
||||||
|
@ -627,6 +627,16 @@ class Vcns(object):
|
|||||||
return self.do_request(HTTP_GET, section_uri, format='xml',
|
return self.do_request(HTTP_GET, section_uri, format='xml',
|
||||||
decode=False)
|
decode=False)
|
||||||
|
|
||||||
|
def get_default_l3_id(self):
|
||||||
|
"""Retrieve the id of the default l3 section."""
|
||||||
|
h, firewall_config = self.get_dfw_config()
|
||||||
|
root = utils.normalize_xml(firewall_config)
|
||||||
|
for child in root:
|
||||||
|
if str(child.tag) == 'layer3Sections':
|
||||||
|
sections = list(child.iter('section'))
|
||||||
|
default = sections[-1]
|
||||||
|
return default.attrib['id']
|
||||||
|
|
||||||
def get_dfw_config(self):
|
def get_dfw_config(self):
|
||||||
uri = FIREWALL_PREFIX
|
uri = FIREWALL_PREFIX
|
||||||
return self.do_request(HTTP_GET, uri, decode=False, format='xml')
|
return self.do_request(HTTP_GET, uri, decode=False, format='xml')
|
||||||
|
@ -1006,6 +1006,9 @@ class FakeVcns(object):
|
|||||||
def update_section_by_id(self, id, type, request):
|
def update_section_by_id(self, id, type, request):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def get_default_l3_id(self):
|
||||||
|
return 1234
|
||||||
|
|
||||||
def get_dfw_config(self):
|
def get_dfw_config(self):
|
||||||
response = ""
|
response = ""
|
||||||
for sec_id in range(0, self._sections['section_ids']):
|
for sec_id in range(0, self._sections['section_ids']):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user