예제 #1
0
    def test_create_snapshot(self):
        self.stubs.Set(SolidFireDriver, "_issue_api_request", self.fake_issue_api_request)
        self.stubs.Set(SolidFireDriver, "_get_model_info", self.fake_get_model_info)
        testvol = {
            "project_id": "testprjid",
            "name": "testvol",
            "size": 1,
            "id": "a720b3c0-d1f0-11e1-9b23-0800200c9a66",
            "volume_type_id": None,
            "created_at": timeutils.utcnow(),
        }

        testsnap = {
            "project_id": "testprjid",
            "name": "testvol",
            "volume_size": 1,
            "id": "b831c4d1-d1f0-11e1-9b23-0800200c9a66",
            "volume_id": "a720b3c0-d1f0-11e1-9b23-0800200c9a66",
            "volume_type_id": None,
            "created_at": timeutils.utcnow(),
        }

        sfv = SolidFireDriver(configuration=self.configuration)
        model_update = sfv.create_volume(testvol)
        sfv.create_snapshot(testsnap)
예제 #2
0
    def test_verify_image_volume_ok(self,
                                    _mock_create_image_volume,
                                    _mock_get_sf_volume,
                                    _mock_get_sfaccount,
                                    _mock_issue_api_request):

        _mock_issue_api_request.return_value = self.mock_stats_data
        _mock_get_sfaccount.return_value = {'username': '******',
                                            'accountID': 7777}
        _mock_get_sf_volume.return_value =\
            {'status': 'active', 'volumeID': 1,
             'attributes': {
                 'image_info':
                     {'image_updated_at': '2013-09-28T15:27:36.325355',
                      'image_id': '17c550bb-a411-44c0-9aaf-0d96dd47f501',
                      'image_name': 'fake-image',
                      'image_created_at': '2014-12-17T00:16:23+00:00'}}}
        _mock_create_image_volume.return_value = None

        image_meta = {'id': '17c550bb-a411-44c0-9aaf-0d96dd47f501',
                      'updated_at': datetime.datetime(2013, 9, 28,
                                                      15, 27, 36,
                                                      325355)}
        image_service = 'null'

        sfv = SolidFireDriver(configuration=self.configuration)
        _mock_issue_api_request.return_value = {'result': 'ok'}

        sfv._verify_image_volume(self.ctxt, image_meta, image_service)
        self.assertFalse(_mock_create_image_volume.called)
예제 #3
0
    def test_create_volume_for_migration(self):
        def _fake_do_v_create(self, project_id, params):
            return project_id, params

        self.stubs.Set(SolidFireDriver, '_issue_api_request',
                       self.fake_issue_api_request)
        self.stubs.Set(SolidFireDriver, '_do_volume_create', _fake_do_v_create)

        testvol = {'project_id': 'testprjid',
                   'name': 'testvol',
                   'size': 1,
                   'id': 'b830b3c0-d1f0-11e1-9b23-1900200c9a77',
                   'volume_type_id': None,
                   'created_at': timeutils.utcnow(),
                   'migration_status': 'target:'
                                       'a720b3c0-d1f0-11e1-9b23-0800200c9a66'}

        sfv = SolidFireDriver(configuration=self.configuration)
        proj_id, sf_vol_object = sfv.create_volume(testvol)
        self.assertEqual('a720b3c0-d1f0-11e1-9b23-0800200c9a66',
                         sf_vol_object['attributes']['uuid'])
        self.assertEqual('b830b3c0-d1f0-11e1-9b23-1900200c9a77',
                         sf_vol_object['attributes']['migration_uuid'])
        self.assertEqual('UUID-a720b3c0-d1f0-11e1-9b23-0800200c9a66',
                         sf_vol_object['name'])
예제 #4
0
 def test_update_cluster_status(self):
     self.stubs.Set(SolidFireDriver, '_issue_api_request',
                    self.fake_issue_api_request)
     sfv = SolidFireDriver(configuration=self.configuration)
     sfv._update_cluster_status()
     self.assertEqual(sfv.cluster_stats['free_capacity_gb'], 99.0)
     self.assertEqual(sfv.cluster_stats['total_capacity_gb'], 100.0)
예제 #5
0
 def test_extend_volume(self):
     self.stubs.Set(SolidFireDriver, '_issue_api_request',
                    self.fake_issue_api_request)
     testvol = {'project_id': 'testprjid',
                'name': 'test_volume',
                'size': 1,
                'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66'}
     sfv = SolidFireDriver(configuration=self.configuration)
     sfv.extend_volume(testvol, 2)
예제 #6
0
 def test_set_by_qos_by_type_only(self):
     sfv = SolidFireDriver(configuration=self.configuration)
     type_ref = volume_types.create(self.ctxt,
                                    "type1", {"qos:minIOPS": "100",
                                              "qos:burstIOPS": "300",
                                              "qos:maxIOPS": "200"})
     qos = sfv._set_qos_by_volume_type(self.ctxt, type_ref['id'])
     self.assertEqual(qos, {'minIOPS': 100,
                            'maxIOPS': 200,
                            'burstIOPS': 300})
