]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Migrate volume related quota info in db migration
authorJohn Griffith <john.griffith@solidfire.com>
Tue, 21 Aug 2012 20:00:18 +0000 (14:00 -0600)
committerJohn Griffith <john.griffith@solidfire.com>
Tue, 21 Aug 2012 20:05:15 +0000 (14:05 -0600)
  * Fixes bug 1039615
  * Now that quotas are back we need to handle migration
    of volume related quota data in the cinder-manage migrate helper
  * Only resource types transferred are volumes and gigabytes

Change-Id: Idd9aab834612e929683491f47fa1e1861bdbd0d1

bin/cinder-manage

index 566c2b63761a53702ad18dd59638cd9ce92f5c79..3b2978b8ec2201072502d8746e858cf0ee73faa6 100755 (executable)
@@ -279,6 +279,11 @@ class ImportCommands(object):
                       'volume_metadata',
                       'volume_type_extra_specs']
 
+        quota_table_list = ['quota_classes',
+                            'quota_usages',
+                            'quotas',
+                            'reservations']
+
         if backup_db > 0:
             if 'mysql:' not in dest_db:
                 print (_('Sorry, only mysql backups are supported!'))
@@ -301,6 +306,18 @@ class ImportCommands(object):
                 dest.add(new_row(**data))
             dest.commit()
 
+        for table_name in quota_table_list:
+            print (_('Importing table %s...' % table_name))
+            table = Table(table_name, src_meta, autoload=True)
+            new_row = self._map_table(table)
+            columns = table.columns.keys()
+            for row in src.query(table).all():
+                if row.resource == 'gigabytes' or row.resource == 'volumes':
+                    data = dict([(str(column), getattr(row, column))
+                        for column in columns])
+                    dest.add(new_row(**data))
+                dest.commit()
+
     @args('--src', dest='src_db', metavar='<Nova DB>',
           help='db-engine://db_user[:passwd]@db_host[:port]\t\t'
                'example: mysql://root:secrete@192.168.137.1')