Exemple #1
0
    def setUp(self):
        super(CinderCloudTestCase, self).setUp()
        vol_tmpdir = tempfile.mkdtemp()
        self.flags(compute_driver='nova.virt.fake.FakeDriver',
                   volume_api_class='nova.tests.fake_volume.API')

        def fake_show(meh, context, id):
            return {
                'id': id,
                'name': 'fake_name',
                'container_format': 'ami',
                'status': 'active',
                'properties': {
                    'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
                    'ramdisk_id': 'cedef40a-ed67-4d10-800e-17455edce175',
                    'type': 'machine',
                    'image_state': 'available'
                }
            }

        def fake_detail(_self, context, **kwargs):
            image = fake_show(None, context, None)
            image['name'] = kwargs.get('filters', {}).get('name')
            return [image]

        self.stubs.Set(fake._FakeImageService, 'show', fake_show)
        self.stubs.Set(fake._FakeImageService, 'detail', fake_detail)
        fake.stub_out_image_service(self.stubs)

        def dumb(*args, **kwargs):
            pass

        self.stubs.Set(compute_utils, 'notify_about_instance_usage', dumb)
        fake_network.set_stub_network_methods(self.stubs)

        # set up our cloud
        self.cloud = cloud.CloudController()
        self.flags(scheduler_driver='nova.scheduler.chance.ChanceScheduler')

        # set up services
        self.compute = self.start_service('compute')
        self.scheduler = self.start_service('scheduler')
        self.network = self.start_service('network')

        self.user_id = 'fake'
        self.project_id = 'fake'
        self.context = context.RequestContext(self.user_id,
                                              self.project_id,
                                              is_admin=True)
        self.volume_api = volume.API()

        # NOTE(comstud): Make 'cast' behave like a 'call' which will
        # ensure that operations complete
        self.stubs.Set(rpc, 'cast', rpc.call)

        # make sure we can map ami-00000001/2 to a uuid in FakeImageService
        db.api.s3_image_create(self.context,
                               'cedef40a-ed67-4d10-800e-17455edce175')
        db.api.s3_image_create(self.context,
                               '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6')
Exemple #2
0
    def setUp(self):
        super(VsaTestCase, self).setUp()
        self.stubs = stubout.StubOutForTesting()
        self.vsa_api = vsa.API()
        self.volume_api = volume.API()

        FLAGS.quota_volumes = 100
        FLAGS.quota_gigabytes = 10000

        self.context = context.get_admin_context()

        volume_types.create(self.context,
                            'SATA_500_7200',
                            extra_specs={
                                'type': 'vsa_drive',
                                'drive_name': 'SATA_500_7200',
                                'drive_type': 'SATA',
                                'drive_size': '500',
                                'drive_rpm': '7200'
                            })

        def fake_show_by_name(meh, context, name):
            if name == 'wrong_image_name':
                LOG.debug(_("Test: Emulate wrong VSA name. Raise"))
                raise exception.ImageNotFound
            return {'id': 1, 'properties': {'kernel_id': 1, 'ramdisk_id': 1}}

        self.stubs.Set(nova.image.fake._FakeImageService, 'show_by_name',
                       fake_show_by_name)
Exemple #3
0
 def test_too_many_gigabytes(self):
     volume_ids = []
     volume_id = self._create_volume(size=20)
     volume_ids.append(volume_id)
     self.assertRaises(exception.QuotaError,
                       volume.API().create, self.context, 10, '', '', None)
     for volume_id in volume_ids:
         db.volume_destroy(self.context, volume_id)
Exemple #4
0
 def __init__(self):
     self.image_service = s3.S3ImageService()
     self.network_api = network.API()
     self.volume_api = volume.API()
     self.compute_api = compute.API(network_api=self.network_api,
                                    volume_api=self.volume_api,
                                    hostname_factory=ec2utils.id_to_ec2_id)
     self.setup()
Exemple #5
0
 def test_too_many_volumes(self):
     volume_ids = []
     for i in range(FLAGS.quota_volumes):
         volume_id = self._create_volume()
         volume_ids.append(volume_id)
     self.assertRaises(exception.QuotaError,
                       volume.API().create, self.context, 10, '', '', None)
     for volume_id in volume_ids:
         db.volume_destroy(self.context, volume_id)
Exemple #6
0
def terminate_volumes(db, context, instance_id):
    """delete volumes of delete_on_termination=True in block device mapping"""
    volume_api = volume.API()
    for bdm in db.block_device_mapping_get_all_by_instance(
            context, instance_id):
        #LOG.debug(_("terminating bdm %s") % bdm)
        if bdm['volume_id'] and bdm['delete_on_termination']:
            volume_api.delete(context, bdm['volume_id'])
        db.block_device_mapping_destroy(context, bdm['id'])