예제 #7
0
 def test_set_by_qos_by_type_only(self):
     sfv = SolidFireDriver(configuration=self.configuration)
     type_ref = volume_types.create(self.ctxt,
                                    "type1", {"qos:minIOPS": "100",
                                              "qos:burstIOPS": "300",
                                              "qos:maxIOPS": "200"})
     qos = sfv._set_qos_by_volume_type(self.ctxt, type_ref['id'])
     self.assertEqual(qos, {'minIOPS': 100,
                            'maxIOPS': 200,
                            'burstIOPS': 300})
예제 #8
0
    def test_clone_image_not_configured(self, _mock_issue_api_request):
        _mock_issue_api_request.return_value = self.mock_stats_data

        sfv = SolidFireDriver(configuration=self.configuration)
        self.assertEqual((None, False),
                         sfv.clone_image(self.ctxt,
                                         self.mock_volume,
                                         'fake',
                                         self.fake_image_meta,
                                         'fake'))
예제 #9
0
    def test_retype_with_qos_spec(self):
        test_type = {
            'name': 'sf-1',
            'qos_specs_id': 'fb0576d7-b4b5-4cad-85dc-ca92e6a497d1',
            'deleted': False,
            'created_at': '2014-02-06 04:58:11',
            'updated_at': None,
            'extra_specs': {},
            'deleted_at': None,
            'id': 'e730e97b-bc7d-4af3-934a-32e59b218e81'
        }

        test_qos_spec = {
            'id': 'asdfafdasdf',
            'specs': {
                'minIOPS': '1000',
                'maxIOPS': '2000',
                'burstIOPS': '3000'
            }
        }

        def _fake_get_volume_type(ctxt, type_id):
            return test_type

        def _fake_get_qos_spec(ctxt, spec_id):
            return test_qos_spec

        self.stubs.Set(SolidFireDriver, '_issue_api_request',
                       self.fake_issue_api_request)
        self.stubs.Set(volume_types, 'get_volume_type', _fake_get_volume_type)
        self.stubs.Set(qos_specs, 'get_qos_specs', _fake_get_qos_spec)

        sfv = SolidFireDriver(configuration=self.configuration)

        diff = {
            'encryption': {},
            'extra_specs': {},
            'qos_specs': {
                'burstIOPS': ('10000', '2000'),
                'minIOPS': ('1000', '500'),
                'maxIOPS': ('10000', '1000')
            }
        }
        host = None
        testvol = {
            'project_id': 'testprjid',
            'name': 'test_volume',
            'size': 1,
            'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
            'created_at': timeutils.utcnow()
        }

        sfv = SolidFireDriver(configuration=self.configuration)
        self.assertTrue(sfv.retype(self.ctxt, testvol, test_type, diff, host))
예제 #10
0
    def test_delete_volume(self):
        self.stubs.Set(SolidFireDriver, '_issue_api_request',
                       self.fake_issue_api_request)
        testvol = {'project_id': 'testprjid',
                   'name': 'test_volume',
                   'size': 1,
                   'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
                   'created_at': timeutils.utcnow()}

        sfv = SolidFireDriver(configuration=self.configuration)
        sfv.delete_volume(testvol)
예제 #11
0
    def test_extend_volume(self):
        self.stubs.Set(SolidFireDriver, '_issue_api_request',
                       self.fake_issue_api_request)
        testvol = {'project_id': 'testprjid',
                   'name': 'test_volume',
                   'size': 1,
                   'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
                   'created_at': timeutils.utcnow()}

        sfv = SolidFireDriver(configuration=self.configuration)
        sfv.extend_volume(testvol, 2)
예제 #12
0
 def test_create_volume(self):
     self.stubs.Set(SolidFireDriver, '_issue_api_request',
                    self.fake_issue_api_request)
     testvol = {'project_id': 'testprjid',
                'name': 'testvol',
                'size': 1,
                'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
                'volume_type_id': None}
     sfv = SolidFireDriver(configuration=self.configuration)
     model_update = sfv.create_volume(testvol)
     self.assertNotEqual(model_update, None)
     self.assertEqual(model_update.get('provider_geometry', None), None)
예제 #13
0
    def test_extend_volume(self):
        self.stubs.Set(SolidFireDriver, "_issue_api_request", self.fake_issue_api_request)
        testvol = {
            "project_id": "testprjid",
            "name": "test_volume",
            "size": 1,
            "id": "a720b3c0-d1f0-11e1-9b23-0800200c9a66",
            "created_at": timeutils.utcnow(),
        }

        sfv = SolidFireDriver(configuration=self.configuration)
        sfv.extend_volume(testvol, 2)
예제 #14
0
 def test_manage_existing_volume(self):
     external_ref = {'name': 'existing volume', 'source-id': 5}
     testvol = {'project_id': 'testprjid',
                'name': 'testvol',
                'size': 1,
                'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
                'created_at': timeutils.utcnow()}
     self.stubs.Set(SolidFireDriver, '_issue_api_request',
                    self.fake_issue_api_request)
     sfv = SolidFireDriver(configuration=self.configuration)
     model_update = sfv.manage_existing(testvol, external_ref)
     self.assertIsNotNone(model_update)
     self.assertIsNone(model_update.get('provider_geometry', None))
예제 #15
0
 def test_manage_existing_volume(self):
     external_ref = {'name': 'existing volume', 'source-id': 5}
     testvol = {'project_id': 'testprjid',
                'name': 'testvol',
                'size': 1,
                'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
                'created_at': timeutils.utcnow()}
     self.stubs.Set(SolidFireDriver, '_issue_api_request',
                    self.fake_issue_api_request)
     sfv = SolidFireDriver(configuration=self.configuration)
     model_update = sfv.manage_existing(testvol, external_ref)
     self.assertIsNotNone(model_update)
     self.assertIsNone(model_update.get('provider_geometry', None))
