Coverage for manila/db/migrations/alembic/versions/0c23aec99b74_add_per_share_gigabytes_quota_class.py: 83%

18 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2026-02-18 22:19 +0000

1# Licensed under the Apache License, Version 2.0 (the "License"); you may 

2# not use this file except in compliance with the License. You may obtain 

3# a copy of the License at 

4# 

5# http://www.apache.org/licenses/LICENSE-2.0 

6# 

7# Unless required by applicable law or agreed to in writing, software 

8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 

9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 

10# License for the specific language governing permissions and limitations 

11# under the License. 

12 

13"""add_per_share_gigabytes_quota_class 

14 

15Revision ID: 0c23aec99b74 

16Revises: 5aa813ae673d 

17Create Date: 2021-01-03 10:01:57.276225 

18 

19""" 

20 

21# revision identifiers, used by Alembic. 

22revision = '0c23aec99b74' 

23down_revision = '5aa813ae673d' 

24 

25from alembic import op 

26from manila.db.migrations import utils 

27from oslo_log import log 

28from oslo_utils import timeutils 

29 

30LOG = log.getLogger(__name__) 

31 

32 

33def upgrade(): 

34 connection = op.get_bind() 

35 quota_classes_table = utils.load_table('quota_classes', connection) 

36 

37 try: 

38 op.bulk_insert 

39 (quota_classes_table, 

40 [{'created_at': timeutils.utcnow(), 

41 'class_name': 'default', 

42 'resource': 'per_share_gigabytes', 

43 'hard_limit': -1, 

44 'deleted': False, }]) 

45 except Exception: 

46 LOG.error("Default per_share_gigabytes row not inserted " 

47 "into the quota_classes.") 

48 raise 

49 

50 

51def downgrade(): 

52 """Don't delete the 'default' entries at downgrade time. 

53 

54 We don't know if the user had default entries when we started. 

55 If they did, we wouldn't want to remove them. So, the safest 

56 thing to do is just leave the 'default' entries at downgrade time. 

57 """ 

58 pass