summaryrefslogtreecommitdiffstats
path: root/nova/notifier
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2012-01-23 11:51:14 +0000
committerMark McLoughlin <markmc@redhat.com>2012-01-28 12:37:16 +0000
commit82049af90e86380043c59741fa4e1cd2cf24aaa7 (patch)
treefd5a35b7a373de888ece003929f8c499b34ce83c /nova/notifier
parent02b872625b94c3c63674d8c64b23f80215b04a15 (diff)
Refactor away the flags.DEFINE_* helpers
The next obvious step in porting to cfg is to define all options using cfg schemas directly rather than using the flags.DEFINE_* helpers. This is a large change, but it is almost entirely pure refactoring and does not result in any functional changes. The only change to note is that the default values for glance_host, glance_api_servers and default_publisher_id options are now using opt value interpolation i.e. -glance_host=_get_my_ip() +glance_host='$my_ip' -glance_api_servers=['%s:%d' % (FLAGS.glance_host, FLAGS.glance_port)] +glance_api_servers=['$glance_host:$glance_port'] -default_publisher_id=FLAGS.host +default_publisher_id='$host' Also note that the lower_bound check on the {report,periodic}_interval options are no more, but this has been true since cfg was first added. Change-Id: Ia58c8f0aaf61628bb55b1b8485118a2a9852ed17
Diffstat (limited to 'nova/notifier')
-rw-r--r--nova/notifier/api.py18
-rw-r--r--nova/notifier/list_notifier.py10
-rw-r--r--nova/notifier/rabbit_notifier.py10
3 files changed, 26 insertions, 12 deletions
diff --git a/nova/notifier/api.py b/nova/notifier/api.py
index 043838536..50730cb0f 100644
--- a/nova/notifier/api.py
+++ b/nova/notifier/api.py
@@ -15,19 +15,25 @@
import uuid
+from nova.common import cfg
from nova import flags
from nova import utils
from nova import log as logging
-LOG = logging.getLogger('nova.exception')
-FLAGS = flags.FLAGS
+LOG = logging.getLogger('nova.exception')
-flags.DEFINE_string('default_notification_level', 'INFO',
- 'Default notification level for outgoing notifications')
-flags.DEFINE_string('default_publisher_id', FLAGS.host,
- 'Default publisher_id for outgoing notifications')
+notifier_opts = [
+ cfg.StrOpt('default_notification_level',
+ default='INFO',
+ help='Default notification level for outgoing notifications'),
+ cfg.StrOpt('default_publisher_id',
+ default='$host',
+ help='Default publisher_id for outgoing notifications'),
+ ]
+FLAGS = flags.FLAGS
+FLAGS.add_options(notifier_opts)
WARN = 'WARN'
INFO = 'INFO'
diff --git a/nova/notifier/list_notifier.py b/nova/notifier/list_notifier.py
index 62847c85f..29c6ba720 100644
--- a/nova/notifier/list_notifier.py
+++ b/nova/notifier/list_notifier.py
@@ -13,16 +13,20 @@
# License for the specific language governing permissions and limitations
# under the License.
+from nova.common import cfg
from nova import flags
from nova import log as logging
from nova import utils
from nova.exception import ClassNotFound
-flags.DEFINE_multistring('list_notifier_drivers',
- ['nova.notifier.no_op_notifier'],
- 'List of drivers to send notifications')
+
+list_notifier_drivers_opt = \
+ cfg.MultiStrOpt('list_notifier_drivers',
+ default=['nova.notifier.no_op_notifier'],
+ help='List of drivers to send notifications')
FLAGS = flags.FLAGS
+FLAGS.add_option(list_notifier_drivers_opt)
LOG = logging.getLogger('nova.notifier.list_notifier')
diff --git a/nova/notifier/rabbit_notifier.py b/nova/notifier/rabbit_notifier.py
index 64e03697a..c88f76cb0 100644
--- a/nova/notifier/rabbit_notifier.py
+++ b/nova/notifier/rabbit_notifier.py
@@ -16,14 +16,18 @@
import nova.context
+from nova.common import cfg
from nova import flags
from nova import rpc
-FLAGS = flags.FLAGS
+notification_topic_opt = \
+ cfg.StrOpt('notification_topic',
+ default='notifications',
+ help='RabbitMQ topic used for Nova notifications')
-flags.DEFINE_string('notification_topic', 'notifications',
- 'RabbitMQ topic used for Nova notifications')
+FLAGS = flags.FLAGS
+FLAGS.add_option(notification_topic_opt)
def notify(message):