コード例 #1
0
ファイル: huaweistorac.py プロジェクト: sasimpson/cinder
 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
コード例 #2
0
ファイル: huaweistorac.py プロジェクト: NxtCloud/cinder
 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
コード例 #3
0
ファイル: huaweistorac.py プロジェクト: NeCTAR-RC/cinder
 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
コード例 #4
0
ファイル: huaweistorac.py プロジェクト: sasimpson/cinder
 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
コード例 #5
0
ファイル: huaweistorac.py プロジェクト: NxtCloud/cinder
 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
コード例 #6
0
ファイル: huaweistorac.py プロジェクト: NeCTAR-RC/cinder
 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
コード例 #7
0
 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)
コード例 #8
0
ファイル: test_huaweistorac.py プロジェクト: NeCTAR-RC/cinder
 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)