Rename params to consts

Cause name 'params' may bring some troubles, rename it to 'consts'.

Change-Id: I882d6cba290c0936442e0e3a4f5872158e38de33
This commit is contained in:
lvdongbing 2015-12-30 03:51:48 -05:00
parent 1ad368ac31
commit 1d15ffbfa0
8 changed files with 34 additions and 34 deletions

View File

@ -14,7 +14,7 @@
import itertools
from bilean.api.openstack.v1 import util
from bilean.common import params
from bilean.common import consts
from bilean.common import serializers
from bilean.common import wsgi
from bilean.rpc import client as rpc_client
@ -75,7 +75,7 @@ class EventController(object):
def _init_event_statistics(self):
event_statistics = {}
for resource in params.RESOURCE_TYPES:
for resource in consts.RESOURCE_TYPES:
event_statistics[resource] = 0
return event_statistics

View File

@ -15,8 +15,8 @@ from webob import exc
from bilean.api.openstack.v1 import util
from bilean.api import validator
from bilean.common import consts
from bilean.common.i18n import _
from bilean.common import params
from bilean.common import serializers
from bilean.common import wsgi
from bilean.rpc import client as rpc_client
@ -29,17 +29,17 @@ class RuleData(object):
self.data = data
def name(self):
if params.RULE_NAME not in self.data:
if consts.RULE_NAME not in self.data:
raise exc.HTTPBadRequest(_("No rule name specified"))
return self.data[params.RULE_NAME]
return self.data[consts.RULE_NAME]
def spec(self):
if params.RULE_SPEC not in self.data:
if consts.RULE_SPEC not in self.data:
raise exc.HTTPBadRequest(_("No rule spec provided"))
return self.data[params.RULE_SPEC]
return self.data[consts.RULE_SPEC]
def metadata(self):
return self.data.get(params.RULE_METADATA, None)
return self.data.get(consts.RULE_METADATA, None)
class RuleController(object):

View File

@ -15,9 +15,9 @@
import six
from bilean.common import consts
from bilean.common import exception
from bilean.common.i18n import _
from bilean.common import params
from oslo_log import log as logging
from oslo_utils import uuidutils
@ -122,7 +122,7 @@ def validate_resource(resource):
raise exception.InvalidInput(message=msg)
if resource['resource_type']:
validate_string(resource['resource_type'],
available_fields=params.RESOURCE_TYPES)
available_fields=consts.RESOURCE_TYPES)
else:
msg = _('Expected resource_type field for resource')
raise exception.InvalidInput(reason=msg)

View File

@ -22,9 +22,9 @@ from oslo_log import log as logging
from sqlalchemy.orm.session import Session
from bilean.common import consts
from bilean.common import exception
from bilean.common.i18n import _
from bilean.common import params
from bilean.db.sqlalchemy import filters as db_filters
from bilean.db.sqlalchemy import migration
from bilean.db.sqlalchemy import models
@ -180,10 +180,10 @@ def user_get_all(context, show_deleted=False, limit=None,
filters = {}
sort_key_map = {
params.USER_CREATED_AT: models.User.created_at.key,
params.USER_UPDATED_AT: models.User.updated_at.key,
params.USER_BALANCE: models.User.balance.key,
params.USER_STATUS: models.User.status.key,
consts.USER_CREATED_AT: models.User.created_at.key,
consts.USER_UPDATED_AT: models.User.updated_at.key,
consts.USER_BALANCE: models.User.balance.key,
consts.USER_STATUS: models.User.status.key,
}
keys = _get_sort_keys(sort_keys, sort_key_map)
@ -215,10 +215,10 @@ def rule_get_all(context, show_deleted=False, limit=None,
filters = {}
sort_key_map = {
params.RULE_NAME: models.Rule.name.key,
params.RULE_TYPE: models.Rule.type.key,
params.RULE_CREATED_AT: models.Rule.created_at.key,
params.RULE_UPDATED_AT: models.Rule.updated_at.key,
consts.RULE_NAME: models.Rule.name.key,
consts.RULE_TYPE: models.Rule.type.key,
consts.RULE_CREATED_AT: models.Rule.created_at.key,
consts.RULE_UPDATED_AT: models.Rule.updated_at.key,
}
keys = _get_sort_keys(sort_keys, sort_key_map)
@ -292,10 +292,10 @@ def resource_get_all(context, user_id=None, show_deleted=False,
filters = {}
sort_key_map = {
params.RES_CREATED_AT: models.Resource.created_at.key,
params.RES_UPDATED_AT: models.Resource.updated_at.key,
params.RES_RESOURCE_TYPE: models.Resource.resource_type.key,
params.RES_USER_ID: models.Resource.user_id.key,
consts.RES_CREATED_AT: models.Resource.created_at.key,
consts.RES_UPDATED_AT: models.Resource.updated_at.key,
consts.RES_RESOURCE_TYPE: models.Resource.resource_type.key,
consts.RES_USER_ID: models.Resource.user_id.key,
}
keys = _get_sort_keys(sort_keys, sort_key_map)
query = db_filters.exact_filter(query, models.Resource, filters)
@ -377,10 +377,10 @@ def event_get_all(context, user_id=None, show_deleted=False,
filters = {}
sort_key_map = {
params.EVENT_ACTION: models.Event.action.key,
params.EVENT_RESOURCE_TYPE: models.Event.resource_type.key,
params.EVENT_TIMESTAMP: models.Event.timestamp.key,
params.EVENT_USER_ID: models.Event.user_id.key,
consts.EVENT_ACTION: models.Event.action.key,
consts.EVENT_RESOURCE_TYPE: models.Event.resource_type.key,
consts.EVENT_TIMESTAMP: models.Event.timestamp.key,
consts.EVENT_USER_ID: models.Event.user_id.key,
}
keys = _get_sort_keys(sort_keys, sort_key_map)
query = db_filters.exact_filter(query, models.Resource, filters)

View File

@ -15,9 +15,9 @@ from oslo_log import log as logging
import oslo_messaging
from oslo_service import service
from bilean.common import consts
from bilean.common.i18n import _
from bilean.common import messaging as bilean_messaging
from bilean.common import params
from bilean.notification import endpoint
LOG = logging.getLogger(__name__)
@ -36,12 +36,12 @@ class NotificationService(service.Service):
super(NotificationService, self).start()
self.transport = bilean_messaging.get_transport()
self.targets.append(
oslo_messaging.Target(topic=params.NOTIFICATION_TOPICS))
oslo_messaging.Target(topic=consts.NOTIFICATION_TOPICS))
listener = bilean_messaging.get_notification_listener(
self.transport, self.targets, self.endpoints)
LOG.info(_("Starting listener on topic: %s"),
params.NOTIFICATION_TOPICS)
consts.NOTIFICATION_TOPICS)
listener.start()
self.listeners.append(listener)

View File

@ -17,8 +17,8 @@
Client side of the bilean engine RPC API.
"""
from bilean.common import consts
from bilean.common import messaging
from bilean.common import params
from oslo_config import cfg
@ -30,7 +30,7 @@ class EngineClient(object):
def __init__(self):
self._client = messaging.get_rpc_client(
topic=params.ENGINE_TOPIC,
topic=consts.ENGINE_TOPIC,
server=cfg.CONF.host,
version=self.BASE_RPC_API_VERSION)

View File

@ -32,8 +32,8 @@ POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'bilean', '__init__.py')):
sys.path.insert(0, POSSIBLE_TOPDIR)
from bilean.common import consts
from bilean.common import messaging
from bilean.common import params
from oslo_config import cfg
from oslo_i18n import _lazy
@ -54,7 +54,7 @@ if __name__ == '__main__':
from bilean.engine import service as engine
srv = engine.EngineService(cfg.CONF.host, params.ENGINE_TOPIC)
srv = engine.EngineService(cfg.CONF.host, consts.ENGINE_TOPIC)
launcher = service.launch(cfg.CONF, srv,
workers=cfg.CONF.num_engine_workers)
launcher.wait()