service: run common initialization stuff
Change-Id: I6f6f2e1f6885533b5d8ee8bf652f7f605c78bcdd Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
cc0fc91200
commit
856c4452bd
@ -26,9 +26,6 @@ import sys
|
|||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
from stevedore import dispatch
|
from stevedore import dispatch
|
||||||
|
|
||||||
from ceilometer.openstack.common import gettextutils
|
|
||||||
gettextutils.install('ceilometer')
|
|
||||||
|
|
||||||
from ceilometer import counter
|
from ceilometer import counter
|
||||||
from ceilometer import pipeline
|
from ceilometer import pipeline
|
||||||
from ceilometer import publisher
|
from ceilometer import publisher
|
||||||
@ -75,7 +72,7 @@ cfg.CONF.register_cli_opts([
|
|||||||
help='counter metadata'),
|
help='counter metadata'),
|
||||||
])
|
])
|
||||||
|
|
||||||
service.prepare_service(sys.argv)
|
service.prepare_service()
|
||||||
|
|
||||||
# Set up logging to use the console
|
# Set up logging to use the console
|
||||||
console = logging.StreamHandler(sys.stderr)
|
console = logging.StreamHandler(sys.stderr)
|
||||||
|
@ -20,7 +20,6 @@ import logging
|
|||||||
import os
|
import os
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
import pecan
|
import pecan
|
||||||
import sys
|
|
||||||
|
|
||||||
from ceilometer.api import acl
|
from ceilometer.api import acl
|
||||||
from ceilometer.api import config as api_config
|
from ceilometer.api import config as api_config
|
||||||
@ -29,7 +28,6 @@ from ceilometer.api import middleware
|
|||||||
from ceilometer import service
|
from ceilometer import service
|
||||||
from ceilometer.openstack.common import log
|
from ceilometer.openstack.common import log
|
||||||
from wsgiref import simple_server
|
from wsgiref import simple_server
|
||||||
from ceilometer.openstack.common import gettextutils
|
|
||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
@ -102,8 +100,7 @@ class VersionSelectorApplication(object):
|
|||||||
|
|
||||||
|
|
||||||
def start():
|
def start():
|
||||||
gettextutils.install('ceilometer')
|
service.prepare_service()
|
||||||
service.prepare_service(sys.argv)
|
|
||||||
|
|
||||||
# Build the WSGI app
|
# Build the WSGI app
|
||||||
root = VersionSelectorApplication()
|
root = VersionSelectorApplication()
|
||||||
|
@ -16,14 +16,11 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import eventlet
|
|
||||||
from keystoneclient.v2_0 import client as ksclient
|
from keystoneclient.v2_0 import client as ksclient
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
import sys
|
|
||||||
|
|
||||||
from ceilometer import agent
|
from ceilometer import agent
|
||||||
from ceilometer import extension_manager
|
from ceilometer import extension_manager
|
||||||
from ceilometer.openstack.common import gettextutils
|
|
||||||
from ceilometer.openstack.common import log
|
from ceilometer.openstack.common import log
|
||||||
from ceilometer.openstack.common import service as os_service
|
from ceilometer.openstack.common import service as os_service
|
||||||
from ceilometer.openstack.common.rpc import service as rpc_service
|
from ceilometer.openstack.common.rpc import service as rpc_service
|
||||||
@ -84,10 +81,7 @@ class AgentManager(agent.AgentManager):
|
|||||||
|
|
||||||
|
|
||||||
def agent_central():
|
def agent_central():
|
||||||
# TODO(jd) move into prepare_service gettextutils and eventlet?
|
service.prepare_service()
|
||||||
eventlet.monkey_patch()
|
|
||||||
gettextutils.install('ceilometer')
|
|
||||||
service.prepare_service(sys.argv)
|
|
||||||
os_service.launch(rpc_service.Service(cfg.CONF.host,
|
os_service.launch(rpc_service.Service(cfg.CONF.host,
|
||||||
'ceilometer.agent.central',
|
'ceilometer.agent.central',
|
||||||
AgentManager())).wait()
|
AgentManager())).wait()
|
||||||
|
@ -16,17 +16,14 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import eventlet
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
import msgpack
|
import msgpack
|
||||||
import socket
|
import socket
|
||||||
import sys
|
|
||||||
|
|
||||||
from ceilometer.publisher import meter as publisher_meter
|
from ceilometer.publisher import meter as publisher_meter
|
||||||
from ceilometer import extension_manager
|
from ceilometer import extension_manager
|
||||||
from ceilometer.service import prepare_service
|
from ceilometer.service import prepare_service
|
||||||
from ceilometer.openstack.common import context
|
from ceilometer.openstack.common import context
|
||||||
from ceilometer.openstack.common import gettextutils
|
|
||||||
from ceilometer.openstack.common import log
|
from ceilometer.openstack.common import log
|
||||||
from ceilometer.openstack.common import service as os_service
|
from ceilometer.openstack.common import service as os_service
|
||||||
from ceilometer.openstack.common.rpc import dispatcher as rpc_dispatcher
|
from ceilometer.openstack.common.rpc import dispatcher as rpc_dispatcher
|
||||||
@ -112,10 +109,7 @@ class UDPCollectorService(os_service.Service):
|
|||||||
|
|
||||||
|
|
||||||
def udp_collector():
|
def udp_collector():
|
||||||
# TODO(jd) move into prepare_service gettextutils and eventlet?
|
prepare_service()
|
||||||
eventlet.monkey_patch()
|
|
||||||
gettextutils.install('ceilometer')
|
|
||||||
prepare_service(sys.argv)
|
|
||||||
os_service.launch(UDPCollectorService()).wait()
|
os_service.launch(UDPCollectorService()).wait()
|
||||||
|
|
||||||
|
|
||||||
@ -234,9 +228,6 @@ class CollectorService(rpc_service.Service):
|
|||||||
|
|
||||||
|
|
||||||
def collector():
|
def collector():
|
||||||
# TODO(jd) move into prepare_service gettextutils and eventlet?
|
prepare_service()
|
||||||
eventlet.monkey_patch()
|
|
||||||
gettextutils.install('ceilometer')
|
|
||||||
prepare_service(sys.argv)
|
|
||||||
os_service.launch(CollectorService(cfg.CONF.host,
|
os_service.launch(CollectorService(cfg.CONF.host,
|
||||||
'ceilometer.collector')).wait()
|
'ceilometer.collector')).wait()
|
||||||
|
@ -16,15 +16,12 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import eventlet
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
import sys
|
|
||||||
|
|
||||||
from ceilometer import agent
|
from ceilometer import agent
|
||||||
from ceilometer.compute.virt import inspector as virt_inspector
|
from ceilometer.compute.virt import inspector as virt_inspector
|
||||||
from ceilometer import extension_manager
|
from ceilometer import extension_manager
|
||||||
from ceilometer import nova_client
|
from ceilometer import nova_client
|
||||||
from ceilometer.openstack.common import gettextutils
|
|
||||||
from ceilometer.openstack.common import log
|
from ceilometer.openstack.common import log
|
||||||
from ceilometer.openstack.common import service as os_service
|
from ceilometer.openstack.common import service as os_service
|
||||||
from ceilometer.openstack.common.rpc import service as rpc_service
|
from ceilometer.openstack.common.rpc import service as rpc_service
|
||||||
@ -90,10 +87,7 @@ class AgentManager(agent.AgentManager):
|
|||||||
|
|
||||||
|
|
||||||
def agent_compute():
|
def agent_compute():
|
||||||
# TODO(jd) move into prepare_service gettextutils and eventlet?
|
service.prepare_service()
|
||||||
eventlet.monkey_patch()
|
|
||||||
gettextutils.install('ceilometer')
|
|
||||||
service.prepare_service(sys.argv)
|
|
||||||
os_service.launch(rpc_service.Service(cfg.CONF.host,
|
os_service.launch(rpc_service.Service(cfg.CONF.host,
|
||||||
'ceilometer.agent.compute',
|
'ceilometer.agent.compute',
|
||||||
AgentManager())).wait()
|
AgentManager())).wait()
|
||||||
|
@ -78,7 +78,7 @@ class CeilometerMiddleware(object):
|
|||||||
"metadata_headers",
|
"metadata_headers",
|
||||||
"").split(",") if h.strip()]
|
"").split(",") if h.strip()]
|
||||||
|
|
||||||
service.prepare_service()
|
service.prepare_service([])
|
||||||
|
|
||||||
self.pipeline_manager = pipeline.setup_pipeline(
|
self.pipeline_manager = pipeline.setup_pipeline(
|
||||||
transformer.TransformerExtensionManager(
|
transformer.TransformerExtensionManager(
|
||||||
|
@ -17,11 +17,14 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import eventlet
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
|
import sys
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
from ceilometer.openstack.common import gettextutils
|
||||||
from ceilometer.openstack.common import log
|
from ceilometer.openstack.common import log
|
||||||
from ceilometer.openstack.common import rpc
|
from ceilometer.openstack.common import rpc
|
||||||
|
|
||||||
@ -72,7 +75,9 @@ def _sanitize_cmd_line(argv):
|
|||||||
return [a for a in argv if a in cli_opt_names]
|
return [a for a in argv if a in cli_opt_names]
|
||||||
|
|
||||||
|
|
||||||
def prepare_service(argv=[]):
|
def prepare_service(argv=None):
|
||||||
|
eventlet.monkey_patch()
|
||||||
|
gettextutils.install('ceilometer')
|
||||||
rpc.set_defaults(control_exchange='ceilometer')
|
rpc.set_defaults(control_exchange='ceilometer')
|
||||||
cfg.set_defaults(log.log_opts,
|
cfg.set_defaults(log.log_opts,
|
||||||
default_log_levels=['amqplib=WARN',
|
default_log_levels=['amqplib=WARN',
|
||||||
@ -82,5 +87,7 @@ def prepare_service(argv=[]):
|
|||||||
'stevedore=INFO',
|
'stevedore=INFO',
|
||||||
'eventlet.wsgi.server=WARN'
|
'eventlet.wsgi.server=WARN'
|
||||||
])
|
])
|
||||||
|
if argv is None:
|
||||||
|
argv = sys.argv
|
||||||
cfg.CONF(argv[1:], project='ceilometer')
|
cfg.CONF(argv[1:], project='ceilometer')
|
||||||
log.setup('ceilometer')
|
log.setup('ceilometer')
|
||||||
|
@ -23,9 +23,7 @@ import urlparse
|
|||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
from stevedore import driver
|
from stevedore import driver
|
||||||
import sys
|
|
||||||
|
|
||||||
from ceilometer.openstack.common import gettextutils
|
|
||||||
from ceilometer.openstack.common import log
|
from ceilometer.openstack.common import log
|
||||||
from ceilometer import utils
|
from ceilometer import utils
|
||||||
from ceilometer import service
|
from ceilometer import service
|
||||||
@ -124,6 +122,5 @@ class EventFilter(object):
|
|||||||
|
|
||||||
|
|
||||||
def dbsync():
|
def dbsync():
|
||||||
gettextutils.install('ceilometer')
|
service.prepare_service()
|
||||||
service.prepare_service(sys.argv)
|
|
||||||
get_connection(cfg.CONF).upgrade()
|
get_connection(cfg.CONF).upgrade()
|
||||||
|
@ -26,7 +26,6 @@ from oslo.config import cfg
|
|||||||
import pecan
|
import pecan
|
||||||
import pecan.testing
|
import pecan.testing
|
||||||
|
|
||||||
from ceilometer import service
|
|
||||||
from ceilometer.openstack.common import jsonutils
|
from ceilometer.openstack.common import jsonutils
|
||||||
from ceilometer.api import acl
|
from ceilometer.api import acl
|
||||||
from ceilometer.api.v1 import app as v1_app
|
from ceilometer.api.v1 import app as v1_app
|
||||||
@ -84,7 +83,6 @@ class FunctionalTest(db_test_base.TestBase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(FunctionalTest, self).setUp()
|
super(FunctionalTest, self).setUp()
|
||||||
service.prepare_service()
|
|
||||||
cfg.CONF.set_override("auth_version", "v2.0", group=acl.OPT_GROUP_NAME)
|
cfg.CONF.set_override("auth_version", "v2.0", group=acl.OPT_GROUP_NAME)
|
||||||
cfg.CONF.set_override("policy_file",
|
cfg.CONF.set_override("policy_file",
|
||||||
self.path_get('tests/policy.json'))
|
self.path_get('tests/policy.json'))
|
||||||
|
@ -35,7 +35,6 @@ class TestApp(base.TestCase):
|
|||||||
cfg.CONF.reset()
|
cfg.CONF.reset()
|
||||||
|
|
||||||
def test_keystone_middleware_conf(self):
|
def test_keystone_middleware_conf(self):
|
||||||
service.prepare_service()
|
|
||||||
cfg.CONF.set_override("auth_protocol", "foottp",
|
cfg.CONF.set_override("auth_protocol", "foottp",
|
||||||
group=acl.OPT_GROUP_NAME)
|
group=acl.OPT_GROUP_NAME)
|
||||||
cfg.CONF.set_override("auth_version", "v2.0", group=acl.OPT_GROUP_NAME)
|
cfg.CONF.set_override("auth_version", "v2.0", group=acl.OPT_GROUP_NAME)
|
||||||
|
@ -23,4 +23,4 @@ from ceilometer.tests import base
|
|||||||
|
|
||||||
class ServiceTestCase(base.TestCase):
|
class ServiceTestCase(base.TestCase):
|
||||||
def test_prepare_service(self):
|
def test_prepare_service(self):
|
||||||
service.prepare_service()
|
service.prepare_service([])
|
||||||
|
Loading…
Reference in New Issue
Block a user