Skip to content

Commit 58a5733

Browse files
authored
Merge pull request #1438 from nberezin/cluster_stats
Adding the support for cluster stats.
2 parents 161a5f6 + 649ca80 commit 58a5733

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

f5/bigip/tm/sys/cluster.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"""
2929

3030
from f5.bigip.resource import OrganizingCollection
31+
from f5.bigip.resource import Stats
3132
from f5.bigip.resource import UnnamedResource
3233

3334

@@ -37,7 +38,7 @@ def __init__(self, sys):
3738
super(Cluster, self).__init__(sys)
3839
self._meta_data['required_json_kind'] =\
3940
"tm:sys:cluster:clustercollectionstate"
40-
self._meta_data['allowed_lazy_attributes'] = [Default]
41+
self._meta_data['allowed_lazy_attributes'] = [Default, Stats]
4142

4243

4344
class Default(UnnamedResource):
@@ -46,3 +47,4 @@ def __init__(self, settings):
4647
super(Default, self).__init__(settings)
4748
self._meta_data['required_json_kind'] = \
4849
'tm:sys:cluster:clusterstate'
50+
self._meta_data['allowed_lazy_attributes'] = [Stats]

f5/bigip/tm/sys/test/functional/test_cluster.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,23 @@
1717

1818

1919
def test_cluster_load(request, mgmt_root):
20-
# Load will produce exception on non-cluster BIGIP.l
20+
# Load will produce exception on non-cluster BIGIP.
2121
# iControlUnexpectedHTTPError: 404 Unexpected Error: Not Found for uri:
2222
try:
2323
assert str(mgmt_root.tm.sys.cluster.default.load().kind) == 'tm:sys:cluster:clusterstate'
2424
except iControlUnexpectedHTTPError as err:
25-
assert('01020036:3: The requested cluster (default) was not found.' in err.message)
25+
assert('01020036:3: The requested cluster (default) was not found.' in str(err))
26+
27+
28+
def test_cluster_stats_load(request, mgmt_root):
29+
# Load will give the result even on non-cluster BIGIP. However, the payload will be almost empty
30+
assert str(mgmt_root.tm.sys.cluster.stats.load().kind) == 'tm:sys:cluster:clustercollectionstats'
31+
32+
33+
def test_cluster_default_stats_load(request, mgmt_root):
34+
# Load will produce exception on non-cluster BIGIP.
35+
# iControlUnexpectedHTTPError: 404 Unexpected Error: Not Found for uri:
36+
try:
37+
assert str(mgmt_root.tm.sys.cluster.default.stats.load().kind) == 'tm:sys:cluster:clusterstats'
38+
except iControlUnexpectedHTTPError as err:
39+
assert('01020036:3: The requested cluster (default) was not found.' in str(err))

0 commit comments

Comments
 (0)