summaryrefslogtreecommitdiff
path: root/nova/policy.py
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/policy.py
parent02b872625b94c3c63674d8c64b23f80215b04a15 (diff)
downloadnova-82049af90e86380043c59741fa4e1cd2cf24aaa7.tar.gz
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/policy.py')
-rw-r--r--nova/policy.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/nova/policy.py b/nova/policy.py
index 22551d6a40..ccf1f4624c 100644
--- a/nova/policy.py
+++ b/nova/policy.py
@@ -17,16 +17,24 @@
"""Policy Engine For Nova"""
+from nova.common import cfg
from nova.common import policy
from nova import exception
from nova import flags
from nova import utils
+
+policy_opts = [
+ cfg.StrOpt('policy_file',
+ default='policy.json',
+ help=_('JSON file representing policy')),
+ cfg.StrOpt('policy_default_rule',
+ default='default',
+ help=_('Rule checked when requested rule is not found')),
+ ]
+
FLAGS = flags.FLAGS
-flags.DEFINE_string('policy_file', 'policy.json',
- _('JSON file representing policy'))
-flags.DEFINE_string('policy_default_rule', 'default',
- _('Rule checked when requested rule is not found'))
+FLAGS.add_options(policy_opts)
_POLICY_PATH = None
_POLICY_CACHE = {}