]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Merge tag '2013.2_b1' into debian/havana
authorThomas Goirand <thomas@goirand.fr>
Sat, 29 Jun 2013 04:39:27 +0000 (12:39 +0800)
committerThomas Goirand <thomas@goirand.fr>
Sat, 29 Jun 2013 04:39:27 +0000 (12:39 +0800)
Cinder havana-1 milestone (2013.2.b1)

Conflicts:
cinder/openstack/common/setup.py
cinder/openstack/common/version.py
tools/flakes.py

1  2 
cinder/tests/test_netapp.py
cinder/tests/test_nfs.py
cinder/volume/drivers/san/hp/hp_3par_common.py
cinder/volume/manager.py

Simple merge
index ebeb0d1cdb1a2cd9868067c06a8888249cf95e0d,3f967c6f2eb5159300cec23a3569ee087d558644..3b42c1bb8bcdcb68870488fee82f03261ca4c70f
@@@ -730,31 -659,8 +659,33 @@@ class NfsDriverTestCase(test.TestCase)
  
          mox.ReplayAll()
  
-         drv.delete_volume(volume)
+         drv.get_volume_stats()
+         self.assertEqual(drv._stats['total_capacity_gb'], 30.0)
+         self.assertEqual(drv._stats['free_capacity_gb'], 5.0)
  
          mox.VerifyAll()
 +
 +    def test_get_volume_stats(self):
 +        """get_volume_stats must fill the correct values"""
 +        mox = self._mox
 +        drv = self._driver
 +
 +        drv._mounted_shares = [self.TEST_NFS_EXPORT1, self.TEST_NFS_EXPORT2]
 +
 +        mox.StubOutWithMock(drv, '_ensure_shares_mounted')
 +        mox.StubOutWithMock(drv, '_get_available_capacity')
 +
 +        drv._ensure_shares_mounted()
 +
 +        drv._get_available_capacity(self.TEST_NFS_EXPORT1).\
 +            AndReturn((2 * self.ONE_GB_IN_BYTES, 10 * self.ONE_GB_IN_BYTES))
 +        drv._get_available_capacity(self.TEST_NFS_EXPORT2).\
 +            AndReturn((3 * self.ONE_GB_IN_BYTES, 20 * self.ONE_GB_IN_BYTES))
 +
 +        mox.ReplayAll()
 +
 +        drv.get_volume_stats()
 +        self.assertEqual(drv._stats['total_capacity_gb'], 30.0)
 +        self.assertEqual(drv._stats['free_capacity_gb'], 5.0)
 +
 +        mox.VerifyAll()
index 10a18bbb0545ccb212fa46d1d03bb30a7a510d3a,9468904994c53e82f272d02192a4381bc07c33f0..a3fb8aafdd957ad814f244df9bab459852c63985
@@@ -415,17 -416,19 +416,51 @@@ exi
  
          return self.stats
  
+     def _update_volume_stats(self, client):
+         # const to convert MiB to GB
+         const = 0.0009765625
+         # storage_protocol and volume_backend_name are
+         # set in the child classes
+         stats = {'driver_version': '1.0',
+                  'free_capacity_gb': 'unknown',
+                  'reserved_percentage': 0,
+                  'storage_protocol': None,
+                  'total_capacity_gb': 'unknown',
+                  'vendor_name': 'Hewlett-Packard',
+                  'volume_backend_name': None}
++
++        try:
++            cpg = client.getCPG(self.config.hp3par_cpg)
++            if 'limitMiB' not in cpg['SDGrowth']:
++                total_capacity = 'infinite'
++                free_capacity = 'infinite'
++            else:
++                total_capacity = int(cpg['SDGrowth']['limitMiB'] * const)
++                free_capacity = int((cpg['SDGrowth']['limitMiB'] -
++                                    cpg['UsrUsage']['usedMiB']) * const)
++
++            stats['total_capacity_gb'] = total_capacity
++            stats['free_capacity_gb'] = free_capacity
++        except hpexceptions.HTTPNotFound:
++            err = (_("CPG (%s) doesn't exist on array")
++                   % self.config.hp3par_cpg)
++            LOG.error(err)
++            raise exception.InvalidInput(reason=err)
++
++        self.stats = stats
++
 +    def _update_volume_stats(self, client):
 +
 +        # storage_protocol and volume_backend_name are
 +        # set in the child classes
 +        stats = {'driver_version': '1.0',
 +                 'free_capacity_gb': 'unknown',
 +                 'reserved_percentage': 0,
 +                 'storage_protocol': None,
 +                 'total_capacity_gb': 'unknown',
 +                 'vendor_name': 'Hewlett-Packard',
 +                 'volume_backend_name': None}
  
          try:
              cpg = client.getCPG(self.config.hp3par_cpg)
index f2be2d64966552b4f137daac9ef5a5c62274d07d,5e1397ec29cb06f132ca7f80d75288826680f2b8..9a7513f3d2c84ef8e3cad3c49b3bf36331c64786
@@@ -487,12 -495,14 +495,19 @@@ class VolumeManager(manager.SchedulerDe
          context = context.elevated()
          snapshot_ref = self.db.snapshot_get(context, snapshot_id)
          LOG.info(_("snapshot %s: deleting"), snapshot_ref['name'])
+         self._notify_about_snapshot_usage(
+             context, snapshot_ref, "delete.start")
+         if context.project_id != snapshot_ref['project_id']:
+             project_id = snapshot_ref['project_id']
+         else:
+             project_id = context.project_id
  
 +        if context.project_id != snapshot_ref['project_id']:
 +            project_id = snapshot_ref['project_id']
 +        else:
 +            project_id = context.project_id
 +
          try:
              LOG.debug(_("snapshot %s: deleting"), snapshot_ref['name'])
              self.driver.delete_snapshot(snapshot_ref)