diff --git a/etc/tendrl/ceph-integration.yaml.sample b/etc/tendrl/ceph-integration.yaml.sample new file mode 100644 index 000000000..a9671271d --- /dev/null +++ b/etc/tendrl/ceph-integration.yaml.sample @@ -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 diff --git a/etc/tendrl/tendrl.conf.sample b/etc/tendrl/tendrl.conf.sample deleted file mode 100644 index 861cc0511..000000000 --- a/etc/tendrl/tendrl.conf.sample +++ /dev/null @@ -1,23 +0,0 @@ -[common] - -# Central store etcd port -etcd_port = 2379 - -# Central store etcd host/ip -etcd_connection = 0.0.0.0 - -# Path to log file -log_cfg_path = /etc/tendrl/common_logging.yaml -log_level = DEBUG - - -[ceph-integration] -# Path to log file -log_cfg_path = /etc/tendrl/logging.yaml -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 diff --git a/tendrl/ceph_integration/manager/eventer.py b/tendrl/ceph_integration/manager/eventer.py index ee0deefc3..3e4ae6b83 100644 --- a/tendrl/ceph_integration/manager/eventer.py +++ b/tendrl/ceph_integration/manager/eventer.py @@ -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 @@ -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 @@ -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): diff --git a/tendrl/ceph_integration/manager/manager.py b/tendrl/ceph_integration/manager/manager.py index c27d2b044..08234d076 100644 --- a/tendrl/ceph_integration/manager/manager.py +++ b/tendrl/ceph_integration/manager/manager.py @@ -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__) @@ -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() diff --git a/tendrl/ceph_integration/manager/server_monitor.py b/tendrl/ceph_integration/manager/server_monitor.py index 62ec289a8..035bd3c84 100644 --- a/tendrl/ceph_integration/manager/server_monitor.py +++ b/tendrl/ceph_integration/manager/server_monitor.py @@ -21,7 +21,6 @@ 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 @@ -29,12 +28,16 @@ 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. diff --git a/tendrl/ceph_integration/persistence/persister.py b/tendrl/ceph_integration/persistence/persister.py index c03c2861c..1d5424429 100644 --- a/tendrl/ceph_integration/persistence/persister.py +++ b/tendrl/ceph_integration/persistence/persister.py @@ -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, diff --git a/tendrl/ceph_integration/tests/test_persister.py b/tendrl/ceph_integration/tests/test_persister.py index 7d84ffea5..a9630ee53 100644 --- a/tendrl/ceph_integration/tests/test_persister.py +++ b/tendrl/ceph_integration/tests/test_persister.py @@ -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):