diff options
author | wangxiyuan <wangxiyuan@huawei.com> | 2018-03-15 10:56:51 +0800 |
---|---|---|
committer | wangxiyuan <wangxiyuan@huawei.com> | 2018-05-08 10:59:41 +0800 |
commit | 9d7ffbc89e54bae1e9c3cdafec4c23edd77fc542 (patch) | |
tree | 0a8c8e234495405497b6740af95236168620d51e /keystone/limit | |
parent | 403917cef96655546c247c86adb26d10984cfb67 (diff) | |
download | keystone-9d7ffbc89e54bae1e9c3cdafec4c23edd77fc542.tar.gz |
Limit description support
This patch added description support for registered
limit and project limit.
Closes-Bug: #1754185
Change-Id: Ia2023ca809b8c2f58af648cb7377f41cd220725b
Diffstat (limited to 'keystone/limit')
-rw-r--r-- | keystone/limit/backends/sql.py | 11 | ||||
-rw-r--r-- | keystone/limit/schema.py | 15 |
2 files changed, 18 insertions, 8 deletions
diff --git a/keystone/limit/backends/sql.py b/keystone/limit/backends/sql.py index 5d3ef958b..eeaad2fd4 100644 --- a/keystone/limit/backends/sql.py +++ b/keystone/limit/backends/sql.py @@ -32,7 +32,8 @@ class RegisteredLimitModel(sql.ModelBase, sql.ModelDictMixin): 'service_id', 'region_id', 'resource_name', - 'default_limit' + 'default_limit', + 'description' ] id = sql.Column(sql.String(length=64), primary_key=True) @@ -42,6 +43,7 @@ class RegisteredLimitModel(sql.ModelBase, sql.ModelDictMixin): sql.ForeignKey('region.id'), nullable=True) resource_name = sql.Column(sql.String(255)) default_limit = sql.Column(sql.Integer, nullable=False) + description = sql.Column(sql.Text()) __table_args__ = ( sqlalchemy.UniqueConstraint('service_id', @@ -57,7 +59,8 @@ class LimitModel(sql.ModelBase, sql.ModelDictMixin): 'service_id', 'region_id', 'resource_name', - 'resource_limit' + 'resource_limit', + 'description' ] id = sql.Column(sql.String(length=64), primary_key=True) @@ -67,6 +70,7 @@ class LimitModel(sql.ModelBase, sql.ModelDictMixin): region_id = sql.Column(sql.String(64), nullable=True) resource_name = sql.Column(sql.String(255)) resource_limit = sql.Column(sql.Integer, nullable=False) + description = sql.Column(sql.Text()) __table_args__ = ( sqlalchemy.ForeignKeyConstraint(['service_id', @@ -227,9 +231,10 @@ class UnifiedLimit(base.UnifiedLimitDriverBase): for limit in limits: ref = self._get_limit(session, limit['id']) old_dict = ref.to_dict() - old_dict['resource_limit'] = limit['resource_limit'] + old_dict.update(limit) new_limit = LimitModel.from_dict(old_dict) ref.resource_limit = new_limit.resource_limit + ref.description = new_limit.description @driver_hints.truncated def list_limits(self, hints): diff --git a/keystone/limit/schema.py b/keystone/limit/schema.py index b76445865..95315529a 100644 --- a/keystone/limit/schema.py +++ b/keystone/limit/schema.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +from keystone.common import validation from keystone.common.validation import parameter_types _registered_limit_create_properties = { @@ -24,7 +25,8 @@ _registered_limit_create_properties = { }, 'default_limit': { 'type': 'integer' - } + }, + 'description': validation.nullable(parameter_types.description) } _registered_limit_create = { @@ -51,7 +53,8 @@ _registered_limit_update_properties = { }, 'default_limit': { 'type': 'integer' - } + }, + 'description': validation.nullable(parameter_types.description) } _registered_limit_update = { @@ -78,7 +81,8 @@ _limit_create_properties = { }, 'resource_limit': { 'type': 'integer' - } + }, + 'description': validation.nullable(parameter_types.description) } @@ -99,14 +103,15 @@ _limit_update_properties = { 'id': parameter_types.id_string, 'resource_limit': { 'type': 'integer' - } + }, + 'description': validation.nullable(parameter_types.description) } _limit_update = { 'type': 'object', 'properties': _limit_update_properties, 'additionalProperties': False, - 'required': ['id', 'resource_limit'] + 'required': ['id', ] } limit_update = { |