Skip to content

Commit bd2c79c

Browse files
nnDarshanroot
authored andcommitted
Fix pep8 and UT issues and config file structure
tendrl-bug-id: #62 Signed-off-by: nnDarshan <[email protected]>
1 parent 5baf7fc commit bd2c79c

File tree

7 files changed

+55
-39
lines changed

7 files changed

+55
-39
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
configuration:
2+
# Central store etcd port
3+
etcd_port: 2379
4+
# Central store etcd host/ip
5+
etcd_connection: 10.70.43.131
6+
# Path for tendrl-utility execution using ansible modules.
7+
# Tendrl uses ansible modules for some tasks like service-management,
8+
# package installation etc. Ansible provides executable scripts for this,
9+
# these scripts will be run from the path below.
10+
tendrl_exe_file_prefix: $HOME/.tendrl/util_runner_
11+
# The log path for ceph-integration
12+
log_cfg_path: /etc/tendrl/ceph-itegration_logging.yaml
13+
# The log level for ceph-integration
14+
log_level: DEBUG
15+
crush_host_type: host
16+
crush_osd_type: osd
17+
favorite_timeout_factor: 3
18+
server_timeout_factor: 3
19+
cluster_contact_threshold: 60
20+
cluster_map_retention: 3600

etc/tendrl/tendrl.conf.sample

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

tendrl/ceph_integration/manager/eventer.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from tendrl.ceph_integration.persistence.event import severity_str
1414
from tendrl.ceph_integration.persistence.event import WARNING
1515

16-
from tendrl.ceph_integration.config import TendrlConfig
1716
from tendrl.ceph_integration.gevent_util import nosleep
1817
from tendrl.ceph_integration.types import Health
1918
from tendrl.ceph_integration.types import MDS
@@ -23,9 +22,14 @@
2322
from tendrl.ceph_integration.types import OsdMap
2423
from tendrl.ceph_integration.types import ServiceId
2524
from tendrl.ceph_integration.util import now
25+
from tendrl.commons.config import load_config
2626

2727

28-
config = TendrlConfig()
28+
config = load_config(
29+
"ceph-integration",
30+
"/etc/tendrl/ceph-integration/ceph-integration.conf.yaml"
31+
)
32+
2933
LOG = logging.getLogger(__name__)
3034

3135
# The tick handler is very cheap (no I/O) so we call
@@ -39,10 +43,12 @@
3943

4044
# How long must a [server|cluster] be out of contact before
4145
# we generate an event?
42-
CONTACT_THRESHOLD_FACTOR = int(config.get(
43-
'ceph-integration', 'server_timeout_factor')) # multiple of contact period
44-
CLUSTER_CONTACT_THRESHOLD = int(config.get(
45-
'ceph-integration', 'cluster_contact_threshold')) # in seconds
46+
CONTACT_THRESHOLD_FACTOR = int(
47+
config['configuration']['server_timeout_factor']
48+
) # multiple of contact period
49+
CLUSTER_CONTACT_THRESHOLD = int(
50+
config['configuration']['cluster_contact_threshold']
51+
) # in seconds
4652

4753

4854
class Eventer(gevent.greenlet.Greenlet):

tendrl/ceph_integration/manager/manager.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,17 @@
1313
from tendrl.ceph_integration.persistence.tendrl_context import TendrlContext
1414
from tendrl.ceph_integration.persistence.tendrl_definitions import \
1515
TendrlDefinitions
16-
from tendrl.commons.config import TendrlConfig
16+
from tendrl.commons.config import load_config
1717
from tendrl.commons.log import setup_logging
1818
from tendrl.commons.manager.manager import Manager
1919
from tendrl.commons.manager.manager import SyncStateThread
2020

21-
config = TendrlConfig("ceph-integration", "/etc/tendrl/tendrl.conf")
21+
22+
config = load_config(
23+
"ceph-integration",
24+
"/etc/tendrl/ceph-integration/ceph-integration.conf.yaml"
25+
)
26+
2227

2328
LOG = logging.getLogger(__name__)
2429

@@ -147,8 +152,7 @@ def register_to_cluster(self, cluster_id):
147152

148153
def main():
149154
setup_logging(
150-
config.get('ceph-integration', 'log_cfg_path'),
151-
config.get('ceph-integration', 'log_level')
155+
config['configuration']['log_cfg_path']
152156
)
153157

154158
cluster_id = utils.get_tendrl_context()

tendrl/ceph_integration/manager/server_monitor.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,23 @@
2121
from gevent import greenlet
2222

2323
from tendrl.ceph_integration import ceph
24-
from tendrl.ceph_integration.config import TendrlConfig
2524
from tendrl.ceph_integration.gevent_util import nosleep
2625
from tendrl.ceph_integration.persistence.servers import Server
2726
from tendrl.ceph_integration.persistence.servers import Service
2827
from tendrl.ceph_integration.types import MonMap
2928
from tendrl.ceph_integration.types import OsdMap
3029
from tendrl.ceph_integration.types import ServiceId
3130
from tendrl.ceph_integration.util import now
31+
from tendrl.commons.config import load_config
3232

3333

34-
config = TendrlConfig()
34+
config = load_config(
35+
"ceph-integration",
36+
"/etc/tendrl/ceph-integration/ceph-integration.conf.yaml"
37+
)
3538

36-
CRUSH_HOST_TYPE = config.get('ceph-integration', 'crush_host_type')
37-
CRUSH_OSD_TYPE = config.get('ceph-integration', 'crush_osd_type')
39+
CRUSH_HOST_TYPE = config['configuration']['crush_host_type']
40+
CRUSH_OSD_TYPE = config['configuration']['crush_osd_type']
3841

3942
# Ignore changes in boot time below this threshold, to avoid mistaking clock
4043
# adjustments for reboots.

tendrl/ceph_integration/persistence/persister.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
from tendrl.ceph_integration.persistence.sync_objects import SyncObject
2+
from tendrl.commons.etcdobj.etcdobj import Server as etcd_server
23
from tendrl.commons.persistence.etcd_persister import EtcdPersister
34

45

56
class CephIntegrationEtcdPersister(EtcdPersister):
67
def __init__(self, config):
7-
super(CephIntegrationEtcdPersister, self).__init__(config)
8-
self._store = self.get_store()
8+
etcd_kwargs = {
9+
'port': int(config["configuration"]["etcd_port"]),
10+
'host': config["configuration"]["etcd_connection"]
11+
}
12+
self._store = etcd_server(etcd_kwargs=etcd_kwargs)
13+
super(CephIntegrationEtcdPersister, self).__init__(self._store.client)
914

1015
def update_sync_object(
1116
self,

tendrl/ceph_integration/tests/test_persister.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import sys
33
sys.modules['tendrl.commons.config'] = MagicMock()
44
from tendrl.ceph_integration.persistence import persister
5+
del sys.modules['tendrl.commons.config']
56

67

78
class Test_Persister(object):

0 commit comments

Comments
 (0)