예제 #16
0
 def test_delete_volume_fails_no_volume(self):
     self.stubs.Set(SolidFireDriver, '_issue_api_request',
                    self.fake_issue_api_request)
     testvol = {'project_id': 'testprjid',
                'name': 'no-name',
                'size': 1,
                'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66'}
     sfv = SolidFireDriver(configuration=self.configuration)
     try:
         sfv.delete_volume(testvol)
         self.fail("Should have thrown Error")
     except Exception:
         pass
예제 #17
0
 def test_accept_transfer(self):
     sfv = SolidFireDriver(configuration=self.configuration)
     self.stubs.Set(SolidFireDriver, '_issue_api_request',
                    self.fake_issue_api_request)
     testvol = {'project_id': 'testprjid',
                'name': 'test_volume',
                'size': 1,
                'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
                'created_at': timeutils.utcnow()}
     expected = {'provider_auth': 'CHAP cinder-new_project 123456789012'}
     self.assertEqual(sfv.accept_transfer(self.ctxt,
                                          testvol,
                                          'new_user', 'new_project'),
                      expected)
예제 #18
0
 def test_accept_transfer(self):
     sfv = SolidFireDriver(configuration=self.configuration)
     self.stubs.Set(SolidFireDriver, '_issue_api_request',
                    self.fake_issue_api_request)
     testvol = {'project_id': 'testprjid',
                'name': 'test_volume',
                'size': 1,
                'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
                'created_at': timeutils.utcnow()}
     expected = {'provider_auth': 'CHAP cinder-new_project 123456789012'}
     self.assertEqual(sfv.accept_transfer(self.ctxt,
                                          testvol,
                                          'new_user', 'new_project'),
                      expected)
예제 #19
0
    def test_create_volume(self):
        self.stubs.Set(SolidFireDriver, '_issue_api_request',
                       self.fake_issue_api_request)
        testvol = {'project_id': 'testprjid',
                   'name': 'testvol',
                   'size': 1,
                   'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
                   'volume_type_id': None,
                   'created_at': timeutils.utcnow()}

        sfv = SolidFireDriver(configuration=self.configuration)
        model_update = sfv.create_volume(testvol)
        self.assertIsNotNone(model_update)
        self.assertIsNone(model_update.get('provider_geometry', None))
예제 #20
0
    def test_create_with_qos_type(self):
        self.stubs.Set(SolidFireDriver, '_issue_api_request',
                       self.fake_issue_api_request)
        self.stubs.Set(SolidFireDriver, '_set_qos_by_volume_type',
                       self.fake_set_qos_by_volume_type)
        testvol = {'project_id': 'testprjid',
                   'name': 'testvol',
                   'size': 1,
                   'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
                   'volume_type_id': 'fast'}

        sfv = SolidFireDriver(configuration=self.configuration)
        model_update = sfv.create_volume(testvol)
        self.assertNotEqual(model_update, None)
예제 #21
0
    def test_create_with_qos_type(self):
        self.stubs.Set(SolidFireDriver, '_issue_api_request',
                       self.fake_issue_api_request)
        self.stubs.Set(SolidFireDriver, '_set_qos_by_volume_type',
                       self.fake_set_qos_by_volume_type)
        testvol = {'project_id': 'testprjid',
                   'name': 'testvol',
                   'size': 1,
                   'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
                   'volume_type_id': 'fast',
                   'created_at': timeutils.utcnow()}

        sfv = SolidFireDriver(configuration=self.configuration)
        model_update = sfv.create_volume(testvol)
        self.assertNotEqual(model_update, None)
예제 #22
0
    def test_delete_volume_fails_no_volume(self):
        self.stubs.Set(SolidFireDriver, '_issue_api_request',
                       self.fake_issue_api_request)
        testvol = {'project_id': 'testprjid',
                   'name': 'no-name',
                   'size': 1,
                   'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
                   'created_at': timeutils.utcnow()}

        sfv = SolidFireDriver(configuration=self.configuration)
        try:
            sfv.delete_volume(testvol)
            self.fail("Should have thrown Error")
        except Exception:
            pass
예제 #23
0
    def test_create_volume(self):
        self.stubs.Set(SolidFireDriver, "_issue_api_request", self.fake_issue_api_request)
        testvol = {
            "project_id": "testprjid",
            "name": "testvol",
            "size": 1,
            "id": "a720b3c0-d1f0-11e1-9b23-0800200c9a66",
            "volume_type_id": None,
            "created_at": timeutils.utcnow(),
        }

        sfv = SolidFireDriver(configuration=self.configuration)
        model_update = sfv.create_volume(testvol)
        self.assertIsNotNone(model_update)
        self.assertIsNone(model_update.get("provider_geometry", None))
