Esempio n. 1
0
 def _wait_for_copy_pair_smpl(start_time, ldev):
     """Raise True if the LDEV is no longer in a copy pair."""
     ldev_info = self.get_ldev_info(['status', 'attributes'], ldev)
     if (ldev_info['status'] != NORMAL_STS
             or PAIR_ATTR not in ldev_info['attributes']):
         raise loopingcall.LoopingCallDone()
     if utils.timed_out(start_time, utils.DEFAULT_PROCESS_WAITTIME):
         raise loopingcall.LoopingCallDone(False)
Esempio n. 2
0
 def _wait_for_copy_pair_status(start_time, ldev, status, timeout):
     """Raise True if the S-VOL is in the specified status."""
     if not isinstance(status, set):
         status = set([status])
     if self._get_copy_pair_status(ldev) in status:
         raise loopingcall.LoopingCallDone()
     if utils.timed_out(start_time, timeout):
         raise loopingcall.LoopingCallDone(False)
Esempio n. 3
0
 def _wait_for_copy_pair_smpl(start_time, ldev):
     """Raise True if the LDEV is no longer in a copy pair."""
     ldev_info = self.get_ldev_info(['status', 'attributes'], ldev)
     if (ldev_info['status'] != NORMAL_STS
             or self.driver_info['pair_attr']
             not in ldev_info['attributes']):
         raise loopingcall.LoopingCallDone()
     if utils.timed_out(start_time,
                        self.conf.hitachi_state_transition_timeout):
         raise loopingcall.LoopingCallDone(False)
Esempio n. 4
0
    def _check_rest_api_response(
            self, response, start_time, method=None,
            url=None, params=None, body=None, **kwargs):
        """Check the response from REST API server."""
        rsp_body = response['rsp_body']
        errobj = response['errobj']
        if response.is_locked():
            if (kwargs['no_retry'] or
                    utils.timed_out(start_time, _LOCK_WAITTIME)):
                msg = utils.output_log(MSG.REST_API_FAILED,
                                       no_log=kwargs['no_log'],
                                       method=method, url=url,
                                       params=params, body=body,
                                       **response.get_errobj())
                if kwargs['do_raise']:
                    raise utils.HBSDError(msg, errobj=errobj)
                return False, rsp_body, errobj
            else:
                LOG.debug("The resource group to which the operation object ",
                          "belongs is being locked by other software.")
                return True, rsp_body, errobj

        if response.is_success(kwargs['ignore_error'],
                               kwargs['ignore_message_id'],
                               kwargs['ignore_return_code'],
                               kwargs['ignore_all_errors']):
            return False, rsp_body, errobj

        if (kwargs['no_retry'] and
                response['status_code'] != httpclient.INTERNAL_SERVER_ERROR or
                response.is_no_retry_error(kwargs['no_retry_error'])):
            retry = False
        elif response.is_auth_fail():
            retry = self.relogin(kwargs['no_relogin'])
        else:
            retry = True

        if retry and response.is_rest_server_busy():
            if utils.timed_out(start_time, _REST_SERVER_BUSY_TIMEOUT):
                retry = False
        elif retry and utils.timed_out(start_time, kwargs['timeout']):
            if kwargs['timeout_message']:
                utils.output_log(kwargs['timeout_message'][0],
                                 **kwargs['timeout_message'][1])
            if response.is_json():
                msg = utils.output_log(MSG.REST_API_TIMEOUT,
                                       no_log=kwargs['no_log'],
                                       method=method, url=url,
                                       params=params, body=body,
                                       **response.get_job_result())
                if errobj:
                    msg = utils.output_log(MSG.REST_API_FAILED,
                                           no_log=kwargs['no_log'],
                                           method=method, url=url,
                                           params=params, body=body,
                                           **response.get_errobj())
            else:
                msg = utils.output_log(MSG.REST_API_HTTP_ERROR,
                                       no_log=kwargs['no_log'],
                                       status_code=response['status_code'],
                                       response_body=rsp_body,
                                       method=method, url=url,
                                       params=params, body=body)
            if kwargs['do_raise']:
                raise utils.HBSDError(msg, errobj=errobj)
            return False, rsp_body, errobj

        if errobj:
            LOG.debug('ERROR %s', errobj)
        else:
            LOG.debug('ERROR %s', ' '.join(str(rsp_body).splitlines()))

        if not retry:
            if response.is_json():
                msg = utils.output_log(MSG.REST_API_FAILED,
                                       no_log=kwargs['no_log'],
                                       method=method, url=url,
                                       params=params, body=body,
                                       **response.get_errobj())
            else:
                msg = utils.output_log(MSG.REST_API_HTTP_ERROR,
                                       no_log=kwargs['no_log'],
                                       status_code=response['status_code'],
                                       response_body=rsp_body,
                                       method=method, url=url,
                                       params=params, body=body)
            if kwargs['do_raise']:
                raise utils.HBSDError(msg, errobj=errobj)
        return retry, rsp_body, errobj
