Skip to content

Commit c569d1c

Browse files
Preyansh91caphrim007
authored andcommitted
method to get version details of a bigip (#1387)
* method to get version details of a bigip * style changes added * changes to functional test for version details * functional test changes * functional test changes * functional test changes
1 parent 7e40041 commit c569d1c

4 files changed

Lines changed: 117 additions & 1 deletion

File tree

f5/bigip/tm/sys/__init__.py

100644100755
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
from f5.bigip.tm.sys.sshd import Sshd
5454
from f5.bigip.tm.sys.syslog import Syslog
5555
from f5.bigip.tm.sys.ucs import Ucs
56+
from f5.bigip.tm.sys.version import Version
5657

5758

5859
class Sys(OrganizingCollection):
@@ -84,5 +85,6 @@ def __init__(self, tm):
8485
Software,
8586
Sshd,
8687
Syslog,
87-
Ucs
88+
Ucs,
89+
Version
8890
]
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright 2016 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+
def setup_version_test(request, mgmt_root):
18+
def teardown():
19+
v.selfLink = selflink
20+
request.addfinalizer(teardown)
21+
v = mgmt_root.tm.sys.version.load()
22+
selflink = v.selfLink
23+
return v, selflink
24+
25+
26+
class TestVersion(object):
27+
def test_entry(self, request, mgmt_root):
28+
# Load
29+
ver1, orig_link = setup_version_test(request, mgmt_root)
30+
ver2 = mgmt_root.tm.sys.version.load()
31+
assert len(ver1.selfLink) == len(ver2.selfLink)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright 2016 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+
import mock
17+
import pytest
18+
19+
20+
from f5.bigip.tm.sys.version import Version
21+
from f5.sdk_exception import UnsupportedMethod
22+
23+
24+
@pytest.fixture
25+
def FakeVersion():
26+
fake_sys = mock.MagicMock()
27+
return Version(fake_sys)
28+
29+
30+
def test_create_raises(FakeVersion):
31+
with pytest.raises(UnsupportedMethod) as EIO:
32+
FakeVersion.create()
33+
assert str(EIO.value) == "Version does not support the create method"
34+
35+
36+
def test_delete_raises(FakeVersion):
37+
with pytest.raises(UnsupportedMethod) as EIO:
38+
FakeVersion.delete()
39+
assert str(EIO.value) == "Version does not support the delete method"

f5/bigip/tm/sys/version.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# coding=utf-8
2+
#
3+
# Copyright 2016 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 dns module
19+
20+
REST URI
21+
``http://localhost/mgmt/tm/sys/dns``
22+
23+
GUI Path
24+
``System --> Configuration --> Device --> DNS``
25+
26+
REST Kind
27+
``tm:sys:dns:*``
28+
"""
29+
30+
from f5.bigip.resource import UnnamedResource
31+
32+
33+
class Version(UnnamedResource):
34+
"""BIG-IP® system Version unnamed resource
35+
36+
.. note::
37+
38+
This is an unnamed resource so it has not ~Partition~Name pattern
39+
at the end of its URI.
40+
"""
41+
def __init__(self, sys):
42+
super(Version, self).__init__(sys)
43+
self._meta_data['required_load_parameters'] = set()
44+
self._meta_data['required_json_kind'] = 'tm:sys:version:versionstats'

0 commit comments

Comments
 (0)