Skip to content

Commit

Permalink
Merge pull request #1501 from caphrim007/bugfix.tolerate-name-of-any6
Browse files Browse the repository at this point in the history
Correct edge case in ltm node api for address + fqdn
  • Loading branch information
f5-rahm committed Aug 11, 2018
2 parents a97a2ef + 552bb01 commit bc10ca7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 2 additions & 0 deletions f5/bigip/tm/ltm/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def create(self, **kwargs):
has_any = [set(x).issubset(args) for x in required_one_of]
if len([x for x in has_any if x is True]) == 1:
return self._create(**kwargs)
elif 'address' in kwargs and kwargs['address'] == 'any6' and 'fqdn' in kwargs:
return self._create(**kwargs)

raise RequiredOneOf(required_one_of)

Expand Down
35 changes: 34 additions & 1 deletion f5/bigip/tm/ltm/test/functional/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import pytest

from distutils.version import LooseVersion
from f5.sdk_exception import NodeStateModifyUnsupported
from f5.sdk_exception import RequiredOneOf

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

@pytest.mark.skipif(
LooseVersion(pytest.config.getoption('--release')) < LooseVersion('12.0.0'),
reason='This test only works on version 12.0.0 or greater'
)
def test_create_fqdn_with_address(self, request, mgmt_root):
def teardown():
if mgmt_root.tm.ltm.nodes.node.exists(name='foo.example', partition='Common'):
loaded_node = mgmt_root.tm.ltm.nodes.node.load(
name='foo.example', partition='Common')
loaded_node.delete()
request.addfinalizer(teardown)
params = {
"name": "foo.example",
"address": "any6",
"fqdn": {
"addressFamily": "ipv4",
"autopopulate": "enabled",
"downInterval": 5,
"interval": 3600,
"tmName": "foo.bar.com"
},
"ratio": 1,
"session": "user-enabled",
"state": "user-up"
}

n1 = mgmt_root.tm.ltm.nodes.node.create(**params)
n2 = mgmt_root.tm.ltm.nodes.node.load(name=n1.name, partition=n1.partition)
assert n1.name == 'foo.example'
assert n2.name == n1.name
assert n1.generation == n2.generation


class TestNodes(object):
def test_get_collection(self, request, mgmt_root):
Expand All @@ -218,7 +251,7 @@ def test_stats(self, request, mgmt_root, opt_release):
'~Common~node1/stats'
assert stats_link in nodes_stats.entries
node_nested_stats = nodes_stats.entries[stats_link]['nestedStats']
assert node_nested_stats['selfLink'] == stats_link+'?ver='+opt_release
assert node_nested_stats['selfLink'].startswith(stats_link)
entries = node_nested_stats['entries']
assert entries['tmName']['description'] == '/Common/node1'
assert entries['status.enabledState']['description'] == 'enabled'

0 comments on commit bc10ca7

Please sign in to comment.