Merge "statsd have some required configuration options" into stable/1.3

This commit is contained in:
Jenkins 2016-02-14 22:22:14 +00:00 committed by Gerrit Code Review
commit fe2beaef3c
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
@ -67,20 +66,24 @@ def list_opts():
gnocchi.storage.swift.OPTS,
gnocchi.storage.influxdb.OPTS)),
("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
@ -166,6 +167,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()