コード例 #1
0
ファイル: volumeops.py プロジェクト: hsluoyz/patron
 def _connect_to_volume_provider(self, connection_data, instance_name):
     sr_uuid, sr_label, sr_params = volume_utils.parse_sr_info(
             connection_data, 'Disk-for:%s' % instance_name)
     sr_ref = volume_utils.find_sr_by_uuid(self._session, sr_uuid)
     if not sr_ref:
         # introduce SR because not already present
         sr_ref = volume_utils.introduce_sr(
                 self._session, sr_uuid, sr_label, sr_params)
     return (sr_ref, sr_uuid)
コード例 #2
0
    def test_find_sr_invalid_uuid(self):
        class UUIDException(Exception):
            details = ["UUID_INVALID", "", "", ""]

        self.session = mock.Mock()
        self.session.XenAPI.Failure = UUIDException
        self.session.call_xenapi.side_effect = UUIDException
        self.assertIsNone(
            volume_utils.find_sr_by_uuid(self.session, 'sr_uuid'))
コード例 #3
0
 def _connect_to_volume_provider(self, connection_data, instance_name):
     sr_uuid, sr_label, sr_params = volume_utils.parse_sr_info(
         connection_data, 'Disk-for:%s' % instance_name)
     sr_ref = volume_utils.find_sr_by_uuid(self._session, sr_uuid)
     if not sr_ref:
         # introduce SR because not already present
         sr_ref = volume_utils.introduce_sr(self._session, sr_uuid,
                                            sr_label, sr_params)
     return (sr_ref, sr_uuid)
コード例 #4
0
 def test_find_sr_valid_uuid(self):
     self.session = mock.Mock()
     self.session.call_xenapi.return_value = 'sr_ref'
     self.assertEqual(volume_utils.find_sr_by_uuid(self.session,
                                                   'sr_uuid'),
                      'sr_ref')