Skip to content

Commit 552bb01

Browse files
committed
Correct edge case in ltm node api for address + fqdn
Issues: Fixes #1500 Problem: The ltm node api has an edge case with the address value "any6" when it is specified with the fqdn key. The patch that originally fixed this issue was causing the bigip_node module in ansible to break. Analysis: This patch handles that edge case and allows it. Tests: * functional
1 parent a97a2ef commit 552bb01

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

f5/bigip/tm/ltm/node.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ def create(self, **kwargs):
6262
has_any = [set(x).issubset(args) for x in required_one_of]
6363
if len([x for x in has_any if x is True]) == 1:
6464
return self._create(**kwargs)
65+
elif 'address' in kwargs and kwargs['address'] == 'any6' and 'fqdn' in kwargs:
66+
return self._create(**kwargs)
6567

6668
raise RequiredOneOf(required_one_of)
6769

f5/bigip/tm/ltm/test/functional/test_node.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import pytest
1717

18+
from distutils.version import LooseVersion
1819
from f5.sdk_exception import NodeStateModifyUnsupported
1920
from f5.sdk_exception import RequiredOneOf
2021

@@ -202,6 +203,38 @@ def test_session_modify_error(self, request, mgmt_root):
202203
n1.modify(session='monitor-enabled')
203204
assert "The node resource does not support a" in str(ex.value)
204205

206+
@pytest.mark.skipif(
207+
LooseVersion(pytest.config.getoption('--release')) < LooseVersion('12.0.0'),
208+
reason='This test only works on version 12.0.0 or greater'
209+
)
210+
def test_create_fqdn_with_address(self, request, mgmt_root):
211+
def teardown():
212+
if mgmt_root.tm.ltm.nodes.node.exists(name='foo.example', partition='Common'):
213+
loaded_node = mgmt_root.tm.ltm.nodes.node.load(
214+
name='foo.example', partition='Common')
215+
loaded_node.delete()
216+
request.addfinalizer(teardown)
217+
params = {
218+
"name": "foo.example",
219+
"address": "any6",
220+
"fqdn": {
221+
"addressFamily": "ipv4",
222+
"autopopulate": "enabled",
223+
"downInterval": 5,
224+
"interval": 3600,
225+
"tmName": "foo.bar.com"
226+
},
227+
"ratio": 1,
228+
"session": "user-enabled",
229+
"state": "user-up"
230+
}
231+
232+
n1 = mgmt_root.tm.ltm.nodes.node.create(**params)
233+
n2 = mgmt_root.tm.ltm.nodes.node.load(name=n1.name, partition=n1.partition)
234+
assert n1.name == 'foo.example'
235+
assert n2.name == n1.name
236+
assert n1.generation == n2.generation
237+
205238

206239
class TestNodes(object):
207240
def test_get_collection(self, request, mgmt_root):
@@ -218,7 +251,7 @@ def test_stats(self, request, mgmt_root, opt_release):
218251
'~Common~node1/stats'
219252
assert stats_link in nodes_stats.entries
220253
node_nested_stats = nodes_stats.entries[stats_link]['nestedStats']
221-
assert node_nested_stats['selfLink'] == stats_link+'?ver='+opt_release
254+
assert node_nested_stats['selfLink'].startswith(stats_link)
222255
entries = node_nested_stats['entries']
223256
assert entries['tmName']['description'] == '/Common/node1'
224257
assert entries['status.enabledState']['description'] == 'enabled'

0 commit comments

Comments
 (0)