예제 #24
0
 def test_set_by_qos_spec(self):
     sfv = SolidFireDriver(configuration=self.configuration)
     qos_ref = qos_specs.create(self.ctxt,
                                'qos-specs-1', {'minIOPS': '1000',
                                                'maxIOPS': '10000',
                                                'burstIOPS': '20000'})
     type_ref = volume_types.create(self.ctxt,
                                    "type1", {"qos:minIOPS": "100",
                                              "qos:burstIOPS": "300",
                                              "qos:maxIOPS": "200"})
     qos_specs.associate_qos_with_type(self.ctxt,
                                       qos_ref['id'],
                                       type_ref['id'])
     qos = sfv._set_qos_by_volume_type(self.ctxt, type_ref['id'])
     self.assertEqual(qos, self.expected_qos_results)
예제 #25
0
    def test_create_volume_non_512(self):
        self.stubs.Set(SolidFireDriver, '_issue_api_request',
                       self.fake_issue_api_request)
        testvol = {'project_id': 'testprjid',
                   'name': 'testvol',
                   'size': 1,
                   'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
                   'volume_type_id': None,
                   'created_at': timeutils.utcnow()}

        self.configuration.sf_emulate_512 = False
        sfv = SolidFireDriver(configuration=self.configuration)
        model_update = sfv.create_volume(testvol)
        self.assertEqual(model_update.get('provider_geometry', None),
                         '4096 4096')
        self.configuration.sf_emulate_512 = True
예제 #26
0
    def test_delete_volume_fails_no_volume(self):
        self.stubs.Set(SolidFireDriver, "_issue_api_request", self.fake_issue_api_request)
        testvol = {
            "project_id": "testprjid",
            "name": "no-name",
            "size": 1,
            "id": "a720b3c0-d1f0-11e1-9b23-0800200c9a66",
            "created_at": timeutils.utcnow(),
        }

        sfv = SolidFireDriver(configuration=self.configuration)
        try:
            sfv.delete_volume(testvol)
            self.fail("Should have thrown Error")
        except Exception:
            pass
예제 #27
0
    def test_clone_image_virt_size_not_set(self, _mock_issue_api_request):
        _mock_issue_api_request.return_value = self.mock_stats_data
        self.configuration.sf_allow_template_caching = True
        sfv = SolidFireDriver(configuration=self.configuration)

        # Don't run clone_image if virtual_size property not on image
        _fake_image_meta = {
            'id': '17c550bb-a411-44c0-9aaf-0d96dd47f501',
            'updated_at': datetime.datetime(2013, 9, 28, 15, 27, 36, 325355),
            'is_public': True,
            'owner': 'testprjid'
        }

        self.assertEqual((None, False),
                         sfv.clone_image(self.ctxt, self.mock_volume, 'fake',
                                         _fake_image_meta, 'fake'))
예제 #28
0
    def test_retype_with_qos_spec(self):
        test_type = {'name': 'sf-1',
                     'qos_specs_id': 'fb0576d7-b4b5-4cad-85dc-ca92e6a497d1',
                     'deleted': False,
                     'created_at': '2014-02-06 04:58:11',
                     'updated_at': None,
                     'extra_specs': {},
                     'deleted_at': None,
                     'id': 'e730e97b-bc7d-4af3-934a-32e59b218e81'}

        test_qos_spec = {'id': 'asdfafdasdf',
                         'specs': {'minIOPS': '1000',
                                   'maxIOPS': '2000',
                                   'burstIOPS': '3000'}}

        qos_specs

        def _fake_get_volume_type(ctxt, type_id):
            return test_type

        def _fake_get_qos_spec(ctxt, spec_id):
            return test_qos_spec

        self.stubs.Set(SolidFireDriver, '_issue_api_request',
                       self.fake_issue_api_request)
        self.stubs.Set(volume_types, 'get_volume_type',
                       _fake_get_volume_type)
        self.stubs.Set(qos_specs, 'get_qos_specs',
                       _fake_get_qos_spec)

        sfv = SolidFireDriver(configuration=self.configuration)

        diff = {'encryption': {}, 'extra_specs': {},
                'qos_specs': {'burstIOPS': ('10000', '2000'),
                              'minIOPS': ('1000', '500'),
                              'maxIOPS': ('10000', '1000')}}
        host = None
        testvol = {'project_id': 'testprjid',
                   'name': 'test_volume',
                   'size': 1,
                   'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
                   'created_at': timeutils.utcnow()}

        sfv = SolidFireDriver(configuration=self.configuration)
        self.assertTrue(sfv.retype(self.ctxt,
                                   testvol,
                                   test_type, diff, host))
