Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pep8 and UT issues #79

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions etc/tendrl/ceph-integration.yaml.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
configuration:
# Central store etcd port
etcd_port: 2379
# Central store etcd host/ip
etcd_connection: 10.70.43.131
# Path for tendrl-utility execution using ansible modules.
# Tendrl uses ansible modules for some tasks like service-management,
# package installation etc. Ansible provides executable scripts for this,
# these scripts will be run from the path below.
tendrl_exe_file_prefix: $HOME/.tendrl/util_runner_
# The log path for ceph-integration
log_cfg_path: /etc/tendrl/ceph-itegration_logging.yaml
# The log level for ceph-integration
log_level: DEBUG
crush_host_type: host
crush_osd_type: osd
favorite_timeout_factor: 3
server_timeout_factor: 3
cluster_contact_threshold: 60
cluster_map_retention: 3600
23 changes: 0 additions & 23 deletions etc/tendrl/tendrl.conf.sample

This file was deleted.

18 changes: 12 additions & 6 deletions tendrl/ceph_integration/manager/eventer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from tendrl.ceph_integration.persistence.event import severity_str
from tendrl.ceph_integration.persistence.event import WARNING

from tendrl.ceph_integration.config import TendrlConfig
from tendrl.ceph_integration.gevent_util import nosleep
from tendrl.ceph_integration.types import Health
from tendrl.ceph_integration.types import MDS
Expand All @@ -23,9 +22,14 @@
from tendrl.ceph_integration.types import OsdMap
from tendrl.ceph_integration.types import ServiceId
from tendrl.ceph_integration.util import now
from tendrl.commons.config import load_config


config = TendrlConfig()
config = load_config(
"ceph-integration",
"/etc/tendrl/ceph-integration/ceph-integration.yaml"
)

LOG = logging.getLogger(__name__)

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

# How long must a [server|cluster] be out of contact before
# we generate an event?
CONTACT_THRESHOLD_FACTOR = int(config.get(
'ceph-integration', 'server_timeout_factor')) # multiple of contact period
CLUSTER_CONTACT_THRESHOLD = int(config.get(
'ceph-integration', 'cluster_contact_threshold')) # in seconds
CONTACT_THRESHOLD_FACTOR = int(
config['configuration']['server_timeout_factor']
) # multiple of contact period
CLUSTER_CONTACT_THRESHOLD = int(
config['configuration']['cluster_contact_threshold']
) # in seconds


class Eventer(gevent.greenlet.Greenlet):
Expand Down
12 changes: 8 additions & 4 deletions tendrl/ceph_integration/manager/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@
from tendrl.ceph_integration.persistence.tendrl_context import TendrlContext
from tendrl.ceph_integration.persistence.tendrl_definitions import \
TendrlDefinitions
from tendrl.commons.config import TendrlConfig
from tendrl.commons.config import load_config
from tendrl.commons.log import setup_logging
from tendrl.commons.manager.manager import Manager
from tendrl.commons.manager.manager import SyncStateThread

config = TendrlConfig("ceph-integration", "/etc/tendrl/tendrl.conf")

config = load_config(
"ceph-integration",
"/etc/tendrl/ceph-integration/ceph-integration.yaml"
)


LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -147,8 +152,7 @@ def register_to_cluster(self, cluster_id):

def main():
setup_logging(
config.get('ceph-integration', 'log_cfg_path'),
config.get('ceph-integration', 'log_level')
config['configuration']['log_cfg_path']
)

cluster_id = utils.get_tendrl_context()
Expand Down
11 changes: 7 additions & 4 deletions tendrl/ceph_integration/manager/server_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,23 @@
from gevent import greenlet

from tendrl.ceph_integration import ceph
from tendrl.ceph_integration.config import TendrlConfig
from tendrl.ceph_integration.gevent_util import nosleep
from tendrl.ceph_integration.persistence.servers import Server
from tendrl.ceph_integration.persistence.servers import Service
from tendrl.ceph_integration.types import MonMap
from tendrl.ceph_integration.types import OsdMap
from tendrl.ceph_integration.types import ServiceId
from tendrl.ceph_integration.util import now
from tendrl.commons.config import load_config


config = TendrlConfig()
config = load_config(
"ceph-integration",
"/etc/tendrl/ceph-integration/ceph-integration.yaml"
)

CRUSH_HOST_TYPE = config.get('ceph-integration', 'crush_host_type')
CRUSH_OSD_TYPE = config.get('ceph-integration', 'crush_osd_type')
CRUSH_HOST_TYPE = config['configuration']['crush_host_type']
CRUSH_OSD_TYPE = config['configuration']['crush_osd_type']

# Ignore changes in boot time below this threshold, to avoid mistaking clock
# adjustments for reboots.
Expand Down
9 changes: 7 additions & 2 deletions tendrl/ceph_integration/persistence/persister.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
from tendrl.ceph_integration.persistence.sync_objects import SyncObject
from tendrl.commons.etcdobj.etcdobj import Server as etcd_server
from tendrl.commons.persistence.etcd_persister import EtcdPersister


class CephIntegrationEtcdPersister(EtcdPersister):
def __init__(self, config):
super(CephIntegrationEtcdPersister, self).__init__(config)
self._store = self.get_store()
etcd_kwargs = {
'port': int(config["configuration"]["etcd_port"]),
'host': config["configuration"]["etcd_connection"]
}
self._store = etcd_server(etcd_kwargs=etcd_kwargs)
super(CephIntegrationEtcdPersister, self).__init__(self._store.client)

def update_sync_object(
self,
Expand Down
1 change: 1 addition & 0 deletions tendrl/ceph_integration/tests/test_persister.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import sys
sys.modules['tendrl.commons.config'] = MagicMock()
from tendrl.ceph_integration.persistence import persister
del sys.modules['tendrl.commons.config']


class Test_Persister(object):
Expand Down