Merge "Cleanup for resource-specific options"

This commit is contained in:
Jenkins 2017-01-27 21:50:36 +00:00 committed by Gerrit Code Review
commit 4eab1c1855
2 changed files with 15 additions and 9 deletions

View File

@ -14,20 +14,21 @@ from keystone.common import resource_options
USER_OPTIONS_REGISTRY = resource_options.ResourceOptionRegistry('USER')
USER_OPTIONS_LIST = [
# NOTE(notmorgan): This placeholder options can be removed once more
# options are populated. This forces iteration on possible options for
# complete test purposes in unit/functional/gate tests outside of the
# explicit test cases that test resource options. This option is never
# expected to be set.
resource_options.ResourceOption('_TST', '__PLACEHOLDER__'),
]
# NOTE(notmorgan): This placeholder options can be removed once more
# options are populated. This forces iteration on possible options for
# complete test purposes in unit/functional/gate tests outside of the
# explicit test cases that test resource options. This option is never
# expected to be set.
_placeholder_opt = resource_options.ResourceOption('_TST', '__PLACEHOLDER__')
# NOTE(notmorgan): wrap this in a function for testing purposes.
# This is called on import by design.
def register_user_options():
for opt in USER_OPTIONS_LIST:
for opt in [
_placeholder_opt,
]:
USER_OPTIONS_REGISTRY.register_option(opt)

View File

@ -191,6 +191,11 @@ class User(sql.ModelBase, sql.DictBase):
def enabled(cls):
return User._enabled
def get_resource_option(self, option_id):
if option_id in self._resource_option_mapper.keys():
return self._resource_option_mapper[option_id]
return None
def to_dict(self, include_extra_dict=False):
d = super(User, self).to_dict(include_extra_dict=include_extra_dict)
if 'default_project_id' in d and d['default_project_id'] is None: