Skip to content

Commit 0821f47

Browse files
f5-rahmcaphrim007
authored andcommitted
Issue #1357 - Adding license revoke endpoint (#1402)
- endpoint included - unit tests
1 parent a41480a commit 0821f47

3 files changed

Lines changed: 92 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
@@ -41,6 +41,7 @@
4141
from f5.bigip.tm.sys.global_settings import Global_Settings
4242
from f5.bigip.tm.sys.httpd import Httpd
4343
from f5.bigip.tm.sys.icall import Icall
44+
from f5.bigip.tm.sys.license import License
4445
from f5.bigip.tm.sys.log_config import Log_Config
4546
from f5.bigip.tm.sys.management_ip import Management_Ips
4647
from f5.bigip.tm.sys.management_route import Management_Routes
@@ -75,6 +76,7 @@ def __init__(self, tm):
7576
Global_Settings,
7677
Httpd,
7778
Icall,
79+
License,
7880
Log_Config,
7981
Management_Ips,
8082
Management_Routes,

f5/bigip/tm/sys/license.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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 license module
19+
20+
REST URI
21+
``http://localhost/mgmt/tm/sys/license``
22+
23+
GUI Path
24+
``System --> License``
25+
26+
REST Kind
27+
``tm:sys:license:*``
28+
"""
29+
30+
from distutils.version import LooseVersion
31+
32+
from f5.bigip.mixins import CommandExecutionMixin
33+
from f5.bigip.resource import UnnamedResource
34+
35+
from f5.sdk_exception import UnsupportedTmosVersion
36+
37+
38+
class License(UnnamedResource, CommandExecutionMixin):
39+
"""BIG-IP® license unnamed resource"""
40+
def __init__(self, sys):
41+
super(License, self).__init__(sys)
42+
self._meta_data['required_json_kind'] =\
43+
"tm:sys:license:licensestats"
44+
self._meta_data['allowed_commands'].append('revoke')
45+
46+
def exec_cmd(self, command, **kwargs):
47+
self._is_allowed_command(command)
48+
self._check_command_parameters(**kwargs)
49+
if LooseVersion(self._meta_data['bigip']._meta_data['tmos_version']) < LooseVersion('13.1.0'):
50+
raise UnsupportedTmosVersion('%s is not supported until version 13.1' % command)
51+
return self._exec_cmd(command, **kwargs)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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 License
21+
from f5.sdk_exception import UnsupportedMethod
22+
23+
24+
@pytest.fixture
25+
def FakeLicense():
26+
fake_sys = mock.MagicMock()
27+
return License(fake_sys)
28+
29+
30+
def test_create_raises(FakeLicense):
31+
with pytest.raises(UnsupportedMethod) as EIO:
32+
FakeLicense.create()
33+
assert str(EIO.value) == "License does not support the create method"
34+
35+
36+
def test_delete_raises(FakeLicense):
37+
with pytest.raises(UnsupportedMethod) as EIO:
38+
FakeLicense.delete()
39+
assert str(EIO.value) == "License does not support the delete method"

0 commit comments

Comments
 (0)