예제 #29
0
    def test_iscsi_helpers_not_in_base_iscsi_driver(self, mock_conf):
        # This test is added to check for bug: 1400804
        # The base iscsi driver should be clean from specifics
        # regarding tgtadm or LVM driver, this check is here
        # to make sure nothing regarding specific iscsi_helpers
        # sneak back in
        expected_iqn = 'iqn.2010-01.com.solidfire:'\
                       '87hg.uuid-2cc06226-cc74-4cb7-bd55-14aed659a0cc.4060'
        expected_properties = \
            {'driver_volume_type': 'iscsi',
             'data': {'target_discovered': False,
                      'encrypted': False,
                      'logical_block_size': '4096',
                      'physical_block_size': '4096',
                      'target_iqn': expected_iqn,
                      'target_portal': '10.10.7.1:3260',
                      'volume_id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
                      'target_lun': 0,
                      'auth_password': '******',
                      'auth_username':
                          '******',
                      'auth_method': 'CHAP'}}

        connector = {'initiator': 'iqn.2012-07.org.fake:01'}
        testvol = {'project_id': 'testprjid',
                   'name': 'testvol',
                   'size': 1,
                   'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
                   'volume_type_id': None,
                   'provider_location': '10.10.7.1:3260 iqn.2010-01.com.'
                                        'solidfire:87hg.uuid-2cc06226-cc'
                                        '74-4cb7-bd55-14aed659a0cc.4060 0',
                   'provider_auth': 'CHAP stack-1-a60e2611875f40199931f2'
                                    'c76370d66b 2FE0CQ8J196R',
                   'provider_geometry': '4096 4096',
                   'created_at': timeutils.utcnow(),
                   }

        mock_conf.iscsi_helper = 'lioadm'
        sfv = SolidFireDriver(configuration=self.configuration)
        self.assertEqual(sfv.initialize_connection(testvol, connector),
                         expected_properties)

        mock_conf.iscsi_helper = 'iseradm'
        sfv = SolidFireDriver(configuration=self.configuration)
        self.assertEqual(sfv.initialize_connection(testvol, connector),
                         expected_properties)

        mock_conf.iscsi_helper = 'tgtadm'
        sfv = SolidFireDriver(configuration=self.configuration)
        self.assertEqual(sfv.initialize_connection(testvol, connector),
                         expected_properties)
예제 #30
0
    def test_create_volume_with_qos(self):
        preset_qos = {}
        preset_qos['qos'] = 'fast'
        self.stubs.Set(SolidFireDriver, '_issue_api_request',
                       self.fake_issue_api_request)

        testvol = {'project_id': 'testprjid',
                   'name': 'testvol',
                   'size': 1,
                   'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
                   'metadata': [preset_qos],
                   'volume_type_id': None,
                   'created_at': timeutils.utcnow()}

        sfv = SolidFireDriver(configuration=self.configuration)
        model_update = sfv.create_volume(testvol)
        self.assertIsNotNone(model_update)
예제 #31
0
    def test_initialize_connector_with_blocksizes(self):
        expected_iqn = 'iqn.2010-01.com.solidfire:'\
                       '87hg.uuid-2cc06226-cc74-4cb7-bd55-14aed659a0cc.4060'
        expected_properties = \
            {'driver_volume_type': 'iscsi',
             'data': {'target_discovered': False,
                      'encrypted': False,
                      'logical_block_size': '4096',
                      'physical_block_size': '4096',
                      'target_iqn': expected_iqn,
                      'target_portal': '10.10.7.1:3260',
                      'volume_id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
                      'target_lun': 0,
                      'auth_password': '******',
                      'auth_username':
                          '******',
                      'auth_method': 'CHAP'}}

        connector = {'initiator': 'iqn.2012-07.org.fake:01'}
        testvol = {
            'project_id':
            'testprjid',
            'name':
            'testvol',
            'size':
            1,
            'id':
            'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
            'volume_type_id':
            None,
            'provider_location':
            '10.10.7.1:3260 iqn.2010-01.com.'
            'solidfire:87hg.uuid-2cc06226-cc'
            '74-4cb7-bd55-14aed659a0cc.4060 0',
            'provider_auth':
            'CHAP stack-1-a60e2611875f40199931f2'
            'c76370d66b 2FE0CQ8J196R',
            'provider_geometry':
            '4096 4096',
            'created_at':
            timeutils.utcnow(),
        }

        sfv = SolidFireDriver(configuration=self.configuration)
        self.assertEqual(sfv.initialize_connection(testvol, connector),
                         expected_properties)
예제 #32
0
 def test_create_volume_fails(self):
     # NOTE(JDG) This test just fakes update_cluster_status
     # this is inentional for this test
     self.stubs.Set(SolidFireDriver, '_update_cluster_status',
                    self.fake_update_cluster_status)
     self.stubs.Set(SolidFireDriver, '_issue_api_request',
                    self.fake_issue_api_request_fails)
     testvol = {'project_id': 'testprjid',
                'name': 'testvol',
                'size': 1,
                'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66'}
     sfv = SolidFireDriver(configuration=self.configuration)
     try:
         sfv.create_volume(testvol)
         self.fail("Should have thrown Error")
     except Exception:
         pass
예제 #33
0
 def test_create_volume_fails(self):
     # NOTE(JDG) This test just fakes update_cluster_status
     # this is inentional for this test
     self.stubs.Set(SolidFireDriver, '_update_cluster_status',
                    self.fake_update_cluster_status)
     self.stubs.Set(SolidFireDriver, '_issue_api_request',
                    self.fake_issue_api_request_fails)
     testvol = {'project_id': 'testprjid',
                'name': 'testvol',
                'size': 1,
                'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
                'created_at': timeutils.utcnow()}
     sfv = SolidFireDriver(configuration=self.configuration)
     try:
         sfv.create_volume(testvol)
         self.fail("Should have thrown Error")
     except Exception:
         pass
예제 #34
0
    def test_create_volume_with_qos(self):
        preset_qos = {}
        preset_qos["qos"] = "fast"
        self.stubs.Set(SolidFireDriver, "_issue_api_request", self.fake_issue_api_request)

        testvol = {
            "project_id": "testprjid",
            "name": "testvol",
            "size": 1,
            "id": "a720b3c0-d1f0-11e1-9b23-0800200c9a66",
            "metadata": [preset_qos],
            "volume_type_id": None,
            "created_at": timeutils.utcnow(),
        }

        sfv = SolidFireDriver(configuration=self.configuration)
        model_update = sfv.create_volume(testvol)
        self.assertIsNotNone(model_update)
