def test_create_share_from_snapshot(self, share_proto): share = fake_share.fake_share(share_proto=share_proto) share_instance = fake_share.fake_share_instance(share, host="H@B#P") mock_cd = self.mock_object(self.driver, '_create_directory', mock.Mock(return_value='/fake/path')) mock_cns = self.mock_object(self.driver, '_create_nfs_share') mock_ccs = self.mock_object(self.driver, '_create_cifs_share') mock_sdq = self.mock_object(self.driver, '_set_directory_quota') mock_cdtd = self.mock_object(self.driver, '_clone_directory_to_dest') self.driver.ips = ['127.0.0.1'] locations = self.driver.create_share_from_snapshot( self._ctxt, share_instance, None) if share_proto == 'nfs': expect_locations = [{'path': r'127.0.0.1:/fake/path'}] self.assertEqual(locations, expect_locations) else: expect_locations = [{'path': r'\\127.0.0.1\share_fakeinstanceid'}] self.assertEqual(locations, expect_locations) mock_cd.assert_called_once_with(share_name='share_fakeinstanceid', pool_name='P') if share_proto == 'nfs': mock_cns.assert_called_once_with(share_path='/fake/path') elif share['share_proto'] is 'cifs': mock_ccs.assert_called_once_with(share_path='/fake/path', share_name='share_fakeinstanceid') mock_sdq.assert_called_once_with('/fake/path', share['size']) mock_cdtd.assert_called_once_with(snapshot=None, dest_path='/fake/path')
def test__generate_share_name(self): share = fake_share.fake_share() share_instance = fake_share.fake_share_instance(share, host="H@B#P") result = self.driver._generate_share_name(share_instance) self.assertEqual('share_fakeinstanceid', result)
def test__generate_share_name(self): share = fake_share.fake_share() share_instance = fake_share.fake_share_instance(share, host="H@B#P") result = self.driver._generate_share_name(share_instance) self.assertEqual('share_fakeinstanceid', result)
def setUp(self): super(HitachiHSPTestCase, self).setUp() CONF.set_default('driver_handles_share_servers', False) CONF.hitachi_hsp_host = '172.24.47.190' CONF.hitachi_hsp_username = '******' CONF.hitachi_hsp_password = '******' CONF.hitachi_hsp_job_timeout = 300 self.fake_el = [{ "path": CONF.hitachi_hsp_host + ":/fakeinstanceid", "metadata": {}, "is_admin_only": False, }] self.fake_share = fake_share.fake_share(share_proto='nfs') self.fake_share_instance = fake_share.fake_share_instance( base_share=self.fake_share, export_locations=self.fake_el) self.fake_conf = manila.share.configuration.Configuration(None) self.fake_private_storage = mock.Mock() self.mock_object(rest.HSPRestBackend, "get_cluster", mock.Mock(return_value=fakes.hsp_cluster)) self._driver = driver.HitachiHSPDriver( configuration=self.fake_conf, private_storage=self.fake_private_storage) self._driver.backend_name = "HSP" self.mock_log = self.mock_object(driver, 'LOG')
def test__get_share_instance_pnsp(self, share_proto): share = fake_share.fake_share(share_proto=share_proto) share_instance = fake_share.fake_share_instance(share, host="H@B#P") result = self.driver._get_share_instance_pnsp(share_instance) self.assertEqual(('P', 'share_fakeinstanceid', 1, share_proto), result)
def test_create_share_from_snapshot(self, share_proto): share = fake_share.fake_share(share_proto=share_proto) share_instance = fake_share.fake_share_instance(share, host="H@B#P") mock_cd = self.mock_object(self.driver, '_create_directory', mock.Mock(return_value='/fake/path')) mock_cns = self.mock_object(self.driver, '_create_nfs_share') mock_ccs = self.mock_object(self.driver, '_create_cifs_share') mock_sdq = self.mock_object(self.driver, '_set_directory_quota') mock_cdtd = self.mock_object(self.driver, '_clone_directory_to_dest') self.driver.ips = ['127.0.0.1'] locations = self.driver.create_share_from_snapshot( self._ctxt, share_instance, None) if share_proto == 'nfs': expect_locations = [{'path': r'127.0.0.1:/fake/path'}] self.assertEqual(locations, expect_locations) else: expect_locations = [{'path': r'\\127.0.0.1\share_fakeinstanceid'}] self.assertEqual(locations, expect_locations) mock_cd.assert_called_once_with(share_name='share_fakeinstanceid', pool_name='P') if share_proto == 'nfs': mock_cns.assert_called_once_with(share_path='/fake/path') elif share['share_proto'] == 'cifs': mock_ccs.assert_called_once_with(share_path='/fake/path', share_name='share_fakeinstanceid') mock_sdq.assert_called_once_with('/fake/path', share['size']) mock_cdtd.assert_called_once_with(snapshot=None, dest_path='/fake/path')
def test__get_share_instance_pnsp(self, share_proto): share = fake_share.fake_share(share_proto=share_proto) share_instance = fake_share.fake_share_instance(share, host="H@B#P") result = self.driver._get_share_instance_pnsp(share_instance) self.assertEqual(('P', 'share_fakeinstanceid', 1, share_proto), result)
def setUp(self): super(HitachiHSPTestCase, self).setUp() CONF.set_default('driver_handles_share_servers', False) CONF.hitachi_hsp_host = '172.24.47.190' CONF.hitachi_hsp_username = '******' CONF.hitachi_hsp_password = '******' CONF.hitachi_hsp_job_timeout = 300 self.fake_el = [{ "path": CONF.hitachi_hsp_host + ":/fakeinstanceid", "metadata": {}, "is_admin_only": False, }] self.fake_share = fake_share.fake_share(share_proto='nfs') self.fake_share_instance = fake_share.fake_share_instance( base_share=self.fake_share, export_locations=self.fake_el) self.fake_conf = manila.share.configuration.Configuration(None) self.fake_private_storage = mock.Mock() self.mock_object(rest.HSPRestBackend, "get_cluster", mock.Mock(return_value=fakes.hsp_cluster)) self._driver = driver.HitachiHSPDriver( configuration=self.fake_conf, private_storage=self.fake_private_storage) self._driver.backend_name = "HSP" self.mock_log = self.mock_object(driver, 'LOG')
def test_extend_share(self): share = fake_share.fake_share() share_instance = fake_share.fake_share_instance(share, host="H@B#P") expect_share_path = r'/P/share_fakeinstanceid' mock_sdq = self.mock_object(self.driver, '_set_directory_quota') self.driver.extend_share(share_instance, 2) mock_sdq.assert_called_once_with(expect_share_path, 2)
def test_extend_share(self): share = fake_share.fake_share() share_instance = fake_share.fake_share_instance(share, host="H@B#P") expect_share_path = r'/P/share_fakeinstanceid' mock_sdq = self.mock_object(self.driver, '_set_directory_quota') self.driver.extend_share(share_instance, 2) mock_sdq.assert_called_once_with(expect_share_path, 2)
def test_delete_share_not_exist(self, share_proto): share = fake_share.fake_share(share_proto=share_proto) share_instance = fake_share.fake_share_instance(share, host="H@B#P") expect_share_path = r'/P/share_fakeinstanceid' mock_gns = self.mock_object(self.driver, '_get_nfs_share', mock.Mock(return_value=[])) mock_gcs = self.mock_object(self.driver, '_get_cifs_share', mock.Mock(return_value=[])) self.driver.delete_share(self._ctxt, share_instance) if share_proto == 'nfs': mock_gns.assert_called_once_with(expect_share_path) elif share_proto == 'cifs': mock_gcs.assert_called_once_with('share_fakeinstanceid')
def test_delete_share_not_exist(self, share_proto): share = fake_share.fake_share(share_proto=share_proto) share_instance = fake_share.fake_share_instance(share, host="H@B#P") expect_share_path = r'/P/share_fakeinstanceid' mock_gns = self.mock_object(self.driver, '_get_nfs_share', mock.Mock(return_value=[])) mock_gcs = self.mock_object(self.driver, '_get_cifs_share', mock.Mock(return_value=[])) self.driver.delete_share(self._ctxt, share_instance) if share_proto == 'nfs': mock_gns.assert_called_once_with(expect_share_path) elif share_proto == 'cifs': mock_gcs.assert_called_once_with('share_fakeinstanceid')
def setUp(self): super(NativeProtocolHelperTestCase, self).setUp() self.fake_conf = configuration.Configuration(None) self._context = context.get_admin_context() self._share = fake_share.fake_share_instance(share_proto='CEPHFS') self.fake_conf.set_default('driver_handles_share_servers', False) self.mock_object(driver, "cephfs_share_path") self._native_protocol_helper = driver.NativeProtocolHelper( None, self.fake_conf, ceph_vol_client=MockVolumeClientModule.CephFSVolumeClient() )
def test_migration_check_compatibility(self, source_host, dest_host, compatible): mock_exception_log = self.mock_object(storage_helper.LOG, 'exception') source_share = base_fake_share.fake_share_instance(host=source_host) dest_share = base_fake_share.fake_share_instance(host=dest_host) migration_compatibility = self.LVMHelper.migration_check_compatibility( self.context, source_share, dest_share, share_server=None, destination_share_server=None) expected_compatibility = { 'compatible': compatible, 'writable': True, 'nondisruptive': False, 'preserve_metadata': True, 'preserve_snapshots': False, } self.assertDictEqual(expected_compatibility, migration_compatibility) if not compatible: mock_exception_log.assert_called_once()
def test_ensure_share_None_share_fail(self, share_proto): share = fake_share.fake_share(share_proto=share_proto) share_instance = fake_share.fake_share_instance(share, host="H@B#P") mock_gns = self.mock_object(self.driver, '_get_nfs_share', mock.Mock(return_value=[])) mock_gcs = self.mock_object(self.driver, '_get_cifs_share', mock.Mock(return_value=[])) self.assertRaises(exception.ShareResourceNotFound, self.driver.ensure_share, self._ctxt, share_instance) if share_proto == 'nfs': mock_gns.assert_called_once_with(r'/P/share_fakeinstanceid') elif share['share_proto'] == 'cifs': mock_gcs.assert_called_once_with(r'share_fakeinstanceid')
def test_ensure_share_None_share_fail(self, share_proto): share = fake_share.fake_share(share_proto=share_proto) share_instance = fake_share.fake_share_instance(share, host="H@B#P") mock_gns = self.mock_object(self.driver, '_get_nfs_share', mock.Mock(return_value=[])) mock_gcs = self.mock_object(self.driver, '_get_cifs_share', mock.Mock(return_value=[])) self.assertRaises(exception.ShareResourceNotFound, self.driver.ensure_share, self._ctxt, share_instance) if share_proto == 'nfs': mock_gns.assert_called_once_with(r'/P/share_fakeinstanceid') elif share['share_proto'] is 'cifs': mock_gcs.assert_called_once_with(r'share_fakeinstanceid')
def test_delete_snapshot_not_exist(self): share = fake_share.fake_share() share_instance = fake_share.fake_share_instance(share, host="H@B#P") snapshot_instance_pseudo = { 'share': share_instance, 'snapshot_id': 'fakesnapid' } mock_gsfs = self.mock_object(self.driver, '_get_snapshots_from_share', mock.Mock(return_value=[])) mock_rest = self.mock_object(as13000_nas.RestAPIExecutor, 'send_rest_api') self.driver.delete_snapshot(self._ctxt, snapshot_instance_pseudo) mock_gsfs.assert_called_once_with('/P/share_fakeinstanceid') mock_rest.assert_not_called()
def test_delete_snapshot_not_exist(self): share = fake_share.fake_share() share_instance = fake_share.fake_share_instance(share, host="H@B#P") snapshot_instance_pseudo = { 'share': share_instance, 'snapshot_id': 'fakesnapid' } mock_gsfs = self.mock_object(self.driver, '_get_snapshots_from_share', mock.Mock(return_value=[])) mock_rest = self.mock_object(as13000_nas.RestAPIExecutor, 'send_rest_api') self.driver.delete_snapshot(self._ctxt, snapshot_instance_pseudo) mock_gsfs.assert_called_once_with('/P/share_fakeinstanceid') mock_rest.assert_not_called()
def test_ensure_share(self, share_proto): share = fake_share.fake_share(share_proto=share_proto) share_instance = fake_share.fake_share_instance(share, host="H@B#P") mock_gns = self.mock_object(self.driver, '_get_nfs_share', mock.Mock(return_value=['fake_share'])) mock_gcs = self.mock_object(self.driver, '_get_cifs_share', mock.Mock(return_value=['fake_share'])) self.driver.ips = ['127.0.0.1'] locations = self.driver.ensure_share(self._ctxt, share_instance) if share_proto == 'nfs': expect_locations = [{'path': r'127.0.0.1:/P/share_fakeinstanceid'}] self.assertEqual(locations, expect_locations) mock_gns.assert_called_once_with(r'/P/share_fakeinstanceid') else: expect_locations = [{'path': r'\\127.0.0.1\share_fakeinstanceid'}] self.assertEqual(locations, expect_locations) mock_gcs.assert_called_once_with(r'share_fakeinstanceid')
def test_ensure_share(self, share_proto): share = fake_share.fake_share(share_proto=share_proto) share_instance = fake_share.fake_share_instance(share, host="H@B#P") mock_gns = self.mock_object(self.driver, '_get_nfs_share', mock.Mock(return_value=['fake_share'])) mock_gcs = self.mock_object(self.driver, '_get_cifs_share', mock.Mock(return_value=['fake_share'])) self.driver.ips = ['127.0.0.1'] locations = self.driver.ensure_share(self._ctxt, share_instance) if share_proto == 'nfs': expect_locations = [{'path': r'127.0.0.1:/P/share_fakeinstanceid'}] self.assertEqual(locations, expect_locations) mock_gns.assert_called_once_with(r'/P/share_fakeinstanceid') else: expect_locations = [{'path': r'\\127.0.0.1\share_fakeinstanceid'}] self.assertEqual(locations, expect_locations) mock_gcs.assert_called_once_with(r'share_fakeinstanceid')
def test_create_snapshot(self): share = fake_share.fake_share() share_instance = fake_share.fake_share_instance(share, host="H@B#P") snapshot_instance_pseudo = { 'share': share_instance, 'id': 'fakesnapid' } mock_rest = self.mock_object(as13000_nas.RestAPIExecutor, 'send_rest_api') self.driver.create_snapshot(self._ctxt, snapshot_instance_pseudo) method = 'snapshot/directory' request_type = 'post' params = {'path': r'/P/share_fakeinstanceid', 'snapName': 'snap_fakesnapid'} mock_rest.assert_called_once_with(method=method, request_type=request_type, params=params)
def test_create_snapshot(self): share = fake_share.fake_share() share_instance = fake_share.fake_share_instance(share, host="H@B#P") snapshot_instance_pseudo = { 'share': share_instance, 'id': 'fakesnapid' } mock_rest = self.mock_object(as13000_nas.RestAPIExecutor, 'send_rest_api') self.driver.create_snapshot(self._ctxt, snapshot_instance_pseudo) method = 'snapshot/directory' request_type = 'post' params = {'path': r'/P/share_fakeinstanceid', 'snapName': 'snap_fakesnapid'} mock_rest.assert_called_once_with(method=method, request_type=request_type, params=params)
def test__clear_access(self, share_proto): share = fake_share.fake_share(share_proto=share_proto) share_instance = fake_share.fake_share_instance(share, host="H@B#P") fake_share_backend = { 'pathAuthority': 'fakepathAuthority', 'clientList': ['fakeclient'], 'userList': ['fakeuser'] } mock_gns = self.mock_object(self.driver, '_get_nfs_share', mock.Mock(return_value=fake_share_backend)) mock_gcs = self.mock_object(self.driver, '_get_cifs_share', mock.Mock(return_value=fake_share_backend)) mock_rest = self.mock_object(as13000_nas.RestAPIExecutor, 'send_rest_api') self.driver._clear_access(share_instance) method = 'file/share/%s' % share_proto request_type = 'put' params = { 'path': r'/P/share_fakeinstanceid', 'addedClientList': [], 'deletedClientList': [], 'editedClientList': [] } if share_proto == 'nfs': mock_gns.assert_called_once_with(r'/P/share_fakeinstanceid') params['deletedClientList'] = fake_share_backend['clientList'] params['pathAuthority'] = fake_share_backend['pathAuthority'] else: mock_gcs.assert_called_once_with('share_fakeinstanceid') params['deletedClientList'] = fake_share_backend['userList'] params['name'] = 'share_fakeinstanceid' mock_rest.assert_called_once_with(method=method, request_type=request_type, params=params)
def test_delete_snapshot_normal(self): share = fake_share.fake_share() share_instance = fake_share.fake_share_instance(share, host="H@B#P") snapshot_instance_pseudo = { 'share': share_instance, 'id': 'fakesnapid' } mock_gsfs = self.mock_object(self.driver, '_get_snapshots_from_share', mock.Mock(return_value=['fakesnapshot'])) mock_rest = self.mock_object(as13000_nas.RestAPIExecutor, 'send_rest_api') self.driver.delete_snapshot(self._ctxt, snapshot_instance_pseudo) mock_gsfs.assert_called_once_with('/P/share_fakeinstanceid') method = ('snapshot/directory?' 'path=/P/share_fakeinstanceid&snapName=snap_fakesnapid') request_type = 'delete' mock_rest.assert_called_once_with(method=method, request_type=request_type)
def test_delete_snapshot_normal(self): share = fake_share.fake_share() share_instance = fake_share.fake_share_instance(share, host="H@B#P") snapshot_instance_pseudo = { 'share': share_instance, 'id': 'fakesnapid' } mock_gsfs = self.mock_object(self.driver, '_get_snapshots_from_share', mock.Mock(return_value=['fakesnapshot'])) mock_rest = self.mock_object(as13000_nas.RestAPIExecutor, 'send_rest_api') self.driver.delete_snapshot(self._ctxt, snapshot_instance_pseudo) mock_gsfs.assert_called_once_with('/P/share_fakeinstanceid') method = ('snapshot/directory?' 'path=/P/share_fakeinstanceid&snapName=snap_fakesnapid') request_type = 'delete' mock_rest.assert_called_once_with(method=method, request_type=request_type)
def setUp(self): super(NativeProtocolHelperTestCase, self).setUp() self.fake_conf = configuration.Configuration(None) self._context = context.get_admin_context() self._share = fake_share.fake_share_instance(share_proto='CEPHFS') self.fake_conf.set_default('driver_handles_share_servers', False) self.mock_object(driver, "rados_command") driver.ceph_default_target = ('mon-mgr', ) self._native_protocol_helper = driver.NativeProtocolHelper( None, self.fake_conf, rados_client=MockRadosModule.Rados(), volname="cephfs") self._rados_client = self._native_protocol_helper.rados_client self._native_protocol_helper.get_mon_addrs = mock.Mock( return_value=['1.2.3.4', '5.6.7.8'])
def test__clone_directory_to_dest(self): share = fake_share.fake_share() share_instance = fake_share.fake_share_instance(share, host="H@B#P") snapshot_instance_pseudo = { 'id': 'fakesnapid', 'share_instance': share_instance } mock_rest = self.mock_object(as13000_nas.RestAPIExecutor, 'send_rest_api') self.driver._clone_directory_to_dest(snapshot_instance_pseudo, 'fakepath') method = 'snapshot/directory/clone' request_type = 'post' params = {'path': '/P/share_fakeinstanceid', 'snapName': 'snap_fakesnapid', 'destPath': 'fakepath'} mock_rest.assert_called_once_with(method=method, request_type=request_type, params=params)
def test__clone_directory_to_dest(self): share = fake_share.fake_share() share_instance = fake_share.fake_share_instance(share, host="H@B#P") snapshot_instance_pseudo = { 'id': 'fakesnapid', 'share_instance': share_instance } mock_rest = self.mock_object(as13000_nas.RestAPIExecutor, 'send_rest_api') self.driver._clone_directory_to_dest(snapshot_instance_pseudo, 'fakepath') method = 'snapshot/directory/clone' request_type = 'post' params = {'path': '/P/share_fakeinstanceid', 'snapName': 'snap_fakesnapid', 'destPath': 'fakepath'} mock_rest.assert_called_once_with(method=method, request_type=request_type, params=params)
def test__clear_access(self, share_proto): share = fake_share.fake_share(share_proto=share_proto) share_instance = fake_share.fake_share_instance(share, host="H@B#P") fake_share_backend = {'pathAuthority': 'fakepathAuthority', 'clientList': ['fakeclient'], 'userList': ['fakeuser']} mock_gns = self.mock_object(self.driver, '_get_nfs_share', mock.Mock(return_value=fake_share_backend)) mock_gcs = self.mock_object(self.driver, '_get_cifs_share', mock.Mock(return_value=fake_share_backend)) mock_rest = self.mock_object(as13000_nas.RestAPIExecutor, 'send_rest_api') self.driver._clear_access(share_instance) method = 'file/share/%s' % share_proto request_type = 'put' params = { 'path': r'/P/share_fakeinstanceid', 'addedClientList': [], 'deletedClientList': [], 'editedClientList': [] } if share_proto == 'nfs': mock_gns.assert_called_once_with(r'/P/share_fakeinstanceid') params['deletedClientList'] = fake_share_backend['clientList'] params['pathAuthority'] = fake_share_backend['pathAuthority'] else: mock_gcs.assert_called_once_with('share_fakeinstanceid') params['deletedClientList'] = fake_share_backend['userList'] params['name'] = 'share_fakeinstanceid' mock_rest.assert_called_once_with(method=method, request_type=request_type, params=params)
def test_update_access(self, share_proto, use_access): share = fake_share.fake_share(share_proto=share_proto) share_instance = fake_share.fake_share_instance(share, host="H@B#P") access_rules = [{ 'access_to': 'fakename1', 'access_level': 'fakelevel1' }, { 'access_to': 'fakename2', 'access_level': 'fakelevel2' }] add_rules = [{'access_to': 'fakename1', 'access_level': 'fakelevel1'}] del_rules = [{'access_to': 'fakename2', 'access_level': 'fakelevel2'}] mock_ca = self.mock_object(self.driver, '_clear_access') fake_share_backend = {'pathAuthority': 'fakepathAuthority'} mock_gns = self.mock_object(self.driver, '_get_nfs_share', mock.Mock(return_value=fake_share_backend)) mock_rest = self.mock_object(as13000_nas.RestAPIExecutor, 'send_rest_api') if use_access: self.driver.update_access(self._ctxt, share_instance, access_rules, [], []) else: self.driver.update_access(self._ctxt, share_instance, [], add_rules, del_rules) access_clients = [{ 'name': rule['access_to'], 'type': 0 if share_proto == 'nfs' else 1, 'authority': rule['access_level'] } for rule in access_rules] add_clients = [{ 'name': rule['access_to'], 'type': 0 if share_proto == 'nfs' else 1, 'authority': rule['access_level'] } for rule in add_rules] del_clients = [{ 'name': rule['access_to'], 'type': 0 if share_proto == 'nfs' else 1, 'authority': rule['access_level'] } for rule in del_rules] params = { 'path': r'/P/share_fakeinstanceid', 'addedClientList': [], 'deletedClientList': [], 'editedClientList': [] } if share_proto == 'nfs': mock_gns.assert_called_once_with(r'/P/share_fakeinstanceid') params['pathAuthority'] = fake_share_backend['pathAuthority'] else: params['name'] = 'share_fakeinstanceid' if use_access: mock_ca.assert_called_once_with(share_instance) params['addedClientList'] = access_clients else: params['addedClientList'] = add_clients params['deletedClientList'] = del_clients mock_rest.assert_called_once_with(method=('file/share/%s' % share_proto), params=params, request_type='put')
def test_ensure_share_fail_1(self): share = fake_share.fake_share() share_instance = fake_share.fake_share_instance(share, host="H@B#P") self.assertRaises(exception.InvalidInput, self.driver.ensure_share, self._ctxt, share_instance)
def test_ensure_share_fail_1(self): share = fake_share.fake_share() share_instance = fake_share.fake_share_instance(share, host="H@B#P") self.assertRaises(exception.InvalidInput, self.driver.ensure_share, self._ctxt, share_instance)
def test_update_access(self, share_proto, use_access): share = fake_share.fake_share(share_proto=share_proto) share_instance = fake_share.fake_share_instance(share, host="H@B#P") access_rules = [{'access_to': 'fakename1', 'access_level': 'fakelevel1'}, {'access_to': 'fakename2', 'access_level': 'fakelevel2'}] add_rules = [{'access_to': 'fakename1', 'access_level': 'fakelevel1'}] del_rules = [{'access_to': 'fakename2', 'access_level': 'fakelevel2'}] mock_ca = self.mock_object(self.driver, '_clear_access') fake_share_backend = {'pathAuthority': 'fakepathAuthority'} mock_gns = self.mock_object(self.driver, '_get_nfs_share', mock.Mock(return_value=fake_share_backend)) mock_rest = self.mock_object(as13000_nas.RestAPIExecutor, 'send_rest_api') if use_access: self.driver.update_access(self._ctxt, share_instance, access_rules, [], []) else: self.driver.update_access(self._ctxt, share_instance, [], add_rules, del_rules) access_clients = [{'name': rule['access_to'], 'type': 0 if share_proto == 'nfs' else 1, 'authority': rule['access_level'] } for rule in access_rules] add_clients = [{'name': rule['access_to'], 'type': 0 if share_proto == 'nfs' else 1, 'authority': rule['access_level'] } for rule in add_rules] del_clients = [{'name': rule['access_to'], 'type': 0 if share_proto == 'nfs' else 1, 'authority': rule['access_level'] } for rule in del_rules] params = { 'path': r'/P/share_fakeinstanceid', 'addedClientList': [], 'deletedClientList': [], 'editedClientList': [] } if share_proto == 'nfs': mock_gns.assert_called_once_with(r'/P/share_fakeinstanceid') params['pathAuthority'] = fake_share_backend['pathAuthority'] else: params['name'] = 'share_fakeinstanceid' if use_access: mock_ca.assert_called_once_with(share_instance) params['addedClientList'] = access_clients else: params['addedClientList'] = add_clients params['deletedClientList'] = del_clients mock_rest.assert_called_once_with( method=('file/share/%s' % share_proto), params=params, request_type='put')