Skip to content

Commit

Permalink
Update access info filter
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-v committed May 16, 2022
1 parent 3259e17 commit e19141b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
8 changes: 3 additions & 5 deletions delfin/api/v1/storages.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def sync(self, req, id):
def _storage_exist(self, context, access_info):
access_info_dict = copy.deepcopy(access_info)
access_info_list = access_info_filter(
context, access_info_dict, False)
context, access_info_dict)

for _access_info in access_info_list:
try:
Expand Down Expand Up @@ -254,15 +254,13 @@ def _set_synced_if_ok(context, storage_id, resource_count):
db.storage_update(context, storage['id'], storage)


def access_info_filter(context, access_info,
exclude_storage_name=False):
def access_info_filter(context, access_info):
access_info_dict = copy.deepcopy(access_info)

for access in constants.ACCESS_TYPE:
if access_info_dict.get(access):
access_info_dict.pop(access)
if exclude_storage_name:
access_info_dict.pop('storage_name')

# Check if storage is registered
access_info_list = db.access_info_get_all(context,
filters=access_info_dict)
Expand Down
19 changes: 10 additions & 9 deletions delfin/drivers/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,11 @@ def _get_driver_obj(self, context, cache_on_load=True, **kwargs):
return cls(**kwargs)

if kwargs['storage_id'] in self.driver_factory:
driver = self.driver_factory[kwargs['storage_id']]
return driver
return self.driver_factory[kwargs['storage_id']]

with self._instance_lock:
if kwargs['storage_id'] in self.driver_factory:
driver = self.driver_factory[kwargs['storage_id']]
return driver
return self.driver_factory[kwargs['storage_id']]

if kwargs['verify']:
ssl_utils.reload_certificate(kwargs['verify'])
Expand All @@ -110,15 +108,18 @@ def _get_driver_obj(self, context, cache_on_load=True, **kwargs):
'extra_attributes']
# Remove unrelated query fields
for field in remove_fields:
access_info_dict.pop(field)
if access_info_dict.get(field):
access_info_dict.pop(field)
for access in constants.ACCESS_TYPE:
access_info_dict.pop(access)
if access_info_dict.get(access):
access_info_dict.pop(access)

access_info_list = db.access_info_get_all(context,
filters=access_info_dict)
access_info_list = db.access_info_get_all(
context, filters=access_info_dict)
for _access_info in access_info_list:
if _access_info['storage_id'] in self.driver_factory:
driver = self.driver_factory[_access_info['storage_id']]
driver = self.driver_factory[
_access_info['storage_id']]
driver.add_storage(access_info)
self.driver_factory[storage_id] = driver
return driver
Expand Down

0 comments on commit e19141b

Please sign in to comment.