Esempio n. 5
0
    def _check_rest_api_response(
            self, response, start_time, method=None,
            url=None, params=None, body=None, **kwargs):
        """Check the response from REST API server."""
        rsp_body = response['rsp_body']
        errobj = response['errobj']
        if response.is_locked():
            if (kwargs['no_retry'] or
                    utils.timed_out(
                        start_time, self.conf.hitachi_lock_timeout)):
                msg = utils.output_log(MSG.REST_API_FAILED,
                                       no_log=kwargs['no_log'],
                                       method=method, url=url,
                                       params=params, body=body,
                                       **response.get_errobj())
                if kwargs['do_raise']:
                    message = _(
                        '%(prefix)s error occurred. %(msg)s' % {
                            'prefix': self.driver_prefix,
                            'msg': msg,
                        }
                    )
                    raise exception.VolumeDriverException(
                        message, errobj=errobj)
                return False, rsp_body, errobj
            else:
                LOG.debug("The resource group to which the operation object ",
                          "belongs is being locked by other software.")
                return True, rsp_body, errobj

        if response.is_success(kwargs['ignore_error'],
                               kwargs['ignore_message_id'],
                               kwargs['ignore_return_code'],
                               kwargs['ignore_all_errors']):
            return False, rsp_body, errobj

        if (kwargs['no_retry'] and
                response['status_code'] != httpclient.INTERNAL_SERVER_ERROR or
                response.is_no_retry_error(kwargs['no_retry_error'])):
            retry = False
        elif response.is_auth_fail():
            retry = self.relogin(kwargs['no_relogin'])
        else:
            retry = True

        if retry and response.is_rest_server_busy():
            if utils.timed_out(
                    start_time, self.conf.hitachi_rest_server_busy_timeout):
                retry = False
        elif retry and response.get_err_code() in (ANOTHER_LDEV_MAPPED, ):
            if utils.timed_out(
                    start_time,
                    self.conf.hitachi_rest_another_ldev_mapped_retry_timeout):
                LOG.debug(
                    "Another LDEV is already mapped to the specified LUN.")
                retry = False
        elif retry and utils.timed_out(start_time, kwargs['timeout']):
            if kwargs['timeout_message']:
                utils.output_log(kwargs['timeout_message'][0],
                                 **kwargs['timeout_message'][1])
            if response.is_json():
                msg = utils.output_log(MSG.REST_API_TIMEOUT,
                                       no_log=kwargs['no_log'],
                                       method=method, url=url,
                                       params=params, body=body,
                                       **response.get_job_result())
                if errobj:
                    msg = utils.output_log(MSG.REST_API_FAILED,
                                           no_log=kwargs['no_log'],
                                           method=method, url=url,
                                           params=params, body=body,
                                           **response.get_errobj())
            else:
                msg = utils.output_log(MSG.REST_API_HTTP_ERROR,
                                       no_log=kwargs['no_log'],
                                       status_code=response['status_code'],
                                       response_body=rsp_body,
                                       method=method, url=url,
                                       params=params, body=body)
            if kwargs['do_raise']:
                message = _(
                    '%(prefix)s error occurred. %(msg)s' % {
                        'prefix': self.driver_prefix,
                        'msg': msg,
                    }
                )
                raise exception.VolumeDriverException(
                    message, errobj=errobj)
            return False, rsp_body, errobj

        if errobj:
            LOG.debug('ERROR %s', errobj)
        else:
            LOG.debug('ERROR %s', ' '.join(str(rsp_body).splitlines()))

        if not retry:
            if response.is_json():
                msg = utils.output_log(MSG.REST_API_FAILED,
                                       no_log=kwargs['no_log'],
                                       method=method, url=url,
                                       params=params, body=body,
                                       **response.get_errobj())
            else:
                msg = utils.output_log(MSG.REST_API_HTTP_ERROR,
                                       no_log=kwargs['no_log'],
                                       status_code=response['status_code'],
                                       response_body=rsp_body,
                                       method=method, url=url,
                                       params=params, body=body)
            if kwargs['do_raise']:
                message = _(
                    '%(prefix)s error occurred. %(msg)s' % {
                        'prefix': self.driver_prefix,
                        'msg': msg,
                    }
                )
                raise exception.VolumeDriverException(
                    message, errobj=errobj)
        return retry, rsp_body, errobj