Separate the console scripts
Having all the console scripts in one file means that we always pull in all the dependencies. This presents a problem in downstream packaging, for example, a distro alarm subpackage required pymongo dependencies installed, even if not used. This patch separates the console scripts into a 'cmd' module, the way Nova does it. Eventlet monkey patching is done in the module's __init__.py file. Co-Authored-By: Mehdi Abaakouk <mehdi.abaakouk@enovance.com> Closes-bug: #1317210 Change-Id: I83020b13670928fd0d3046d2d2a493b11fe81d61
This commit is contained in:
parent
33d3a96822
commit
ab0c18e5d4
@ -30,97 +30,14 @@ import eventlet
|
||||
eventlet.monkey_patch(socket=True, select=True, thread=True)
|
||||
from oslo.config import cfg
|
||||
|
||||
from ceilometer.alarm import service as alarm_service
|
||||
from ceilometer.api import app
|
||||
from ceilometer.central import manager as central_manager
|
||||
from ceilometer import collector
|
||||
from ceilometer.compute import manager as compute_manager
|
||||
from ceilometer import notification
|
||||
from ceilometer.openstack.common import context
|
||||
from ceilometer.openstack.common import importutils
|
||||
from ceilometer.openstack.common import service as os_service
|
||||
from ceilometer.openstack.common import timeutils
|
||||
from ceilometer import pipeline
|
||||
from ceilometer import sample
|
||||
from ceilometer import service
|
||||
from ceilometer import storage
|
||||
from ceilometer import transformer
|
||||
|
||||
|
||||
OPTS = [
|
||||
cfg.StrOpt('evaluation_service',
|
||||
default='ceilometer.alarm.service.SingletonAlarmService',
|
||||
help='Class to launch as alarm evaluation service.'),
|
||||
]
|
||||
|
||||
cfg.CONF.register_opts(OPTS, group='alarm')
|
||||
cfg.CONF.import_opt('time_to_live', 'ceilometer.storage',
|
||||
group='database')
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def alarm_notifier():
|
||||
service.prepare_service()
|
||||
os_service.launch(alarm_service.AlarmNotifierService()).wait()
|
||||
|
||||
|
||||
def alarm_evaluator():
|
||||
service.prepare_service()
|
||||
eval_service = importutils.import_object(cfg.CONF.alarm.evaluation_service)
|
||||
os_service.launch(eval_service).wait()
|
||||
|
||||
|
||||
def agent_central():
|
||||
service.prepare_service()
|
||||
os_service.launch(central_manager.AgentManager()).wait()
|
||||
|
||||
|
||||
def agent_compute():
|
||||
service.prepare_service()
|
||||
os_service.launch(compute_manager.AgentManager()).wait()
|
||||
|
||||
|
||||
def agent_notification():
|
||||
service.prepare_service()
|
||||
launcher = os_service.ProcessLauncher()
|
||||
launcher.launch_service(
|
||||
notification.NotificationService(),
|
||||
workers=service.get_workers('notification'))
|
||||
launcher.wait()
|
||||
|
||||
|
||||
def api():
|
||||
service.prepare_service()
|
||||
srv = app.build_server()
|
||||
srv.serve_forever()
|
||||
|
||||
|
||||
def collector_service():
|
||||
service.prepare_service()
|
||||
launcher = os_service.ProcessLauncher()
|
||||
launcher.launch_service(
|
||||
collector.CollectorService(),
|
||||
workers=service.get_workers('collector'))
|
||||
launcher.wait()
|
||||
|
||||
|
||||
def storage_dbsync():
|
||||
service.prepare_service()
|
||||
storage.get_connection_from_config(cfg.CONF).upgrade()
|
||||
|
||||
|
||||
def storage_expirer():
|
||||
service.prepare_service()
|
||||
if cfg.CONF.database.time_to_live > 0:
|
||||
LOG.debug(_("Clearing expired metering data"))
|
||||
storage_conn = storage.get_connection_from_config(cfg.CONF)
|
||||
storage_conn.clear_expired_metering_data(
|
||||
cfg.CONF.database.time_to_live)
|
||||
else:
|
||||
LOG.info(_("Nothing to clean, database time to live is disabled"))
|
||||
|
||||
|
||||
def send_sample():
|
||||
cfg.CONF.register_cli_opts([
|
||||
cfg.StrOpt('sample-name',
|
||||
|
22
ceilometer/cmd/__init__.py
Normal file
22
ceilometer/cmd/__init__.py
Normal file
@ -0,0 +1,22 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import eventlet
|
||||
# NOTE(jd) We need to monkey patch the socket and select module for,
|
||||
# at least, oslo.messaging, otherwise everything's blocked on its
|
||||
# first read() or select(), thread need to be patched too, because
|
||||
# oslo.messaging use threading.local
|
||||
eventlet.monkey_patch(socket=True, select=True, thread=True)
|
24
ceilometer/cmd/agent_central.py
Normal file
24
ceilometer/cmd/agent_central.py
Normal file
@ -0,0 +1,24 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from ceilometer.central import manager
|
||||
from ceilometer.openstack.common import service as os_service
|
||||
from ceilometer import service
|
||||
|
||||
|
||||
def main():
|
||||
service.prepare_service()
|
||||
os_service.launch(manager.AgentManager()).wait()
|
24
ceilometer/cmd/agent_compute.py
Normal file
24
ceilometer/cmd/agent_compute.py
Normal file
@ -0,0 +1,24 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from ceilometer.compute import manager
|
||||
from ceilometer.openstack.common import service as os_service
|
||||
from ceilometer import service
|
||||
|
||||
|
||||
def main():
|
||||
service.prepare_service()
|
||||
os_service.launch(manager.AgentManager()).wait()
|
28
ceilometer/cmd/agent_notification.py
Normal file
28
ceilometer/cmd/agent_notification.py
Normal file
@ -0,0 +1,28 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from ceilometer import notification
|
||||
from ceilometer.openstack.common import service as os_service
|
||||
from ceilometer import service
|
||||
|
||||
|
||||
def main():
|
||||
service.prepare_service()
|
||||
launcher = os_service.ProcessLauncher()
|
||||
launcher.launch_service(
|
||||
notification.NotificationService(),
|
||||
workers=service.get_workers('notification'))
|
||||
launcher.wait()
|
42
ceilometer/cmd/alarm.py
Normal file
42
ceilometer/cmd/alarm.py
Normal file
@ -0,0 +1,42 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from ceilometer.alarm import service as alarm_service
|
||||
from ceilometer.openstack.common import importutils
|
||||
from ceilometer.openstack.common import service as os_service
|
||||
from ceilometer import service
|
||||
|
||||
|
||||
OPTS = [
|
||||
cfg.StrOpt('evaluation_service',
|
||||
default='ceilometer.alarm.service.SingletonAlarmService',
|
||||
help='Class to launch as alarm evaluation service.'),
|
||||
]
|
||||
|
||||
cfg.CONF.register_opts(OPTS, group='alarm')
|
||||
|
||||
|
||||
def notifier():
|
||||
service.prepare_service()
|
||||
os_service.launch(alarm_service.AlarmNotifierService()).wait()
|
||||
|
||||
|
||||
def evaluator():
|
||||
service.prepare_service()
|
||||
eval_service = importutils.import_object(cfg.CONF.alarm.evaluation_service)
|
||||
os_service.launch(eval_service).wait()
|
24
ceilometer/cmd/api.py
Normal file
24
ceilometer/cmd/api.py
Normal file
@ -0,0 +1,24 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from ceilometer.api import app
|
||||
from ceilometer import service
|
||||
|
||||
|
||||
def main():
|
||||
service.prepare_service()
|
||||
srv = app.build_server()
|
||||
srv.serve_forever()
|
28
ceilometer/cmd/collector.py
Normal file
28
ceilometer/cmd/collector.py
Normal file
@ -0,0 +1,28 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from ceilometer import collector
|
||||
from ceilometer.openstack.common import service as os_service
|
||||
from ceilometer import service
|
||||
|
||||
|
||||
def main():
|
||||
service.prepare_service()
|
||||
launcher = os_service.ProcessLauncher()
|
||||
launcher.launch_service(
|
||||
collector.CollectorService(),
|
||||
workers=service.get_workers('collector'))
|
||||
launcher.wait()
|
43
ceilometer/cmd/storage.py
Normal file
43
ceilometer/cmd/storage.py
Normal file
@ -0,0 +1,43 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2014 OpenStack Foundation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import logging
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from ceilometer import service
|
||||
from ceilometer import storage
|
||||
|
||||
cfg.CONF.import_opt('time_to_live', 'ceilometer.storage',
|
||||
group='database')
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def dbsync():
|
||||
service.prepare_service()
|
||||
storage.get_connection_from_config(cfg.CONF).upgrade()
|
||||
|
||||
|
||||
def expirer():
|
||||
service.prepare_service()
|
||||
if cfg.CONF.database.time_to_live > 0:
|
||||
LOG.debug(_("Clearing expired metering data"))
|
||||
storage_conn = storage.get_connection_from_config(cfg.CONF)
|
||||
storage_conn.clear_expired_metering_data(
|
||||
cfg.CONF.database.time_to_live)
|
||||
else:
|
||||
LOG.info(_("Nothing to clean, database time to live is disabled"))
|
18
setup.cfg
18
setup.cfg
@ -195,16 +195,16 @@ paste.filter_factory =
|
||||
swift = ceilometer.objectstore.swift_middleware:filter_factory
|
||||
|
||||
console_scripts =
|
||||
ceilometer-api = ceilometer.cli:api
|
||||
ceilometer-agent-central = ceilometer.cli:agent_central
|
||||
ceilometer-agent-compute = ceilometer.cli:agent_compute
|
||||
ceilometer-agent-notification = ceilometer.cli:agent_notification
|
||||
ceilometer-api = ceilometer.cmd.api:main
|
||||
ceilometer-agent-central = ceilometer.cmd.agent_central:main
|
||||
ceilometer-agent-compute = ceilometer.cmd.agent_compute:main
|
||||
ceilometer-agent-notification = ceilometer.cmd.agent_notification:main
|
||||
ceilometer-send-sample = ceilometer.cli:send_sample
|
||||
ceilometer-dbsync = ceilometer.cli:storage_dbsync
|
||||
ceilometer-expirer = ceilometer.cli:storage_expirer
|
||||
ceilometer-collector = ceilometer.cli:collector_service
|
||||
ceilometer-alarm-evaluator = ceilometer.cli:alarm_evaluator
|
||||
ceilometer-alarm-notifier = ceilometer.cli:alarm_notifier
|
||||
ceilometer-dbsync = ceilometer.cmd.storage:dbsync
|
||||
ceilometer-expirer = ceilometer.cmd.storage:expirer
|
||||
ceilometer-collector = ceilometer.cmd.collector:main
|
||||
ceilometer-alarm-evaluator = ceilometer.cmd.alarm:evaluator
|
||||
ceilometer-alarm-notifier = ceilometer.cmd.alarm:notifier
|
||||
|
||||
ceilometer.dispatcher =
|
||||
database = ceilometer.dispatcher.database:DatabaseDispatcher
|
||||
|
Loading…
x
Reference in New Issue
Block a user