Skip to content

Commit e548b38

Browse files
authored
Merge pull request #1299 from caphrim007/bugfix.node-session-fixes
Fixes session errors
2 parents c6df0cd + e5581fa commit e548b38

2 files changed

Lines changed: 18 additions & 14 deletions

File tree

f5/bigip/tm/ltm/node.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,14 @@ def _check_node_parameters(self, **kwargs):
103103
def _modify(self, **patch):
104104
"""Override modify to check kwargs before request sent to device."""
105105
if 'state' in patch:
106-
if patch['state'] != 'user-up' and patch['state'] != 'user-down':
106+
if patch['state'] not in ['user-up', 'user-down', 'unchecked', 'fqdn-up']:
107107
msg = "The node resource does not support a modify with the " \
108108
"value of the 'state' attribute as %s. The accepted " \
109-
"values are 'user-up' or 'user-down'" % patch['state']
109+
"values are 'user-up', 'user-down', 'unchecked', or 'fqdn-up'" \
110+
% patch['state']
110111
raise NodeStateModifyUnsupported(msg)
111112
if 'session' in patch:
112-
if patch['session'] != 'user-enabled' and patch['state'] != \
113-
'user-disabled':
113+
if patch['session'] not in ['user-enabled', 'user-disabled']:
114114
msg = "The node resource does not support a modify with the " \
115115
"value of the 'session' attribute as %s. " \
116116
"The accepted values are 'user-enabled' or " \

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,17 @@ def test_update_session_state_kwargs(self, request, mgmt_root):
167167
n2.session = n1.session
168168
n2.state = n1.state
169169

170+
def test_update_session_without_state(self, request, mgmt_root):
171+
n1, nc1 = setup_node_test(
172+
request, mgmt_root, 'Common', 'node1', '192.168.100.2')
173+
assert n1.session == 'user-enabled'
174+
assert n1.state == 'unchecked'
175+
n1.update(session='user-disabled')
176+
n2 = mgmt_root.tm.ltm.nodes.node.load(name='node1', partition='Common')
177+
n2.session = 'user-disabled'
178+
n2.session = n1.session
179+
n2.state = n1.state
180+
170181
def test_state_modify(self, request, mgmt_root):
171182
n1, nc1 = setup_node_test(
172183
request, mgmt_root, 'Common', 'node1', '10.10.10.1')
@@ -182,21 +193,14 @@ def test_state_modify_error(self, request, mgmt_root):
182193
request, mgmt_root, 'Common', 'node1', '10.10.10.1')
183194
with pytest.raises(NodeStateModifyUnsupported) as ex:
184195
n1.modify(state='down')
185-
assert ex.value.message == "The node resource does not support a " \
186-
"modify with the value of the 'state' " \
187-
"attribute as down. The accepted values " \
188-
"are 'user-up' or 'user-down'"
196+
assert "The node resource does not support a" in str(ex.value)
189197

190198
def test_session_modify_error(self, request, mgmt_root):
191199
n1, nc1 = setup_node_test(
192200
request, mgmt_root, 'Common', 'node1', '10.10.10.1')
193201
with pytest.raises(NodeStateModifyUnsupported) as ex:
194-
n1.modify(state='monitor-enabled')
195-
assert ex.value.message == "The node resource does not support a " \
196-
"modify with the value of the 'state' " \
197-
"attribute as monitor-enabled. " \
198-
"The accepted values are " \
199-
"'user-up' or 'user-down'"
202+
n1.modify(session='monitor-enabled')
203+
assert "The node resource does not support a" in str(ex.value)
200204

201205

202206
class TestNodes(object):

0 commit comments

Comments
 (0)