예제 #35
0
 def test_create_volume_fails(self):
     # NOTE(JDG) This test just fakes update_cluster_status
     # this is inentional for this test
     self.stubs.Set(SolidFireDriver, "_update_cluster_status", self.fake_update_cluster_status)
     self.stubs.Set(SolidFireDriver, "_issue_api_request", self.fake_issue_api_request_fails)
     testvol = {
         "project_id": "testprjid",
         "name": "testvol",
         "size": 1,
         "id": "a720b3c0-d1f0-11e1-9b23-0800200c9a66",
         "created_at": timeutils.utcnow(),
     }
     sfv = SolidFireDriver(configuration=self.configuration)
     try:
         sfv.create_volume(testvol)
         self.fail("Should have thrown Error")
     except Exception:
         pass
예제 #36
0
    def test_verify_image_volume_out_of_date(self, _mock_create_image_volume,
                                             _mock_get_sf_volume,
                                             _mock_get_sfaccount,
                                             _mock_issue_api_request):
        fake_sf_vref = {
            'status': 'active',
            'volumeID': 1,
            'attributes': {
                'image_info': {
                    'image_updated_at': '2014-12-17T00:16:23+00:00',
                    'image_id': '17c550bb-a411-44c0-9aaf-0d96dd47f501',
                    'image_name': 'fake-image',
                    'image_created_at': '2014-12-17T00:16:23+00:00'
                }
            }
        }

        stats_data =\
            {'result':
                {'clusterCapacity': {'maxProvisionedSpace': 107374182400,
                                     'usedSpace': 1073741824,
                                     'compressionPercent': 100,
                                     'deDuplicationPercent': 100,
                                     'thinProvisioningPercent': 100}}}

        _mock_issue_api_request.return_value = stats_data
        _mock_get_sfaccount.return_value = {
            'username': '******',
            'accountID': 7777
        }
        _mock_get_sf_volume.return_value = fake_sf_vref
        _mock_create_image_volume.return_value = fake_sf_vref

        image_meta = {
            'id': '17c550bb-a411-44c0-9aaf-0d96dd47f501',
            'updated_at': datetime.datetime(2013, 9, 28, 15, 27, 36, 325355)
        }
        image_service = 'null'

        sfv = SolidFireDriver(configuration=self.configuration)
        _mock_issue_api_request.return_value = {'result': 'ok'}
        sfv._verify_image_volume(self.ctxt, image_meta, image_service)
        self.assertTrue(_mock_create_image_volume.called)
예제 #37
0
 def test_get_cluster_info_fail(self):
     # NOTE(JDG) This test just fakes update_cluster_status
     # this is inentional for this test
     self.stubs.Set(SolidFireDriver, '_update_cluster_status',
                    self.fake_update_cluster_status)
     self.stubs.Set(SolidFireDriver, '_issue_api_request',
                    self.fake_issue_api_request_fails)
     sfv = SolidFireDriver(configuration=self.configuration)
     self.assertRaises(exception.SolidFireAPIException,
                       sfv._get_cluster_info)
예제 #38
0
    def test_initialize_connector_with_blocksizes(self):
        connector = {'initiator': 'iqn.2012-07.org.fake:01'}
        testvol = {'project_id': 'testprjid',
                   'name': 'testvol',
                   'size': 1,
                   'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
                   'volume_type_id': None,
                   'provider_location': '10.10.7.1:3260 iqn.2010-01.com.'
                                        'solidfire:87hg.uuid-2cc06226-cc'
                                        '74-4cb7-bd55-14aed659a0cc.4060 0',
                   'provider_auth': 'CHAP stack-1-a60e2611875f40199931f2'
                                    'c76370d66b 2FE0CQ8J196R',
                   'provider_geometry': '4096 4096'
                   }

        sfv = SolidFireDriver(configuration=self.configuration)
        properties = sfv.initialize_connection(testvol, connector)
        self.assertEqual(properties['data']['physical_block_size'], '4096')
        self.assertEqual(properties['data']['logical_block_size'], '4096')
예제 #39
0
 def test_extend_volume_fails_no_volume(self):
     self.stubs.Set(SolidFireDriver, '_issue_api_request',
                    self.fake_issue_api_request)
     testvol = {'project_id': 'testprjid',
                'name': 'no-name',
                'size': 1,
                'id': 'not-found'}
     sfv = SolidFireDriver(configuration=self.configuration)
     self.assertRaises(exception.VolumeNotFound,
                       sfv.extend_volume,
                       testvol, 2)
예제 #40
0
    def test_initialize_connector_with_blocksizes(self):
        connector = {"initiator": "iqn.2012-07.org.fake:01"}
        testvol = {
            "project_id": "testprjid",
            "name": "testvol",
            "size": 1,
            "id": "a720b3c0-d1f0-11e1-9b23-0800200c9a66",
            "volume_type_id": None,
            "provider_location": "10.10.7.1:3260 iqn.2010-01.com."
            "solidfire:87hg.uuid-2cc06226-cc"
            "74-4cb7-bd55-14aed659a0cc.4060 0",
            "provider_auth": "CHAP stack-1-a60e2611875f40199931f2" "c76370d66b 2FE0CQ8J196R",
            "provider_geometry": "4096 4096",
            "created_at": timeutils.utcnow(),
        }

        sfv = SolidFireDriver(configuration=self.configuration)
        properties = sfv.initialize_connection(testvol, connector)
        self.assertEqual(properties["data"]["physical_block_size"], "4096")
        self.assertEqual(properties["data"]["logical_block_size"], "4096")
