Skip to content

Commit 55bb818

Browse files
author
Paul Breaux
committed
Cluster refactors to created trusted_peer_manager.
Issues: Fixes #400 Problem: Structure of clustering needs some refactoring and some testing Analysis: Moved the cluster modules into a cluster/ directory under f5. Also created some functional tests for these features. So we have something to hold onto. Tests: Three func tests exists now. The idea is that we can create, scale up, scale down, and teardown a cluster. We do this with a sync-failover and sync-only cluster type and then we create a cluster, only to delete the cluster_manager object, reinitialize with the same devices, then teardown that existing cluster.
1 parent 555fea5 commit 55bb818

20 files changed

Lines changed: 1159 additions & 402 deletions

f5/bigip/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from icontrol.session import iControlRESTSession
2121

2222
from f5.bigip.cm import Cm
23-
from f5.bigip.resource import OrganizingCollection
23+
from f5.bigip.resource import PathElement
2424
from f5.bigip.shared import Shared
2525
from f5.bigip.tm.auth import Auth as TmAuth
2626
from f5.bigip.tm.cm import Cm as TmCm
@@ -32,7 +32,7 @@
3232
from f5.bigip.tm.transaction import Transactions
3333

3434

35-
class ManagementRoot(OrganizingCollection):
35+
class ManagementRoot(PathElement):
3636
"""An interface to a single BIG-IP"""
3737
def __init__(self, hostname, username, password, **kwargs):
3838
timeout = kwargs.pop('timeout', 30)
@@ -53,6 +53,8 @@ def __init__(self, hostname, username, password, **kwargs):
5353
'local_ip': None,
5454
'bigip': self,
5555
'icontrol_version': icontrol_version,
56+
'username': username,
57+
'password': password
5658
}
5759

5860
@property

f5/bigip/cm/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# coding=utf-8
22
#
3-
"""Classes and functions for configuring BIG-IP"""
43
# Copyright 2016 F5 Networks Inc.
54
#
65
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,6 +14,7 @@
1514
# See the License for the specific language governing permissions and
1615
# limitations under the License.
1716
#
17+
"""Classes and functions for configuring BIG-IP"""
1818

1919
from f5.bigip.cm.autodeploy import Autodeploy
2020
from f5.bigip.resource import OrganizingCollection

f5/bigip/mixins.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,16 +274,16 @@ def _upload(self, filepathname, **kwargs):
274274

275275

276276
class DeviceMixin(object):
277-
'''Class to manage BigIP device cluster in a general way.'''
277+
'''Manage BigIP device cluster in a general way.'''
278278

279-
def _get_device_info(self, bigip):
279+
def get_device_info(self, bigip):
280280
'''Get device information about a specific BigIP device.
281281
282282
:param bigip: bigip object --- device to inspect
283283
:returns: bigip object
284284
'''
285285

286-
coll = bigip.cm.devices.get_collection()
286+
coll = bigip.tm.cm.devices.get_collection()
287287
device = [device for device in coll if device.selfDevice == 'true']
288288
assert len(device) == 1
289289
return device[0]

f5/bigip/tm/sys/application.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ def _create(self, **kwargs):
134134
self.load(**kwargs)
135135
if self.kind != self._meta_data['required_json_kind']:
136136
error_message = "For instances of type '%r' the corresponding"\
137-
" kind must be '%r' but creation returned JSON with kind: %r"\
138-
% (self.__class__.__name__,
139-
self._meta_data['required_json_kind'],
140-
self.kind)
137+
" kind must be '%r' but creation returned JSON with "\
138+
" kind: %r" % (self.__class__.__name__,
139+
self._meta_data['required_json_kind'],
140+
self.kind)
141141
raise KindTypeMismatch(error_message)
142142

143143
return self

f5/bigip/tm/sys/test/test_sys_application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def __init__(self, response_obj):
155155

156156
class MockHTTPErrorResponseSuccessful(HTTPError):
157157
def __init__(self):
158-
self.text = 'The configuration was updated successfully but could not' \
158+
self.text = 'The configuration was updated successfully but could not'\
159159
' be retrieved'
160160

161161

f5/common/pollster.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
#
1515
#
1616

17-
import functools
17+
from functools import wraps
1818
import time
1919

2020

2121
class MaximumAttemptsReached(Exception):
2222
pass
2323

2424

25-
def poll_by_method(method, attempts=30, interval=2):
25+
def poll_by_method(method, attempts=30, interval=5):
2626
'''Poll with a given method for a specified number of times.
2727
2828
:param method: callable to invoke in loop -- if no exception is raised
@@ -31,13 +31,14 @@ def poll_by_method(method, attempts=30, interval=2):
3131
:param interval: seconds to wait before next attempt
3232
'''
3333

34-
@functools.wraps(method)
34+
@wraps(method)
3535
def poll(*args, **kwargs):
3636
for attempt in range(attempts):
3737
try:
3838
return method(*args, **kwargs)
3939
except Exception:
40+
if attempt == attempts-1:
41+
raise
4042
time.sleep(interval)
4143
continue
42-
raise MaximumAttemptsReached('Polled method maximum number of times')
4344
return poll

f5/common/test.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

f5/managers/cluster_manager.py

Lines changed: 0 additions & 244 deletions
This file was deleted.

0 commit comments

Comments
 (0)