-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unity fix the issue which when filesystem is None in get_share #696
Changes from 21 commits
f0c9413
cf8f094
7fde282
a74134e
c138b3b
f5b1b43
fc2601a
a27c6b0
7056324
4757c4e
ecef23e
31a119e
edbd0b9
cb81e5f
2dc4992
ab1bc35
87836c4
bb094ea
2ac74fb
cf27b5d
a7afa8f
90353b6
2d7c4d2
fc900a9
375fa2a
b81681f
21180a5
ca0eedc
d5437e8
8e3b0bc
23ebf0a
756a576
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
|
||
from delfin import cryptor | ||
from delfin import exception | ||
from delfin.drivers.dell_emc.unity import consts | ||
from delfin.drivers.utils.rest_client import RestClient | ||
|
||
LOG = logging.getLogger(__name__) | ||
|
@@ -63,7 +64,8 @@ def login(self): | |
self.session.auth = requests.auth.HTTPBasicAuth( | ||
self.rest_username, cryptor.decode(self.rest_password)) | ||
res = self.call_with_token( | ||
RestHandler.REST_AUTH_URL, data, 'GET') | ||
RestHandler.REST_AUTH_URL, data, 'GET', | ||
consts.DEFAULT_TIMEOUT) | ||
if res.status_code == 200: | ||
self.session.headers[RestHandler.AUTH_KEY] = \ | ||
cryptor.encode(res.headers[RestHandler.AUTH_KEY]) | ||
|
@@ -81,44 +83,47 @@ def login(self): | |
LOG.error("Login error: %s", six.text_type(e)) | ||
raise e | ||
|
||
def call_with_token(self, url, data, method): | ||
def call_with_token(self, url, data, method, calltimeout): | ||
auth_key = None | ||
if self.session: | ||
auth_key = self.session.headers.get(RestHandler.AUTH_KEY, None) | ||
if auth_key: | ||
self.session.headers[RestHandler.AUTH_KEY] \ | ||
= cryptor.decode(auth_key) | ||
res = self.do_call(url, data, method) | ||
res = self.do_call(url, data, method, calltimeout) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default value of parameter calltimeout in do_call() is from driver code of HPE 3par, method do_call() is a common method, I think its default value should be also from common module or from its own. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
if auth_key: | ||
self.session.headers[RestHandler.AUTH_KEY] = auth_key | ||
return res | ||
|
||
def logout(self): | ||
try: | ||
if self.san_address: | ||
self.call(RestHandler.REST_LOGOUT_URL, method='POST') | ||
self.call(RestHandler.REST_LOGOUT_URL, | ||
consts.DEFAULT_TIMEOUT, | ||
data={}, method='POST') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. parameter data can use default value of method call(). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
if self.session: | ||
self.session.close() | ||
except Exception as e: | ||
err_msg = "Logout error: %s" % (six.text_type(e)) | ||
LOG.error(err_msg) | ||
raise e | ||
|
||
def get_rest_info(self, url, data=None, method='GET'): | ||
def get_rest_info(self, url, data=None, method='GET', | ||
calltimeout=consts.DEFAULT_TIMEOUT): | ||
result_json = None | ||
res = self.call(url, data, method) | ||
res = self.call(url, calltimeout, data, method) | ||
if res.status_code == 200: | ||
result_json = res.json() | ||
return result_json | ||
|
||
def call(self, url, data=None, method=None): | ||
def call(self, url, calltimeout, data=None, method=None): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the parameters of call() is the same as the parameters of call_with_token(), these parameters should be in the same order. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
try: | ||
res = self.call_with_token(url, data, method) | ||
res = self.call_with_token(url, data, method, calltimeout) | ||
if res.status_code == 401: | ||
LOG.error("Failed to get token, status_code:%s,error_mesg:%s" % | ||
(res.status_code, res.text)) | ||
self.login() | ||
res = self.call_with_token(url, data, method) | ||
res = self.call_with_token(url, data, method, calltimeout) | ||
elif res.status_code == 503: | ||
raise exception.InvalidResults(res.text) | ||
return res | ||
|
@@ -167,7 +172,16 @@ def get_all_alerts(self, page_number): | |
'messageId,message,description,' | ||
'descriptionId,state', | ||
page_number) | ||
result_json = self.get_rest_info(url) | ||
result_json = self.get_rest_info(url, consts.ALERT_TIMEOUT) | ||
return result_json | ||
|
||
def get_all_alerts_without_state(self, page_number): | ||
url = '%s?%s&page=%s' % (RestHandler.REST_ALERTS_URL, | ||
'fields=id,timestamp,severity,component,' | ||
'messageId,message,description,' | ||
'descriptionId', | ||
page_number) | ||
result_json = self.get_rest_info(url, consts.ALERT_TIMEOUT) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The second parameter of get_rest_info() is data, not calltimeout. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
return result_json | ||
|
||
def remove_alert(self, alert_id): | ||
|
@@ -180,16 +194,15 @@ def remove_alert(self, alert_id): | |
def get_all_controllers(self): | ||
url = '%s?%s' % (RestHandler.REST_CONTROLLER_URL, | ||
'fields=id,name,health,model,slotNumber,' | ||
'emcPartNumber,emcSerialNumber,manufacturer,' | ||
'memorySize') | ||
'manufacturer,memorySize') | ||
result_json = self.get_rest_info(url) | ||
return result_json | ||
|
||
def get_all_disks(self): | ||
url = '%s?%s' % (RestHandler.REST_DISK_URL, | ||
'fields=id,name,health,model,slotNumber,' | ||
'manufacturer,version,emcSerialNumber,wwn' | ||
'emcPartNumber,rpm,size,diskGroup') | ||
'manufacturer,version,emcSerialNumber,wwn,' | ||
'rpm,size,diskGroup') | ||
result_json = self.get_rest_info(url) | ||
return result_json | ||
|
||
|
@@ -203,7 +216,7 @@ def get_all_fcports(self): | |
def get_all_ethports(self): | ||
url = '%s?%s' % (RestHandler.REST_ETHPORT_URL, | ||
'fields=id,name,health,portNumber,storageProcessor,' | ||
'speed,isLinkUp,macAddress,maxMtu') | ||
'speed,isLinkUp,macAddress') | ||
result_json = self.get_rest_info(url) | ||
return result_json | ||
|
||
|
@@ -221,6 +234,13 @@ def get_all_filesystems(self): | |
result_json = self.get_rest_info(url) | ||
return result_json | ||
|
||
def get_all_filesystems_without_flr(self): | ||
url = '%s?%s' % (RestHandler.REST_FILESYSTEM_URL, | ||
'fields=id,name,health,sizeAllocated,accessPolicy,' | ||
'sizeTotal,sizeUsed,isThinEnabled,pool') | ||
result_json = self.get_rest_info(url) | ||
return result_json | ||
|
||
def get_all_nfsshares(self): | ||
url = '%s?%s' % (RestHandler.REST_NFSSHARE_URL, | ||
'fields=id,filesystem,name,path') | ||
|
@@ -249,7 +269,6 @@ def get_all_userquotas(self): | |
|
||
def get_quota_configs(self): | ||
url = '%s?%s' % (RestHandler.REST_QUOTACONFIG_URL, | ||
'fields=id,filesystem,treeQuota,quotaPolicy,' | ||
'isUserQuotaEnabled,isAccessDenyEnabled') | ||
'fields=id,filesystem,treeQuota,quotaPolicy') | ||
result_json = self.get_rest_info(url) | ||
return result_json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data can set default ot None, method default to GET, calltimeout default to consts.DEFAULT_TIMEOUT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done