Exemplo n.º 1
0
    def _validate_options():
        if not CONF.zvm.cloud_connector_url:
            error = _('Must specify cloud_connector_url in zvm config '
                      'group to use compute_driver=zvm.driver.ZVMDriver')
            raise exception.ZVMDriverException(error=error)

        # Try a test to ensure length of give guest is smaller than 8
        try:
            _test_instance = CONF.instance_name_template % 0
        except Exception:
            msg = _("Template is not usable, the template defined is "
                    "instance_name_template=%s") % CONF.instance_name_template
            raise exception.ZVMDriverException(error=msg)

        # For zVM instance, limit the maximum length of instance name to 8
        if len(_test_instance) > 8:
            msg = _("Can't spawn instance with template '%s', "
                    "The zVM hypervisor does not support instance names "
                    "longer than 8 characters. Please change your config of "
                    "instance_name_template.") % CONF.instance_name_template
            raise exception.ZVMDriverException(error=msg)
Exemplo n.º 2
0
    def test_snapshot_capture_fail(self, mock_capture, get_image_service):
        image_service = mock.Mock()
        image_id = 'e9ee1562-3ea1-4cb1-9f4c-f2033000eab1'
        get_image_service.return_value = (image_service, image_id)
        mock_capture.side_effect = exception.ZVMDriverException(error='error')

        self.assertRaises(exception.ZVMDriverException, self._driver.snapshot,
                          self._context, self._instance, image_id,
                          self.mock_update_task_state)

        self.mock_update_task_state.assert_called_once_with(
            task_state='image_pending_upload')
        image_service.delete.assert_called_once_with(self._context, image_id)