예제 #41
0
    def test_clone_image_virt_size_not_set(self, _mock_issue_api_request):
        _mock_issue_api_request.return_value = self.mock_stats_data
        self.configuration.sf_allow_template_caching = True
        sfv = SolidFireDriver(configuration=self.configuration)

        # Don't run clone_image if virtual_size property not on image
        _fake_image_meta = {'id': '17c550bb-a411-44c0-9aaf-0d96dd47f501',
                            'updated_at': datetime.datetime(2013, 9,
                                                            28, 15,
                                                            27, 36,
                                                            325355),
                            'is_public': True,
                            'owner': 'testprjid'}

        self.assertEqual((None, False),
                         sfv.clone_image(self.ctxt,
                                         self.mock_volume,
                                         'fake',
                                         _fake_image_meta,
                                         'fake'))
예제 #42
0
    def test_initialize_connector_with_blocksizes(self):
        connector = {'initiator': 'iqn.2012-07.org.fake:01'}
        testvol = {'project_id': 'testprjid',
                   'name': 'testvol',
                   'size': 1,
                   'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
                   'volume_type_id': None,
                   'provider_location': '10.10.7.1:3260 iqn.2010-01.com.'
                                        'solidfire:87hg.uuid-2cc06226-cc'
                                        '74-4cb7-bd55-14aed659a0cc.4060 0',
                   'provider_auth': 'CHAP stack-1-a60e2611875f40199931f2'
                                    'c76370d66b 2FE0CQ8J196R',
                   'provider_geometry': '4096 4096',
                   'created_at': timeutils.utcnow(),
                   }

        sfv = SolidFireDriver(configuration=self.configuration)
        properties = sfv.initialize_connection(testvol, connector)
        self.assertEqual(properties['data']['physical_block_size'], '4096')
        self.assertEqual(properties['data']['logical_block_size'], '4096')
예제 #43
0
    def test_create_clone(self):
        self.stubs.Set(SolidFireDriver, '_issue_api_request',
                       self.fake_issue_api_request)
        self.stubs.Set(SolidFireDriver, '_get_model_info',
                       self.fake_get_model_info)
        testvol = {'project_id': 'testprjid',
                   'name': 'testvol',
                   'size': 1,
                   'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
                   'volume_type_id': None,
                   'created_at': timeutils.utcnow()}

        testvol_b = {'project_id': 'testprjid',
                     'name': 'testvol',
                     'size': 1,
                     'id': 'b831c4d1-d1f0-11e1-9b23-0800200c9a66',
                     'volume_type_id': None,
                     'created_at': timeutils.utcnow()}

        sfv = SolidFireDriver(configuration=self.configuration)
        sfv.create_cloned_volume(testvol_b, testvol)
예제 #44
0
    def test_retype(self):
        sfv = SolidFireDriver(configuration=self.configuration)
        self.stubs.Set(SolidFireDriver, '_issue_api_request',
                       self.fake_issue_api_request)
        type_ref = volume_types.create(self.ctxt,
                                       "type1", {"qos:minIOPS": "500",
                                                 "qos:burstIOPS": "2000",
                                                 "qos:maxIOPS": "1000"})
        diff = {'encryption': {}, 'qos_specs': {},
                'extra_specs': {'qos:burstIOPS': ('10000', u'2000'),
                                'qos:minIOPS': ('1000', u'500'),
                                'qos:maxIOPS': ('10000', u'1000')}}
        host = None
        testvol = {'project_id': 'testprjid',
                   'name': 'test_volume',
                   'size': 1,
                   'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
                   'created_at': timeutils.utcnow()}

        self.assertTrue(sfv.retype(self.ctxt,
                                   testvol,
                                   type_ref, diff, host))
예제 #45
0
    def test_retype(self):
        sfv = SolidFireDriver(configuration=self.configuration)
        self.stubs.Set(SolidFireDriver, '_issue_api_request',
                       self.fake_issue_api_request)
        type_ref = volume_types.create(self.ctxt,
                                       "type1", {"qos:minIOPS": "500",
                                                 "qos:burstIOPS": "2000",
                                                 "qos:maxIOPS": "1000"})
        diff = {'encryption': {}, 'qos_specs': {},
                'extra_specs': {'qos:burstIOPS': ('10000', u'2000'),
                                'qos:minIOPS': ('1000', u'500'),
                                'qos:maxIOPS': ('10000', u'1000')}}
        host = None
        testvol = {'project_id': 'testprjid',
                   'name': 'test_volume',
                   'size': 1,
                   'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
                   'created_at': timeutils.utcnow()}

        self.assertTrue(sfv.retype(self.ctxt,
                                   testvol,
                                   type_ref, diff, host))
예제 #46
0
 def test_accept_transfer_volume_not_found_raises(self):
     sfv = SolidFireDriver(configuration=self.configuration)
     self.stubs.Set(SolidFireDriver, '_issue_api_request',
                    self.fake_issue_api_request)
     testvol = {
         'project_id': 'testprjid',
         'name': 'test_volume',
         'size': 1,
         'id': 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
         'created_at': timeutils.utcnow()
     }
     self.assertRaises(exception.VolumeNotFound, sfv.accept_transfer,
                       self.ctxt, testvol, 'new_user', 'new_project')
