def _fatal_error_code(self, response): """Raise an exception for certain errors in a XG response. Error codes are extracted from vdmd_mgmt.c. Arguments: response -- a response dict result from an XG request """ # known non-fatal response codes: # 1024: 'lun deletion in progress, try again later' # 14032: 'lc_err_lock_busy' if response['code'] == 14000: # lc_generic_error raise exception.ViolinBackendErr(message=response['message']) elif response['code'] == 14002: # lc_err_assertion_failed raise exception.ViolinBackendErr(message=response['message']) elif response['code'] == 14004: # lc_err_not_found raise exception.ViolinBackendErrNotFound() elif response['code'] == 14005: # lc_err_exists raise exception.ViolinBackendErrExists() elif response['code'] == 14008: # lc_err_unexpected_arg raise exception.ViolinBackendErr(message=response['message']) elif response['code'] == 14014: # lc_err_io_error raise exception.ViolinBackendErr(message=response['message']) elif response['code'] == 14016: # lc_err_io_closed raise exception.ViolinBackendErr(message=response['message']) elif response['code'] == 14017: # lc_err_io_timeout raise exception.ViolinBackendErr(message=response['message']) elif response['code'] == 14021: # lc_err_unexpected_case raise exception.ViolinBackendErr(message=response['message']) elif response['code'] == 14025: # lc_err_no_fs_space raise exception.ViolinBackendErr(message=response['message']) elif response['code'] == 14035: # lc_err_range raise exception.ViolinBackendErr(message=response['message']) elif response['code'] == 14036: # lc_err_invalid_param raise exception.ViolinBackendErr(message=response['message']) elif response['code'] == 14121: # lc_err_cancelled_err raise exception.ViolinBackendErr(message=response['message']) elif response['code'] == 512: # Not enough free space in container (vdmd bug) raise exception.ViolinBackendErr(message=response['message']) elif response['code'] == 1 and 'LUN ID conflict' \ in response['message']: # lun id conflict while attempting to export raise exception.ViolinBackendErr(message=response['message'])
def test_create_lun_lun_already_exists(self): """Array returns error that the lun already exists.""" response = { 'code': 14005, 'message': 'LUN with name ... already exists' } conf = { 'lun.create_lun.return_value': response, } self.driver.vip = self.setup_mock_client(m_conf=conf) self.driver._send_cmd = mock.Mock( side_effect=exception.ViolinBackendErrExists(response['message'])) self.assertTrue(self.driver._create_lun(VOLUME) is None)
def _check_error_code(self, response): """Raise an exception when backend returns certain errors. Error codes returned from the backend have to be examined individually. Not all of them are fatal. For example, lun attach failing becase the client is already attached is not a fatal error. :param response: a response dict result from the vmemclient request """ if "Error: 0x9001003c" in response['msg']: # This error indicates a duplicate attempt to attach lun, # non-fatal error pass elif "Error: 0x9002002b" in response['msg']: # lun unexport failed - lun is not exported to any clients, # non-fatal error pass elif "Error: 0x09010023" in response['msg']: # lun delete failed - dependent snapshot copy in progress, # fatal error raise exception.ViolinBackendErr(message=response['msg']) elif "Error: 0x09010048" in response['msg']: # lun delete failed - dependent snapshots still exist, # fatal error raise exception.ViolinBackendErr(message=response['msg']) elif "Error: 0x90010022" in response['msg']: # lun create failed - lun with same name already exists, # fatal error raise exception.ViolinBackendErrExists() elif "Error: 0x90010089" in response['msg']: # lun export failed - lun is still being created as copy, # fatal error raise exception.ViolinBackendErr(message=response['msg']) else: # assume any other error is fatal raise exception.ViolinBackendErr(message=response['msg'])