Ejemplo n.º 1
0
 def test_parse_volume_info_raise_exception(self):
     """This shows how to test helper classes' methods."""
     stubs.stubout_session(self.stubs, stubs.FakeSessionForVolumeTests)
     session = xenapi_conn.XenAPISession('test_url', 'root', 'test_pass')
     helper = volume_utils.VolumeHelper
     helper.XenAPI = session.get_imported_xenapi()
     vol = self._create_volume()
     # oops, wrong mount point!
     self.assertRaises(volume_utils.StorageError, helper.parse_volume_info,
                       vol['id'], '/dev/sd')
     db.volume_destroy(context.get_admin_context(), vol['id'])
Ejemplo n.º 2
0
 def test_create_iscsi_storage(self):
     """This shows how to test helper classes' methods."""
     stubs.stubout_session(self.stubs, stubs.FakeSessionForVolumeTests)
     session = xenapi_conn.XenAPISession('test_url', 'root', 'test_pass')
     helper = volume_utils.VolumeHelper
     helper.XenAPI = session.get_imported_xenapi()
     vol = self._create_volume()
     info = helper.parse_volume_info(vol['id'], '/dev/sdc')
     label = 'SR-%s' % vol['id']
     description = 'Test-SR'
     sr_ref = helper.create_iscsi_storage(session, info, label, description)
     srs = xenapi_fake.get_all('SR')
     self.assertEqual(sr_ref, srs[0])
     db.volume_destroy(context.get_admin_context(), vol['id'])
Ejemplo n.º 3
0
Archivo: xensm.py Proyecto: altai/nova
    def __init__(self, *args, **kwargs):
        """Connect to the hypervisor."""

        # This driver leverages Xen storage manager, and hence requires
        # hypervisor to be Xen
        if FLAGS.connection_type != 'xenapi':
            raise exception.Error(_('XenSMDriver requires xenapi connection'))

        url = FLAGS.xenapi_connection_url
        username = FLAGS.xenapi_connection_username
        password = FLAGS.xenapi_connection_password
        try:
            session = xenapi_conn.XenAPISession(url, username, password)
            self._volumeops = volumeops.VolumeOps(session)
        except Exception as ex:
            LOG.exception(ex)
            raise exception.Error(_("Failed to initiate session"))

        super(XenSMDriver, self).__init__(execute=utils.execute,
                                          sync_exec=utils.execute,
                                          *args,
                                          **kwargs)
Ejemplo n.º 4
0
 def _list_vdis(self):
     url = FLAGS.xenapi_connection_url
     username = FLAGS.xenapi_connection_username
     password = FLAGS.xenapi_connection_password
     session = xenapi_conn.XenAPISession(url, username, password)
     return session.call_xenapi('VDI.get_all')