Beispiel #1
0
 def setUp(self):
     super(SchedulerHintsTestCase, self).setUp()
     self.fake_instance = v2_fakes.create_fake_volume(fake.VOLUME_ID,
                                                      uuid=UUID)
     self.fake_instance['created_at'] =\
         datetime.datetime(2013, 1, 1, 1, 1, 1)
     self.fake_instance['launched_at'] =\
         datetime.datetime(2013, 1, 1, 1, 1, 1)
     self.flags(
         osapi_volume_extension=[
             'cinder.api.contrib.select_extensions'],
         osapi_volume_ext_list=['Scheduler_hints'])
     self.user_ctxt = context.RequestContext(
         fake.USER_ID, fake.PROJECT_ID, auth_token=True)
     self.app = fakes.wsgi_app(fake_auth_context=self.user_ctxt)
Beispiel #2
0
    def test_force_delete_snapshot(self, volume_get, snapshot_get, get_by_id,
                                   delete_snapshot):
        volume = v2_fakes.create_fake_volume(fake.VOLUME_ID)
        snapshot = v2_fakes.fake_snapshot(fake.SNAPSHOT_ID)
        snapshot_obj = fake_snapshot.fake_snapshot_obj(self.ctx, **snapshot)
        volume_get.return_value = volume
        snapshot_get.return_value = snapshot
        get_by_id.return_value = snapshot_obj

        path = '/v2/%s/snapshots/%s/action' % (fake.PROJECT_ID, snapshot['id'])
        req = webob.Request.blank(path)
        req.method = 'POST'
        req.headers['content-type'] = 'application/json'
        req.body = jsonutils.dump_as_bytes({'os-force_delete': {}})
        # attach admin context to request
        req.environ['cinder.context'] = self.ctx
        resp = req.get_response(app())
        self.assertEqual(202, resp.status_int)
Beispiel #3
0
 def fake_volume_get(self, context, volume_id, **kwargs):
     vol = v2_fakes.create_fake_volume(volume_id,
                                       encryption_key_id=fake.KEY_ID)
     return fake_volume.fake_volume_obj(context, **vol)
Beispiel #4
0
    def test_volume_show_with_admin_metadata(self):
        volume = v2_fakes.create_fake_volume(fake.VOLUME_ID)
        del volume['name']
        del volume['volume_type']
        del volume['volume_type_id']
        volume['metadata'] = {'key': 'value'}
        db.volume_create(context.get_admin_context(), volume)
        db.volume_admin_metadata_update(context.get_admin_context(),
                                        fake.VOLUME_ID, {
                                            "readonly": "True",
                                            "invisible_key": "invisible_value"
                                        }, False)
        values = {
            'volume_id': fake.VOLUME_ID,
        }
        attachment = db.volume_attach(context.get_admin_context(), values)
        db.volume_attached(context.get_admin_context(), attachment['id'],
                           fake.INSTANCE_ID, None, '/')

        req = fakes.HTTPRequest.blank('/v1/volumes/%s' % fake.VOLUME_ID)
        admin_ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
        req.environ['cinder.context'] = admin_ctx
        res_dict = self.controller.show(req, fake.VOLUME_ID)
        expected = {
            'volume': {
                'status':
                'in-use',
                'display_description':
                'displaydesc',
                'availability_zone':
                'fakeaz',
                'display_name':
                'displayname',
                'encrypted':
                False,
                'attachments': [{
                    'attachment_id': attachment['id'],
                    'device': '/',
                    'server_id': fake.INSTANCE_ID,
                    'host_name': None,
                    'id': fake.VOLUME_ID,
                    'volume_id': fake.VOLUME_ID
                }],
                'multiattach':
                'false',
                'bootable':
                'false',
                'volume_type':
                None,
                'snapshot_id':
                None,
                'source_volid':
                None,
                'metadata': {
                    'key': 'value',
                    'readonly': 'True'
                },
                'id':
                fake.VOLUME_ID,
                'created_at':
                datetime.datetime(1900,
                                  1,
                                  1,
                                  1,
                                  1,
                                  1,
                                  tzinfo=iso8601.iso8601.Utc()),
                'size':
                1
            }
        }
        self.assertEqual(expected, res_dict)
Beispiel #5
0
 def fake_volume_get(self, context, volume_id, **kwargs):
     vol = v2_fakes.create_fake_volume(
         volume_id, attach_status=fields.VolumeAttachStatus.DETACHED)
     return fake_volume.fake_volume_obj(context, **vol)