def _is_volume_exist(self, volume_name): query_volume_result = self._query_volume(volume_name) if ((not query_volume_result) or ('retcode' not in query_volume_result) or (query_volume_result['retcode'] not in ('0', self.del_complete_code))): msg = _('%(err)s\n') % { 'err': 'Query volume failed!' ' Invalid result code' } raise exception.VolumeBackendAPIException(data=msg) if query_volume_result['retcode'] == self.del_complete_code: return False if query_volume_result['retcode'] == '0': if 'volume0' not in query_volume_result: msg = _('%(err)s\n') % { 'err': 'Query volume failed! ' 'Volume0 not exist!' } raise exception.VolumeBackendAPIException(data=msg) query_volume_result['volume0'] = \ storhyper_utils.generate_dict_from_result( query_volume_result['volume0']) if (('status' not in query_volume_result['volume0']) or (query_volume_result['volume0']['status'] not in ('1', '2', '10'))): msg = _('%(err)s\n') % { 'err': 'Query volume failed!' ' Invalid volume status' } raise exception.VolumeBackendAPIException(data=msg) return True
def _is_volume_exist(self, volume_name): query_volume_result = self._query_volume(volume_name) if ((not query_volume_result) or ('retcode' not in query_volume_result) or (query_volume_result['retcode'] not in ('0', self.del_complete_code))): msg = _('%(err)s\n') % {'err': 'Query volume failed!' ' Invalid result code'} raise exception.VolumeBackendAPIException(data=msg) if query_volume_result['retcode'] == self.del_complete_code: return False if query_volume_result['retcode'] == '0': if 'volume0' not in query_volume_result: msg = _('%(err)s\n') % {'err': 'Query volume failed! ' 'Volume0 not exist!'} raise exception.VolumeBackendAPIException(data=msg) query_volume_result['volume0'] = \ storhyper_utils.generate_dict_from_result( query_volume_result['volume0']) if (('status' not in query_volume_result['volume0']) or (query_volume_result['volume0']['status'] not in ('1', '2', '10'))): msg = _('%(err)s\n') % {'err': 'Query volume failed!' ' Invalid volume status'} raise exception.VolumeBackendAPIException(data=msg) return True
def _is_volume_exist(self, volume_name): query_volume_result = self._query_volume(volume_name) if ( (not query_volume_result) or ("retcode" not in query_volume_result) or (query_volume_result["retcode"] not in ("0", self.del_complete_code)) ): msg = _("%(err)s\n") % {"err": "Query volume failed!" " Invalid result code"} raise exception.VolumeBackendAPIException(data=msg) if query_volume_result["retcode"] == self.del_complete_code: return False if query_volume_result["retcode"] == "0": if "volume0" not in query_volume_result: msg = _("%(err)s\n") % {"err": "Query volume failed! " "Volume0 not exist!"} raise exception.VolumeBackendAPIException(data=msg) query_volume_result["volume0"] = storhyper_utils.generate_dict_from_result(query_volume_result["volume0"]) if ("status" not in query_volume_result["volume0"]) or ( query_volume_result["volume0"]["status"] not in ("1", "2", "10") ): msg = _("%(err)s\n") % {"err": "Query volume failed!" " Invalid volume status"} raise exception.VolumeBackendAPIException(data=msg) return True
def _is_snapshot_exist(self, snapshot_name): query_snapshot_result = self._query_snapshot(snapshot_name) if ((not query_snapshot_result) or ('retcode' not in query_snapshot_result) or (query_snapshot_result['retcode'] not in ('0', self.del_complete_code))): msg = _('%(err)s\n') % {'err': 'Query snapshot failed!'} raise exception.VolumeBackendAPIException(data=msg) if query_snapshot_result['retcode'] == self.del_complete_code: return False if query_snapshot_result['retcode'] == '0': if 'snapshot0' not in query_snapshot_result: msg = _('%(err)s\n') % {'err': 'Query snapshot failed!'} raise exception.VolumeBackendAPIException(data=msg) query_snapshot_result['snapshot0'] =\ storhyper_utils.generate_dict_from_result( query_snapshot_result['snapshot0']) if (('status' not in query_snapshot_result['snapshot0']) or (query_snapshot_result['snapshot0']['status'] not in ('1', '2'))): msg = _('%(err)s\n') % {'err': 'Query snapshot failed!'} raise exception.VolumeBackendAPIException(data=msg) return True
def _is_snapshot_exist(self, snapshot_name): query_snapshot_result = self._query_snapshot(snapshot_name) if ( (not query_snapshot_result) or ("retcode" not in query_snapshot_result) or (query_snapshot_result["retcode"] not in ("0", self.del_complete_code)) ): msg = _("%(err)s\n") % {"err": "Query snapshot failed!"} raise exception.VolumeBackendAPIException(data=msg) if query_snapshot_result["retcode"] == self.del_complete_code: return False if query_snapshot_result["retcode"] == "0": if "snapshot0" not in query_snapshot_result: msg = _("%(err)s\n") % {"err": "Query snapshot failed!"} raise exception.VolumeBackendAPIException(data=msg) query_snapshot_result["snapshot0"] = storhyper_utils.generate_dict_from_result( query_snapshot_result["snapshot0"] ) if ("status" not in query_snapshot_result["snapshot0"]) or ( query_snapshot_result["snapshot0"]["status"] not in ("1", "2") ): msg = _("%(err)s\n") % {"err": "Query snapshot failed!"} raise exception.VolumeBackendAPIException(data=msg) return True
def test_generate_dict_from_result(self): result = utils.generate_dict_from_result("[stor_id=1638,iops=25]") self.assertEqual({'stor_id': '1638', 'iops': '25'}, result)