statsd have some required configuration options

Closes-bug: #1481439
Change-Id: I7b37ccdf2988135504add1801c23e28e9123ccd0
This commit is contained in:
Mehdi Abaakouk 2015-11-23 12:13:49 +01:00 committed by Mehdi Abaakouk (sileht)
parent 49555547e3
commit b877365de6
2 changed files with 13 additions and 5 deletions

View File

@ -1,7 +1,5 @@
# -*- encoding: utf-8 -*-
#
# Copyright © 2014-2015 eNovance
#
# 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
@ -16,6 +14,7 @@
import itertools
from oslo_config import cfg
import uuid
import gnocchi.archive_policy
import gnocchi.indexer
@ -68,20 +67,24 @@ def list_opts():
cfg.PortOpt('port',
default=8125,
help='The port for statsd'),
cfg.StrOpt(
cfg.Opt(
'resource_id',
type=uuid.UUID,
help='Resource UUID to use to identify statsd in Gnocchi'),
cfg.StrOpt(
cfg.Opt(
'user_id',
type=uuid.UUID,
help='User UUID to use to identify statsd in Gnocchi'),
cfg.StrOpt(
cfg.Opt(
'project_id',
type=uuid.UUID,
help='Project UUID to use to identify statsd in Gnocchi'),
cfg.StrOpt(
'archive_policy_name',
help='Archive policy name to use when creating metrics'),
cfg.FloatOpt(
'flush_delay',
default=10,
help='Delay between flushes'),
)),
("archive_policy", gnocchi.archive_policy.OPTS),

View File

@ -19,6 +19,7 @@ try:
import asyncio
except ImportError:
import trollius as asyncio
from oslo_config import cfg
from oslo_log import log
import six
@ -159,6 +160,10 @@ class StatsdServer(object):
def start():
conf = service.prepare_service()
for field in ["resource_id", "user_id", "project_id"]:
if conf.statsd[field] is None:
raise cfg.RequiredOptError(field, cfg.OptGroup("statsd"))
stats = Stats(conf)
loop = asyncio.get_event_loop()