1313# limitations under the License.
1414#
1515
16+ from distutils .version import LooseVersion
1617import pytest
1718
1819from f5 .bigip .resource import MissingRequiredCreationParameter
1920from f5 .bigip .resource import MissingUpdateParameter
21+ from f5 .bigip .tm .net .vlan import TagModeDisallowedForTMOSVersion
2022from icontrol .session import iControlUnexpectedHTTPError
2123from 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
0 commit comments