Example #1
0
    def create_volume(self, volume):
        """Creates a volume.

        :param volume: volume information
        """
        volume_size = volume.size
        volume_name = volume.name
        volume_description = (volume.display_description
                              if volume.display_description
                              else volume.display_name)

        pool = self._get_target_pool(volume)
        qos_specs = utils.get_backend_qos_specs(volume)
        limit_policy = self.client.get_io_limit_policy(qos_specs)

        LOG.info(_LI('Create Volume: %(volume)s  Size: %(size)s '
                     'Pool: %(pool)s Qos: %(qos)s.'),
                 {'volume': volume_name,
                  'size': volume_size,
                  'pool': pool.name,
                  'qos': qos_specs})

        lun = self.client.create_lun(
            volume_name, volume_size, pool, description=volume_description,
            io_limit_policy=limit_policy)
        location = self._build_provider_location(
            lun_type='lun',
            lun_id=lun.get_id())
        model_update = {'provider_location': location}
        return model_update
Example #2
0
 def test_get_backend_qos_mbps(self):
     volume = test_adapter.MockOSResource(volume_type_id='max_2_mbps')
     ret = utils.get_backend_qos_specs(volume)
     expected = {'maxBWS': 2, 'id': 'max_2_mbps', 'maxIOPS': None}
     self.assertEqual(expected, ret)
Example #3
0
 def test_get_backend_qos_both_none(self):
     volume = test_adapter.MockOSResource(volume_type_id='both_none')
     ret = utils.get_backend_qos_specs(volume)
     self.assertIsNone(ret)
Example #4
0
 def test_get_backend_qos_invalid_consumer(self):
     volume = test_adapter.MockOSResource(
         volume_type_id='invalid_backend_qos_consumer')
     ret = utils.get_backend_qos_specs(volume)
     self.assertIsNone(ret)
Example #5
0
 def test_get_backend_qos_iops(self):
     volume = mock.Mock(volume_type_id='max_1000_iops')
     ret = utils.get_backend_qos_specs(volume)
     expected = {'maxBWS': None, 'id': 'max_1000_iops', 'maxIOPS': 1000}
     self.assertEqual(expected, ret)
Example #6
0
 def test_get_backend_qos_both_none(self):
     volume = mock.Mock(volume_type_id='both_none')
     ret = utils.get_backend_qos_specs(volume)
     self.assertIsNone(ret)
Example #7
0
 def test_get_backend_qos_invalid_consumer(self):
     volume = mock.Mock(volume_type_id='invalid_backend_qos_consumer')
     ret = utils.get_backend_qos_specs(volume)
     self.assertIsNone(ret)
Example #8
0
 def io_limit_policy(self):
     if self._io_limit_policy is None:
         qos_specs = utils.get_backend_qos_specs(self._volume)
         self._io_limit_policy = self._adapter.client.get_io_limit_policy(
             qos_specs)
     return self._io_limit_policy