Exemple #7
0
 def __init__(self,context,instance,availability_zone): 
     threading.Thread.__init__(self)
     self.context = context
     self.instance = instance
     #self.flavor_id = flavor_id
     self.availability_zone = availability_zone
     self.compute_api = compute.API()
     self.host_api = compute.HostAPI()
     self.image_api = nova.image.API()
     #self.ext_mgr = ext_mgr
     self.volume_api = volume.API()
Exemple #8
0
 def test_too_many_gigabytes(self):
     volume_ids = []
     volume_id = self._create_volume(size=20)
     volume_ids.append(volume_id)
     self.assertRaises(quota.QuotaError,
                       volume.API().create,
                       self.context,
                       size=10,
                       name='',
                       description='')
     for volume_id in volume_ids:
         db.volume_destroy(self.context, volume_id)
Exemple #9
0
 def test_too_many_volumes(self):
     volume_ids = []
     for i in range(FLAGS.quota_volumes):
         volume_id = self._create_volume()
         volume_ids.append(volume_id)
     self.assertRaises(quota.QuotaError,
                       volume.API().create,
                       self.context,
                       size=10,
                       name='',
                       description='')
     for volume_id in volume_ids:
         db.volume_destroy(self.context, volume_id)
Exemple #10
0
    def __init__(self, vsa_driver=None, *args, **kwargs):
        if not vsa_driver:
            vsa_driver = FLAGS.vsa_driver
        self.driver = utils.import_object(vsa_driver)
        self.compute_manager = utils.import_object(FLAGS.compute_manager)

        self.compute_api = compute.API()
        self.volume_api = volume.API()
        self.vsa_api = vsa.API()

        if FLAGS.vsa_ec2_user_id is None or FLAGS.vsa_ec2_access_key is None:
            raise exception.VSANovaAccessParamNotFound()

        super(VsaManager, self).__init__(*args, **kwargs)
Exemple #11
0
    def setUp(self):
        super(DirectCloudTestCase, self).setUp()
        compute_handle = compute.API(image_service=self.cloud.image_service)
        volume_handle = volume.API()
        network_handle = network.API()
        direct.register_service('compute', compute_handle)
        direct.register_service('volume', volume_handle)
        direct.register_service('network', network_handle)

        self.router = direct.JsonParamsMiddleware(direct.Router())
        proxy = direct.Proxy(self.router)
        self.cloud.compute_api = proxy.compute
        self.cloud.volume_api = proxy.volume
        self.cloud.network_api = proxy.network
        compute_handle.volume_api = proxy.volume
        compute_handle.network_api = proxy.network
Exemple #12
0
    def setUp(self):
        super(VsaVolumesTestCase, self).setUp()
        self.vsa_api = vsa.API()
        self.volume_api = volume.API()
        self.context = context.get_admin_context()

        self.default_vol_type = self.vsa_api.get_vsa_volume_type(self.context)

        def fake_show_by_name(meh, context, name):
            return {'id': 1, 'properties': {'kernel_id': 1, 'ramdisk_id': 1}}

        self.stubs.Set(nova.image.fake._FakeImageService, 'show_by_name',
                       fake_show_by_name)

        param = {'display_name': 'VSA name test'}
        vsa_ref = self.vsa_api.create(self.context, **param)
        self.vsa_id = vsa_ref['id']
Exemple #13
0
 def __init__(self,
              image_service=None,
              network_api=None,
              volume_api=None,
              hostname_factory=generate_default_hostname,
              **kwargs):
     if not image_service:
         image_service = utils.import_object(FLAGS.image_service)
     self.image_service = image_service
     if not network_api:
         network_api = network.API()
     self.network_api = network_api
     if not volume_api:
         volume_api = volume.API()
     self.volume_api = volume_api
     self.hostname_factory = hostname_factory
     super(API, self).__init__(**kwargs)
Exemple #14
0
 def __init__(self):
     self.compute_api = compute.API(network_api=network.API(),
                                    volume_api=volume.API())
Exemple #15
0
 def __init__(self, *args, **kwargs):
     super(ExtendedVolumesController, self).__init__(*args, **kwargs)
     self.compute_api = compute.API(skip_policy_check=True)
     self.volume_api = volume.API()
Exemple #16
0
 def __init__(self, ext_mgr=None):
     self.compute_api = compute.API()
     self.volume_api = volume.API()
     self.ext_mgr = ext_mgr
     super(VolumeAttachmentController, self).__init__()
Exemple #17
0
 def __init__(self, *args, **kwargs):
     super(AdminController, self).__init__(*args, **kwargs)
     # singular name of the resource
     self.resource_name = self.collection.rstrip('s')
     self.volume_api = volume.API()
Exemple #18
0
 def __init__(self):
     self.compute_api = compute.API(skip_policy_check=True)
     self.volume_api = volume.API()
     super(VolumeAttachmentController, self).__init__()
Exemple #19
0
    location = kwargs.get('control_location', None)
    if location and location.lower() == 'front-end':  # case insensitive
        provider = kwargs.get('provider')

        try:
            encryptor = importutils.import_object(provider, connection_info,
                                                  **kwargs)
        except Exception as e:
            LOG.error(_("Error instantiating %(provider)s: %(exception)s"),
                      provider=provider, exception=e)
            raise

    return encryptor


