diff --git a/delfin/drivers/hitachi/vsp/consts.py b/delfin/drivers/hitachi/vsp/consts.py index 268c390c5..9bc3c3d35 100644 --- a/delfin/drivers/hitachi/vsp/consts.py +++ b/delfin/drivers/hitachi/vsp/consts.py @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -SOCKET_TIMEOUT = 52 +SOCKET_TIMEOUT = 30 ERROR_SESSION_INVALID_CODE = 403 ERROR_SESSION_IS_BEING_USED_CODE = 409 BLOCK_SIZE = 512 diff --git a/delfin/drivers/hitachi/vsp/rest_handler.py b/delfin/drivers/hitachi/vsp/rest_handler.py index 6537dff01..9bc068de0 100644 --- a/delfin/drivers/hitachi/vsp/rest_handler.py +++ b/delfin/drivers/hitachi/vsp/rest_handler.py @@ -40,10 +40,10 @@ def __init__(self, **kwargs): self.device_model = None self.serial_number = None - def call(self, url, data=None, method=None): + def call(self, url, data=None, method=None, + calltimeout=consts.SOCKET_TIMEOUT): try: - res = self.do_call(url, data, method, - calltimeout=consts.SOCKET_TIMEOUT) + res = self.do_call(url, data, method, calltimeout) if (res.status_code == consts.ERROR_SESSION_INVALID_CODE or res.status_code == consts.ERROR_SESSION_IS_BEING_USED_CODE): @@ -57,8 +57,7 @@ def call(self, url, data=None, method=None): access_session = self.login() if access_session is not None: res = self. \ - do_call(url, data, method, - calltimeout=consts.SOCKET_TIMEOUT) + do_call(url, data, method, calltimeout) else: LOG.error('Login error,get access_session failed') elif res.status_code == 503: @@ -71,9 +70,9 @@ def call(self, url, data=None, method=None): LOG.error(err_msg) raise e - def get_rest_info(self, url, data=None): + def get_rest_info(self, url, timeout=consts.SOCKET_TIMEOUT, data=None): result_json = None - res = self.call(url, data, 'GET') + res = self.call(url, data, 'GET', timeout) if res.status_code == 200: result_json = res.json() return result_json @@ -96,8 +95,7 @@ def login(self): self.rest_username, cryptor.decode(self.rest_password)) res = self. \ - do_call(url, data, 'POST', - calltimeout=consts.SOCKET_TIMEOUT) + do_call(url, data, 'POST', 10) if res.status_code == 200: result = res.json() self.session_id = result.get('sessionId') @@ -199,6 +197,6 @@ def get_all_volumes(self): return result_json def get_system_info(self): - result_json = self.get_rest_info(RestHandler.COMM_URL) + result_json = self.get_rest_info(RestHandler.COMM_URL, timeout=10) return result_json diff --git a/delfin/drivers/hitachi/vsp/vsp_stor.py b/delfin/drivers/hitachi/vsp/vsp_stor.py index 3c59b2a91..36af9e5ec 100644 --- a/delfin/drivers/hitachi/vsp/vsp_stor.py +++ b/delfin/drivers/hitachi/vsp/vsp_stor.py @@ -52,7 +52,6 @@ class HitachiVspDriver(driver.StorageDriver): TRAP_TIME_OID = '1.3.6.1.4.1.116.5.11.4.2.6' TRAP_DATE_OID = '1.3.6.1.4.1.116.5.11.4.2.5' TRAP_NICKNAME_OID = '1.3.6.1.4.1.116.5.11.4.2.2' - LOCATION_OID = '1.3.6.1.4.1.116.5.11.4.2.4' OID_SEVERITY = '1.3.6.1.6.3.1.1.4.1.0' SECONDS_TO_MS = 1000 @@ -294,7 +293,8 @@ def parse_alert(context, alert): HitachiVspDriver.SECONDS_TO_MS) alert_model['description'] = alert.get(HitachiVspDriver.DESC_OID) alert_model['resource_type'] = constants.DEFAULT_RESOURCE_TYPE - alert_model['location'] = alert.get(HitachiVspDriver.LOCATION_OID) + alert_model['location'] = alert.get(HitachiVspDriver. + TRAP_NICKNAME_OID) return alert_model except Exception as e: