Ejemplo n.º 1
0
 def __init__(self, *args, **kwargs):
     """Init Disco driver : get configuration, create client."""
     super(DiscoDriver, self).__init__(*args, **kwargs)
     self.configuration.append_config_values(disco_opts)
     self.ctxt = context.get_admin_context()
     self.attach_detach_volume = (
         disco_attach_detach.AttachDetachDiscoVolume(self.configuration))
Ejemplo n.º 2
0
    def setUp(self):
        """Initialise variable common to all the test cases."""
        super(TestDISCODriver, self).setUp()

        mock_exec = mock.Mock()
        mock_exec.return_value = ('', '')
        self.cfg = mock.Mock(spec=conf.Configuration)
        self.cfg.disco_client = '127.0.0.1'
        self.cfg.disco_client_port = '9898'
        self.cfg.disco_wsdl_path = 'somewhere'
        self.cfg.volume_name_prefix = 'openstack-'
        self.cfg.num_volume_device_scan_tries = 1
        self.cfg.snapshot_check_timeout = 3600
        self.cfg.restore_check_timeout = 3600
        self.cfg.clone_check_timeout = 3600
        self.cfg.snapshot_reserve_days = -1
        self.cfg.retry_interval = 2
        self.cfg.num_volume_device_scan_tries = 3

        CONF = cfg.CONF
        CONF.choice_client = 'SOAP'
        CONF.rest_ip = '127.0.0.1'

        self.FAKE_RESPONSE = {
            'standard': {
                'success': {
                    'status': 0,
                    'result': 'a normal message'
                },
                'fail': {
                    'status': 1,
                    'result': 'an error message'
                }
            }
        }

        mock.patch.object(client, 'Client', self.create_client).start()

        mock.patch.object(disco_api, 'DiscoApi', self.create_client).start()

        mock.patch.object(connector.InitiatorConnector, 'factory',
                          self.get_mock_connector).start()

        self.driver = driver.DiscoDriver(execute=mock_exec,
                                         configuration=self.cfg)
        self.driver.do_setup(None)

        self.attach_detach = attach_detach.AttachDetachDiscoVolume()

        self.ctx = context.RequestContext('fake', 'fake', auth_token=True)
        self.volume = fake_volume.fake_volume_obj(self.ctx)
        self.volume['volume_id'] = '1234567'

        self.requester = self.driver.client
Ejemplo n.º 3
0
 def copy_volume_to_image(self, context, volume, image_service, image_meta):
     """Copy a  volume to a new image."""
     LOG.debug("Enter in copy image to volume for disco.")
     try:
         attach_detach_volume = (
             disco_attach_detach.AttachDetachDiscoVolume(
                 self.configuration))
         device_info = attach_detach_volume._attach_volume(volume)
         image_utils.upload_volume(context, image_service, image_meta,
                                   device_info['path'])
     finally:
         attach_detach_volume._detach_volume(volume)
Ejemplo n.º 4
0
    def copy_image_to_volume(self, context, volume, image_service, image_id):
        """Fetch the image from image_service and write it to the volume."""
        LOG.debug("Enter in copy image to volume for disco.")

        try:
            attach_detach_volume = (
                disco_attach_detach.AttachDetachDiscoVolume())
            device_info = attach_detach_volume._attach_volume(volume)
            image_utils.fetch_to_raw(context,
                                     image_service,
                                     image_id,
                                     device_info['path'],
                                     self.configuration.volume_dd_blocksize,
                                     size=volume['size'])
        finally:
            attach_detach_volume._detach_volume(volume)