_volume_api = volume.API()


def get_encryption_metadata(context, volume_id, connection_info):
    metadata = {}
    if ('data' in connection_info and
            connection_info['data'].get('encrypted', False)):
        try:
            metadata = _volume_api.get_volume_encryption_metadata(context,
                                                                 volume_id)
        except Exception as e:
            LOG.error(_("Failed to retrieve encryption metadata for "
                            "volume %(volume_id)s: %(exception)s"),
                          {'volume_id': volume_id, 'exception': e})
            raise
Exemple #20
0
 def __init__(self):
     self.volume_api = volume.API()
     self.vsa_api = vsa.API()
     super(VsaVolumeDriveController, self).__init__()
 def __init__(self, *args, **kwargs):
     super(ExtendedVolumesController, self).__init__(*args, **kwargs)
     self.compute_api = compute.API()
     self.volume_api = volume.API()
Exemple #22
0
 def __init__(self, *args, **kwargs):
     super(VolumeActionsController, self).__init__(*args, **kwargs)
     self.volume_api = volume.API()
Exemple #23
0
 def __init__(self):
     self.volume_api = volume.API()
     super(SnapshotController, self).__init__()
Exemple #24
0
 def __init__(self, ext_mgr):
     self.volume_api = volume.API()
     self.ext_mgr = ext_mgr
     super(VolumeController, self).__init__()
Exemple #25
0
 def __init__(self, fc_client, task_ops):
     super(VolumeOps, self).__init__(fc_client, task_ops)
     self._volume_api = volume.API()
Exemple #26
0
 def __init__(self, compute_api=None, volume_api=None, **kwargs):
     self.compute_api = compute_api or compute.API()
     self.volume_api = volume_api or volume.API()
     super(API, self).__init__(**kwargs)
Exemple #27
0
 def __init__(self):
     self.compute_api = compute.API()
     self.volume_api = volume.API()
     super(VolumeAttachmentController, self).__init__()
Exemple #28
0
 def set_up(self):
     """Sets up the client."""
     test_config.compute_service.stop()
     assert_false(test_config.compute_service.is_running)
     self.init("TEST_FAIL_VOLUME_")
     self.volume_api = volume.API()
Exemple #29
0
 def __init__(self):
     self.volume_api = volume.API()
     super(VolumeController, self).__init__()
Exemple #30
0
    def setUp(self):
        super(CinderCloudTestCase, self).setUp()
        ec2utils.reset_cache()
        vol_tmpdir = self.useFixture(fixtures.TempDir()).path
        fake_utils.stub_out_utils_spawn_n(self.stubs)
        self.flags(compute_driver='nova.virt.fake.FakeDriver',
                   volume_api_class='nova.tests.fake_volume.API')

        def fake_show(meh, context, id):
            return {
                'id': id,
                'name': 'fake_name',
                'container_format': 'ami',
                'status': 'active',
                'properties': {
                    'kernel_id': 'cedef40a-ed67-4d10-800e-17455edce175',
                    'ramdisk_id': 'cedef40a-ed67-4d10-800e-17455edce175',
                    'type': 'machine',
                    'image_state': 'available'
                }
            }

        def fake_detail(_self, context, **kwargs):
            image = fake_show(None, context, None)
            image['name'] = kwargs.get('filters', {}).get('name')
            return [image]

        self.stubs.Set(fake._FakeImageService, 'show', fake_show)
        self.stubs.Set(fake._FakeImageService, 'detail', fake_detail)
        fake.stub_out_image_service(self.stubs)

        def dumb(*args, **kwargs):
            pass

        self.stubs.Set(compute_utils, 'notify_about_instance_usage', dumb)
        fake_network.set_stub_network_methods(self.stubs)

        # set up our cloud
        self.cloud = cloud.CloudController()
        self.flags(scheduler_driver='nova.scheduler.chance.ChanceScheduler')

        # Short-circuit the conductor service
        self.flags(use_local=True, group='conductor')

        # set up services
        self.conductor = self.start_service('conductor',
                                            manager=CONF.conductor.manager)
        self.compute = self.start_service('compute')
        self.scheduler = self.start_service('scheduler')
        self.network = self.start_service('network')
        self.consoleauth = self.start_service('consoleauth')

        self.user_id = 'fake'
        self.project_id = 'fake'
        self.context = context.RequestContext(self.user_id,
                                              self.project_id,
                                              is_admin=True)
        self.volume_api = volume.API()
        self.volume_api.reset_fake_api(self.context)

        self.useFixture(cast_as_call.CastAsCall(self.stubs))

        # make sure we can map ami-00000001/2 to a uuid in FakeImageService
        db.s3_image_create(self.context,
                           'cedef40a-ed67-4d10-800e-17455edce175')
        db.s3_image_create(self.context,
                           '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6')