Skip to content

Commit 7500032

Browse files
authored
Merge pull request #1090 from wojtek0806/gtm_global_settings_part1
Fixes #1059
2 parents 3fab44f + b0e9085 commit 7500032

28 files changed

Lines changed: 349 additions & 27 deletions

f5/bigip/tm/gtm/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
from f5.bigip.resource import OrganizingCollection
3232
from f5.bigip.tm.gtm.datacenter import Datacenters
33+
from f5.bigip.tm.gtm.global_settings import Global_Settings
3334
from f5.bigip.tm.gtm.listener import Listeners
3435
from f5.bigip.tm.gtm.pool import Pools
3536
from f5.bigip.tm.gtm.region import Regions
@@ -45,6 +46,7 @@ def __init__(self, tm):
4546
super(Gtm, self).__init__(tm)
4647
self._meta_data['allowed_lazy_attributes'] = [
4748
Datacenters,
49+
Global_Settings,
4850
Listeners,
4951
Pools,
5052
Regions,

f5/bigip/tm/gtm/datacenter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# coding=utf-8
22
#
3-
# Copyright 2014-2015 F5 Networks Inc.
3+
# Copyright 2014-2017 F5 Networks Inc.
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.

f5/bigip/tm/gtm/global_settings.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# coding=utf-8
2+
#
3+
# Copyright 2015-2017 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® Global Traffic Manager™ (GTM®) global-settings submodule.
19+
20+
REST URI
21+
``http://localhost/mgmt/tm/gtm/global-settings``
22+
23+
GUI Path
24+
``DNS --> Settings --> GSLB``
25+
26+
REST Kind
27+
``tm:gtm:global-settings*``
28+
"""
29+
30+
from f5.bigip.resource import OrganizingCollection
31+
from f5.bigip.resource import UnnamedResource
32+
33+
34+
class Global_Settings(OrganizingCollection):
35+
"""BIG-IP® GTM global-settings organizing collection."""
36+
def __init__(self, gtm):
37+
super(Global_Settings, self).__init__(gtm)
38+
self._meta_data['allowed_lazy_attributes'] = [
39+
General,
40+
Load_Balancing,
41+
Metrics,
42+
]
43+
44+
45+
class General(UnnamedResource):
46+
"""BIG-IP® GTM global-settings general resource."""
47+
def __init__(self, global_settings):
48+
super(General, self).__init__(global_settings)
49+
self._meta_data['required_json_kind'] = \
50+
'tm:gtm:global-settings:general:generalstate'
51+
self._meta_data['required_load_parameters'] = set()
52+
53+
54+
class Load_Balancing(UnnamedResource):
55+
"""BIG-IP® GTM global-settings load balancing resource."""
56+
def __init__(self, global_settings):
57+
super(Load_Balancing, self).__init__(global_settings)
58+
self._meta_data['required_json_kind'] = \
59+
'tm:gtm:global-settings:load-balancing:load-balancingstate'
60+
self._meta_data['required_load_parameters'] = set()
61+
62+
63+
class Metrics(UnnamedResource):
64+
"""BIG-IP® GTM global-settings metrics resource."""
65+
def __init__(self, global_settings):
66+
super(Metrics, self).__init__(global_settings)
67+
self._meta_data['required_json_kind'] = \
68+
'tm:gtm:global-settings:metrics:metricsstate'
69+
self._meta_data['required_load_parameters'] = set()

f5/bigip/tm/gtm/listener.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# coding=utf-8
22
#
3-
# Copyright 2014-2016 F5 Networks Inc.
3+
# Copyright 2014-2017 F5 Networks Inc.
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.

f5/bigip/tm/gtm/pool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# coding=utf-8
22
#
3-
# Copyright 2014-2016 F5 Networks Inc.
3+
# Copyright 2014-2017 F5 Networks Inc.
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.

f5/bigip/tm/gtm/region.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# coding=utf-8
22
#
3-
# Copyright 2014-2016 F5 Networks Inc.
3+
# Copyright 2014-2017 F5 Networks Inc.
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.

f5/bigip/tm/gtm/rule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# coding=utf-8
22
#
3-
# Copyright 2014-2015 F5 Networks Inc.
3+
# Copyright 2014-2017 F5 Networks Inc.
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.

f5/bigip/tm/gtm/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# coding=utf-8
22
#
3-
# Copyright 2014-2016 F5 Networks Inc.
3+
# Copyright 2014-2017 F5 Networks Inc.
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.

f5/bigip/tm/gtm/test/functional/test_datacenter.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2015 F5 Networks Inc.
1+
# Copyright 2014-2017 F5 Networks Inc.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -12,7 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
#
15-
1615
import pytest
1716

1817
from f5.bigip.tm.gtm.datacenter import Datacenter
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# Copyright 2014-2017 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 copy
17+
import pytest
18+
19+
from six import iteritems
20+
21+
22+
@pytest.fixture(scope='function')
23+
def general(mgmt_root):
24+
s = mgmt_root.tm.gtm.global_settings.general.load()
25+
yield s
26+
s.modify(autoDiscovery='yes')
27+
28+
29+
@pytest.fixture(scope='function')
30+
def lb(mgmt_root):
31+
s = mgmt_root.tm.gtm.global_settings.load_balancing.load()
32+
yield s
33+
s.modify(ignorePathTtl='no')
34+
35+
36+
@pytest.fixture(scope='function')
37+
def metric(mgmt_root):
38+
s = mgmt_root.tm.gtm.global_settings.metrics.load()
39+
yield s
40+
s.modify(defaultProbeLimit=12)
41+
42+
43+
class TestMetrics(object):
44+
def test_refresh_update(self, mgmt_root, metric):
45+
r1 = metric
46+
r2 = mgmt_root.tm.gtm.global_settings.metrics.load()
47+
assert r1.kind == r2.kind
48+
assert r1.selfLink == r2.selfLink
49+
assert r1.defaultProbeLimit == r2.defaultProbeLimit
50+
r1.defaultProbeLimit = 24
51+
r1.update()
52+
assert r1.kind == r2.kind
53+
assert r1.selfLink == r2.selfLink
54+
assert r1.defaultProbeLimit != r2.defaultProbeLimit
55+
56+
r2.refresh()
57+
assert r1.defaultProbeLimit == r2.defaultProbeLimit
58+
assert r2.defaultProbeLimit == 24
59+
60+
def test_modify(self, metric):
61+
r1 = metric
62+
original_dict = copy.copy(r1.__dict__)
63+
itm = 'defaultProbeLimit'
64+
r1.modify(defaultProbeLimit=24)
65+
for k, v in iteritems(original_dict):
66+
if k != itm:
67+
original_dict[k] = r1.__dict__[k]
68+
elif k == itm:
69+
assert r1.__dict__[k] == 24
70+
71+
def test_load(self, mgmt_root, metric):
72+
r1 = metric
73+
uri = 'https://localhost/mgmt/tm/gtm/global-settings/metrics'
74+
assert r1.kind == \
75+
'tm:gtm:global-settings:metrics:metricsstate'
76+
assert r1.selfLink.startswith(uri)
77+
assert r1.defaultProbeLimit == 12
78+
r1.modify(defaultProbeLimit=24)
79+
assert r1.defaultProbeLimit == 24
80+
81+
r2 = mgmt_root.tm.gtm.global_settings.metrics.load()
82+
assert r1.kind == r2.kind
83+
assert r1.selfLink == r2.selfLink
84+
assert r1.defaultProbeLimit == r2.defaultProbeLimit
85+
86+
87+
class TestLoadBalancing(object):
88+
def test_refresh_update(self, mgmt_root, lb):
89+
r1 = lb
90+
r2 = mgmt_root.tm.gtm.global_settings.load_balancing.load()
91+
assert r1.kind == r2.kind
92+
assert r1.selfLink == r2.selfLink
93+
assert r1.ignorePathTtl == r2.ignorePathTtl
94+
r1.ignorePathTtl = 'yes'
95+
r1.update()
96+
assert r1.kind == r2.kind
97+
assert r1.selfLink == r2.selfLink
98+
assert r1.ignorePathTtl != r2.ignorePathTtl
99+
100+
r2.refresh()
101+
assert r1.ignorePathTtl == r2.ignorePathTtl
102+
assert r2.ignorePathTtl == 'yes'
103+
104+
def test_modify(self, lb):
105+
r1 = lb
106+
original_dict = copy.copy(r1.__dict__)
107+
itm = 'autoDiscovery'
108+
r1.modify(ignorePathTtl='yes')
109+
for k, v in iteritems(original_dict):
110+
if k != itm:
111+
original_dict[k] = r1.__dict__[k]
112+
elif k == itm:
113+
assert r1.__dict__[k] == 'yes'
114+
115+
def test_load(self, mgmt_root, lb):
116+
r1 = lb
117+
uri = 'https://localhost/mgmt/tm/gtm/global-settings/load-balancing'
118+
assert r1.kind == \
119+
'tm:gtm:global-settings:load-balancing:load-balancingstate'
120+
assert r1.selfLink.startswith(uri)
121+
assert r1.ignorePathTtl == 'no'
122+
r1.modify(ignorePathTtl='yes')
123+
assert r1.ignorePathTtl == 'yes'
124+
125+
r2 = mgmt_root.tm.gtm.global_settings.load_balancing.load()
126+
assert r1.kind == r2.kind
127+
assert r1.selfLink == r2.selfLink
128+
assert r1.ignorePathTtl == r2.ignorePathTtl
129+
130+
131+
class TestGeneral(object):
132+
def test_refresh_update(self, mgmt_root, general):
133+
r1 = general
134+
r2 = mgmt_root.tm.gtm.global_settings.general.load()
135+
assert r1.kind == r2.kind
136+
assert r1.selfLink == r2.selfLink
137+
assert r1.autoDiscovery == r2.autoDiscovery
138+
r1.autoDiscovery = 'no'
139+
r1.update()
140+
assert r1.kind == r2.kind
141+
assert r1.selfLink == r2.selfLink
142+
assert r1.autoDiscovery != r2.autoDiscovery
143+
144+
r2.refresh()
145+
assert r1.autoDiscovery == r2.autoDiscovery
146+
assert r2.autoDiscovery == 'no'
147+
148+
def test_modify(self, general):
149+
r1 = general
150+
original_dict = copy.copy(r1.__dict__)
151+
itm = 'autoDiscovery'
152+
r1.modify(autoDiscovery='no')
153+
for k, v in iteritems(original_dict):
154+
if k != itm:
155+
original_dict[k] = r1.__dict__[k]
156+
elif k == itm:
157+
assert r1.__dict__[k] == 'no'
158+
159+
def test_load(self, mgmt_root, general):
160+
r1 = general
161+
uri = 'https://localhost/mgmt/tm/gtm/global-settings/general'
162+
assert r1.kind == 'tm:gtm:global-settings:general:generalstate'
163+
assert r1.selfLink.startswith(uri)
164+
assert r1.autoDiscovery == 'yes'
165+
r1.modify(autoDiscovery='no')
166+
assert r1.autoDiscovery == 'no'
167+
168+
r2 = mgmt_root.tm.gtm.global_settings.general.load()
169+
assert r1.kind == r2.kind
170+
assert r1.selfLink == r2.selfLink
171+
assert r1.autoDiscovery == r2.autoDiscovery

0 commit comments

Comments
 (0)