Get transport zone type api

Change-Id: Ibe674ac95f794b5c01dc9fd5d3566f98b7b05d05
This commit is contained in:
Adit Sarfaty 2017-08-20 10:23:50 +03:00
parent 129a47ad03
commit 0b62cec7eb
3 changed files with 39 additions and 0 deletions

View File

@ -320,3 +320,12 @@ FAKE_SERVICE = {
"target_type": "LogicalRouter"
}
}
FAKE_TZ_UUID = uuidutils.generate_uuid()
FAKE_TZ = {
"resource_type": "TransportZone",
"revision": 0,
"id": FAKE_TZ_UUID,
"display_name": FAKE_NAME,
"transport_type": "OVERLAY"
}

View File

@ -1048,3 +1048,26 @@ class TestNsxSearch(nsxlib_testcase.NsxClientTestCase):
self.assertRaises(exceptions.ManagerError,
self.nsxlib.get_id_by_resource_and_tag,
res_type, scope, tag, alert_multiple=True)
class TransportZone(nsxlib_testcase.NsxClientTestCase):
def _mocked_tz(self, session_response=None):
return self.mocked_resource(
core_resources.NsxLibTransportZone,
session_response=session_response)
def test_get_transport_zone(self):
fake_tz = test_constants.FAKE_TZ.copy()
tz = self._mocked_tz()
tz.get(fake_tz['id'])
test_client.assert_json_call(
'get', tz,
'https://1.2.3.4/api/v1/transport-zones/%s' % fake_tz['id'])
def test_get_transport_zone_type(self):
fake_tz = test_constants.FAKE_TZ.copy()
tz = self._mocked_tz()
with mock.patch.object(tz.client, 'url_get', return_value=fake_tz):
tz_type = tz.get_transport_type(fake_tz['id'])
self.assertEqual(tz.TRANSPORT_TYPE_OVERLAY, tz_type)

View File

@ -656,6 +656,9 @@ class NsxLibEdgeCluster(utils.NsxLibApiBase):
class NsxLibTransportZone(utils.NsxLibApiBase):
TRANSPORT_TYPE_VLAN = 'VLAN'
TRANSPORT_TYPE_OVERLAY = 'OVERLAY'
@property
def uri_segment(self):
return 'transport-zones'
@ -664,6 +667,10 @@ class NsxLibTransportZone(utils.NsxLibApiBase):
def resource_type(self):
return 'TransportZone'
def get_transport_type(self, uuid):
tz = self.get(uuid)
return tz['transport_type']
class NsxLibDhcpProfile(utils.NsxLibApiBase):