Skip to content

Commit 0f8833a

Browse files
authored
Merge pull request #1466 from jasonrahm/issue.1461
Issue #1461 - Add sys/connection endpoint
2 parents 4b7056d + 9791824 commit 0f8833a

4 files changed

Lines changed: 116 additions & 0 deletions

File tree

f5/bigip/tm/sys/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from f5.bigip.tm.sys.clock import Clock
3333
from f5.bigip.tm.sys.cluster import Cluster
3434
from f5.bigip.tm.sys.config import Config
35+
from f5.bigip.tm.sys.connection import Connection
3536
from f5.bigip.tm.sys.crypto import Crypto
3637
from f5.bigip.tm.sys.daemon_log_settings import Daemon_Log_Settings
3738
from f5.bigip.tm.sys.db import Dbs
@@ -72,6 +73,7 @@ def __init__(self, tm):
7273
Clock,
7374
Cluster,
7475
Config,
76+
Connection,
7577
Crypto,
7678
Daemon_Log_Settings,
7779
Dbs,

f5/bigip/tm/sys/connection.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# coding=utf-8
2+
#
3+
# Copyright 2018 F5 Networks Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
"""BIG-IP® system connection module
19+
20+
REST URI
21+
``http://localhost/mgmt/tm/sys/connection``
22+
23+
REST Kind
24+
``tm:sys:connection:connectionstats:*``
25+
"""
26+
27+
from f5.bigip.resource import UnnamedResource
28+
from f5.sdk_exception import UnsupportedOperation
29+
30+
31+
class Connection(UnnamedResource):
32+
"""BIG-IP® system host info unnamed resource"""
33+
def __init__(self, sys):
34+
super(Connection, self).__init__(sys)
35+
self._meta_data['object_has_stats'] = False
36+
self._meta_data['required_load_parameters'] = set()
37+
self._meta_data['required_json_kind'] =\
38+
'tm:sys:connection:connectionstats'
39+
40+
def create(self, **kwargs):
41+
'''Create is not supported for connection resources.
42+
43+
:raises: UnsupportedOperation
44+
'''
45+
raise UnsupportedOperation(
46+
"Operation not allowed on connections."
47+
)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright 2018 F5 Networks Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
16+
from f5.bigip.tm.sys.connection import Connection
17+
18+
19+
class TestConnection(object):
20+
def test_load_refresh(self, mgmt_root):
21+
h1 = mgmt_root.tm.sys.connection.load()
22+
assert isinstance(h1, Connection)
23+
assert hasattr(h1, 'entries') or hasattr(h1, 'apiRawValues')
24+
assert h1.kind == 'tm:sys:connection:connectionstats'
25+
26+
h2 = mgmt_root.tm.sys.connection.load()
27+
28+
assert isinstance(h2, Connection)
29+
assert hasattr(h2, 'entries') or hasattr(h2, 'apiRawValues')
30+
assert h2.kind == 'tm:sys:connection:connectionstats'
31+
32+
h1.refresh()
33+
34+
assert h1.kind == h2.kind
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright 2018 F5 Networks Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
16+
17+
import mock
18+
import pytest
19+
20+
from f5.bigip.tm.sys import Connection
21+
from f5.sdk_exception import UnsupportedOperation
22+
23+
24+
@pytest.fixture
25+
def fake_info():
26+
fake_sys = mock.MagicMock()
27+
return Connection(fake_sys)
28+
29+
30+
def test_create_raises(fake_info):
31+
with pytest.raises(UnsupportedOperation) as EIO:
32+
fake_info.create()
33+
assert str(EIO.value) == "Operation not allowed on connections."

0 commit comments

Comments
 (0)