예제 #47
0
    def test_verify_image_volume_out_of_date(self,
                                             _mock_create_image_volume,
                                             _mock_get_sf_volume,
                                             _mock_get_sfaccount,
                                             _mock_issue_api_request):
        fake_sf_vref = {
            'status': 'active', 'volumeID': 1,
            'attributes': {
                'image_info':
                    {'image_updated_at': '2014-12-17T00:16:23+00:00',
                     'image_id': '17c550bb-a411-44c0-9aaf-0d96dd47f501',
                     'image_name': 'fake-image',
                     'image_created_at': '2014-12-17T00:16:23+00:00'}}}

        stats_data =\
            {'result':
                {'clusterCapacity': {'maxProvisionedSpace': 107374182400,
                                     'usedSpace': 1073741824,
                                     'compressionPercent': 100,
                                     'deDuplicationPercent': 100,
                                     'thinProvisioningPercent': 100}}}

        _mock_issue_api_request.return_value = stats_data
        _mock_get_sfaccount.return_value = {'username': '******',
                                            'accountID': 7777}
        _mock_get_sf_volume.return_value = fake_sf_vref
        _mock_create_image_volume.return_value = fake_sf_vref

        image_meta = {'id': '17c550bb-a411-44c0-9aaf-0d96dd47f501',
                      'updated_at': datetime.datetime(2013, 9, 28,
                                                      15, 27, 36,
                                                      325355)}
        image_service = 'null'

        sfv = SolidFireDriver(configuration=self.configuration)
        _mock_issue_api_request.return_value = {'result': 'ok'}
        sfv._verify_image_volume(self.ctxt, image_meta, image_service)
        self.assertTrue(_mock_create_image_volume.called)
예제 #48
0
    def test_clone_image_authorization(self, _mock_issue_api_request):
        _mock_issue_api_request.return_value = self.mock_stats_data
        self.configuration.sf_allow_template_caching = True
        sfv = SolidFireDriver(configuration=self.configuration)

        # Make sure if it's NOT public and we're NOT the owner it
        # doesn't try and cache
        _fake_image_meta = {'id': '17c550bb-a411-44c0-9aaf-0d96dd47f501',
                            'updated_at': datetime.datetime(2013, 9,
                                                            28, 15,
                                                            27, 36,
                                                            325355),
                            'properties': {'virtual_size': 1},
                            'is_public': False,
                            'owner': 'wrong-owner'}
        self.assertEqual((None, False),
                         sfv.clone_image(self.ctxt,
                                         self.mock_volume,
                                         'fake',
                                         _fake_image_meta,
                                         'fake'))

        # And is_public False, but the correct owner does work
        # expect raise AccountNotFound as that's the next call after
        # auth checks
        _fake_image_meta['owner'] = 'testprjid'
        self.assertRaises(exception.SolidFireAccountNotFound,
                          sfv.clone_image, self.ctxt,
                          self.mock_volume, 'fake',
                          _fake_image_meta, 'fake')

        # And is_public True, even if not the correct owner
        _fake_image_meta['is_public'] = True
        _fake_image_meta['owner'] = 'wrong-owner'
        self.assertRaises(exception.SolidFireAccountNotFound,
                          sfv.clone_image, self.ctxt,
                          self.mock_volume, 'fake',
                          _fake_image_meta, 'fake')
예제 #49
0
    def test_extend_volume_fails_account_lookup(self):
        # NOTE(JDG) This test just fakes update_cluster_status
        # this is intentional for this test
        self.stubs.Set(SolidFireDriver, '_update_cluster_status',
                       self.fake_update_cluster_status)
        self.stubs.Set(SolidFireDriver, '_issue_api_request',
                       self.fake_issue_api_request_fails)
        testvol = {'project_id': 'testprjid',
                   'name': 'no-name',
                   'size': 1,
                   'id': 'a720b3c0-d1f0-11e1-9b23-0800200c9a66',
                   'created_at': timeutils.utcnow()}

        sfv = SolidFireDriver(configuration=self.configuration)
        self.assertRaises(exception.SolidFireAccountNotFound,
                          sfv.extend_volume,
                          testvol, 2)
예제 #50
0
 def test_create_sfaccount_fails(self):
     sfv = SolidFireDriver(configuration=self.configuration)
     self.stubs.Set(SolidFireDriver, '_issue_api_request',
                    self.fake_issue_api_request_fails)
     account = sfv._create_sfaccount('project-id')
     self.assertIsNone(account)
예제 #51
0
 def test_get_sfaccount_by_name_fails(self):
     sfv = SolidFireDriver(configuration=self.configuration)
     self.stubs.Set(SolidFireDriver, '_issue_api_request',
                    self.fake_issue_api_request_fails)
     account = sfv._get_sfaccount_by_name('some-name')
     self.assertIsNone(account)
예제 #52
0
 def test_get_cluster_info(self):
     self.stubs.Set(SolidFireDriver, '_issue_api_request',
                    self.fake_issue_api_request)
     sfv = SolidFireDriver(configuration=self.configuration)
     sfv._get_cluster_info()