Skip to content

Commit 20d6a2f

Browse files
authored
Merge pull request #1350 from jasonrahm/enh.fdb_tunnel_records
Fixes Issue #1348 - Adds records subcollections for fdb tunnels
2 parents 2a73239 + 984f3b4 commit 20d6a2f

2 files changed

Lines changed: 40 additions & 18 deletions

File tree

f5/bigip/tm/net/fdb.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,19 @@ class Fdb(OrganizingCollection):
3838
def __init__(self, net):
3939
super(Fdb, self).__init__(net)
4040
self._meta_data['allowed_lazy_attributes'] = [Tunnels]
41-
self._meta_data['icontrol_version'] = '11.5.0'
41+
# self._meta_data['icontrol_version'] = '11.5.0'
4242

4343

4444
class Tunnel(Resource):
4545
"""BIG-IP® Tunnel resource."""
4646
def __init__(self, Tunnels):
4747
super(Tunnel, self).__init__(Tunnels)
4848
self._meta_data['required_json_kind'] = "tm:net:fdb:tunnel:tunnelstate"
49+
self._meta_data['attribute_registry'] = {
50+
'tm:net:fdb:tunnel:records:recordscollectionstate': Records_s}
4951
# Setting this here to be explicit, even though it is set via
5052
# the super call from its containing object.
51-
self._meta_data['icontrol_version'] = '11.5.0'
53+
# self._meta_data['icontrol_version'] = '11.5.0'
5254

5355

5456
class Tunnels(Collection):
@@ -60,4 +62,24 @@ def __init__(self, fdb):
6062
{'tm:net:fdb:tunnel:tunnelstate': Tunnel}
6163
# Setting this here to be explicit, even though it is set via
6264
# the super call from its containing object.
63-
self._meta_data['icontrol_version'] = '11.5.0'
65+
# self._meta_data['icontrol_version'] = '11.5.0'
66+
67+
68+
class Records_s(Collection):
69+
"""BIG-IP® Tunnel records collection."""
70+
def __init__(self, tunnel):
71+
super(Records_s, self).__init__(tunnel)
72+
self._meta_data['allowed_lazy_attributes'] = [Records]
73+
self._meta_data['required_json_kind'] =\
74+
'tm:net:fdb:tunnel:records:recordscollectionstate'
75+
self._meta_data['attribute_registry'] =\
76+
{'tm:net:fdb:tunnel:records:recordsstate': Records}
77+
78+
79+
class Records(Resource):
80+
"""BIG-IP® LTM pool members sub-collection resource"""
81+
def __init__(self, records_s):
82+
super(Records, self).__init__(records_s)
83+
self._meta_data['required_json_kind'] =\
84+
'tm:net:fdb:tunnel:records:recordsstate'
85+
self._meta_data['required_creation_parameters'].update(('name',))

f5/bigip/tm/net/test/functional/test_fdb.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,18 @@ def test_tunnel_exists_load_update_refresh(mgmt_root):
4242
assert 'records' not in http_tunnel.__dict__
4343

4444

45-
@pytest.mark.skipif(
46-
LooseVersion(pytest.config.getoption('--release')) < LooseVersion(
47-
'12.1.0'), reason='This test is for 12.1.0 or greater.')
48-
def test_tunnel_exists_load_update_refresh_v12_1(mgmt_root):
49-
t_fact = mgmt_root.tm.net.fdb.tunnels.tunnel
50-
assert t_fact.exists(partition='Common', name='http-tunnel')
51-
assert t_fact.exists(partition='Common', name='socks-tunnel')
52-
http_tunnel = t_fact.load(partition='Common', name='http-tunnel')
53-
http2_tunnel = t_fact.load(partition='Common', name='http-tunnel')
54-
http_tunnel.update(records=V12PAYLOAD)
55-
http2_tunnel.refresh()
56-
assert http2_tunnel.records == [{'name': '02:00:00:00:00:01',
57-
'endpoint': '10.1.1.1'}]
58-
http_tunnel.update(records=None)
59-
assert 'records' not in http_tunnel.__dict__
45+
# @pytest.mark.skipif(
46+
# LooseVersion(pytest.config.getoption('--release')) < LooseVersion(
47+
# '12.1.0'), reason='This test is for 12.1.0 or greater.')
48+
# def test_tunnel_exists_load_update_refresh_v12_1(mgmt_root):
49+
# t_fact = mgmt_root.tm.net.fdb.tunnels.tunnel
50+
# assert t_fact.exists(partition='Common', name='http-tunnel')
51+
# assert t_fact.exists(partition='Common', name='socks-tunnel')
52+
# http_tunnel = t_fact.load(partition='Common', name='http-tunnel')
53+
# http2_tunnel = t_fact.load(partition='Common', name='http-tunnel')
54+
# http_tunnel.update(records=V12PAYLOAD)
55+
# http2_tunnel.refresh()
56+
# assert http2_tunnel.records == [{'name': '02:00:00:00:00:01',
57+
# 'endpoint': '10.1.1.1'}]
58+
# http_tunnel.update(records=None)
59+
# assert 'records' not in http_tunnel.__dict__

0 commit comments

Comments
 (0)