Fix transport zones extraction from the transport node
Support the case of NSX3 with multiple host_switches Change-Id: Iba17fa861212906f613f866a383841bf7e683474
This commit is contained in:
parent
68dc449e80
commit
3a4fe9b6bb
@ -1996,11 +1996,13 @@ class TransportNode(BaseTestResource):
|
||||
tn = self.get_mocked_resource()
|
||||
self.nsxlib.feature_supported = mock.MagicMock()
|
||||
with mock.patch.object(tn.client, 'url_get', return_value=fake_tn):
|
||||
# Test the api with its 2 versions
|
||||
self.nsxlib.feature_supported.side_effect = [False, True]
|
||||
tzs = tn.get_transport_zones(fake_tn['id'])
|
||||
self.assertEqual([test_constants.FAKE_TZ_UUID], tzs)
|
||||
tzs = tn.get_transport_zones(fake_tn['id'])
|
||||
self.assertEqual([test_constants.FAKE_TZ_EP_UUID], tzs)
|
||||
self.assertEqual([test_constants.FAKE_TZ_EP_UUID,
|
||||
test_constants.FAKE_TZ_EP_UUID2], tzs)
|
||||
|
||||
|
||||
class MetadataProxy(BaseTestResource):
|
||||
|
@ -948,9 +948,11 @@ class NsxLibTransportNode(utils.NsxLibApiBase):
|
||||
return []
|
||||
|
||||
host_switches = tn.get('host_switch_spec').get('host_switches', [])
|
||||
|
||||
return [ep.get('transport_zone_id') for ep in
|
||||
host_switches[0].get('transport_zone_endpoints', [])]
|
||||
tzs = []
|
||||
for host_switch in host_switches:
|
||||
tzs.extend([ep.get('transport_zone_id') for ep in
|
||||
host_switch.get('transport_zone_endpoints', [])])
|
||||
return tzs
|
||||
else:
|
||||
return [ep.get('transport_zone_id') for ep in
|
||||
tn.get('transport_zone_endpoints', [])]
|
||||
|
Loading…
x
Reference in New Issue
Block a user