Skip to content

Commit

Permalink
pure codeview-Delete unnecessary Definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
zhilong-xu committed Nov 10, 2021
1 parent 7aaa252 commit cefca2c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
4 changes: 2 additions & 2 deletions delfin/drivers/pure/pure/pure_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def list_disks(self, context):
disk_dict = dict()
drive_name = disk.get('name')
disk_dict['name'] = drive_name
physical_type = disk.get('type').lower()
physical_type = disk.get('type', "").lower()
disk_dict['physical_type'] = physical_type \
if physical_type in constants.DiskPhysicalType.ALL else \
constants.DiskPhysicalType.UNKNOWN
Expand All @@ -178,7 +178,7 @@ def list_disks(self, context):
disk_dict['native_disk_id'] = drive_name
disk_dict['id'] = drive_name
disk_dict['location'] = drive_name
disk_dict['manufacturer'] = "pure"
disk_dict['manufacturer'] = "PURE"
disk_dict['firmware'] = ""
list_disks.append(disk_dict)
return list_disks
Expand Down
21 changes: 4 additions & 17 deletions delfin/drivers/pure/pure/rest_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,14 @@ class RestHandler(RestClient):
REST_ALERTS_URL = '/api/1.17/message?flagged=true'
REST_AUTH_URL = '/api/1.17/auth/apitoken'
REST_SESSION_URL = '/api/1.17/auth/session'
HTTPS = 'https://'

def __init__(self, **kwargs):
super(RestHandler, self).__init__(**kwargs)
rest_access = kwargs.get('rest')
if rest_access is None:
raise exception.InvalidInput('Input pure_rest_access is missing')
self.host = rest_access.get('host')
self.port = rest_access.get('port')
self.username = rest_access.get('username')
self.password = rest_access.get('password')

def login(self):
try:
data = {'username': self.username, 'password': cryptor.decode(
self.password)}
data = {'username': self.rest_username, 'password': cryptor.decode(
self.rest_password)}
token_res = self.get_token(RestHandler.REST_AUTH_URL, data,
method='POST')
if token_res.status_code != consts.SUCCESS_STATUS_CODE:
Expand Down Expand Up @@ -86,10 +78,7 @@ def logout(self):
raise exception.StorageBackendException(res.text)

def get_volumes(self):
url = '%s%s:%s%s' % (
RestHandler.HTTPS, self.host, self.port,
RestHandler.REST_VOLUME_URL)
result_json = self.get_volumes_info(url)
result_json = self.get_volumes_info(RestHandler.REST_VOLUME_URL)
return result_json

def get_storages(self):
Expand Down Expand Up @@ -159,9 +148,7 @@ def get_volumes_info(self, url, data=None, volume_list=None,
if next_token:
token = next_token[consts.DEFAULT_LIST_GET_VOLUMES_INFO]
if token:
url = '%s%s:%s%s%s' % (
RestHandler.HTTPS, self.host, self.port,
RestHandler.REST_VOLUME_TOKEN_URL, token)
url = '%s%s' % (RestHandler.REST_VOLUME_TOKEN_URL, token)
self.get_volumes_info(url, data, volume_list)
elif res.status_code == consts.PERMISSION_DENIED_STATUS_CODE:
self.login()
Expand Down

0 comments on commit cefca2c

Please sign in to comment.