def setUp(self): super(TestS3ImageService, self).setUp() self.context = context.RequestContext(None, None) self.useFixture(fixtures.FakeLogger('boto')) # set up 3 fixtures to test shows, should have id '1', '2', and '3' db.s3_image_create(self.context, '155d900f-4e14-4e4c-a73d-069cbf4541e6') db.s3_image_create(self.context, 'a2459075-d96c-40d5-893e-577ff92e721c') db.s3_image_create(self.context, '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6') fake.stub_out_image_service(self.stubs) self.image_service = s3.S3ImageService() ec2utils.reset_cache()
def setUp(self): super(EC2ValidateTestCase, self).setUp() self.flags(compute_driver='patron.virt.fake.FakeDriver') 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() # Short-circuit the conductor service self.flags(use_local=True, group='conductor') # Stub out the notification service so we use the no-op serializer # and avoid lazy-load traces with the wrap_exception decorator in # the compute service. fake_notifier.stub_notifier(self.stubs) self.addCleanup(fake_notifier.reset) # set up services self.conductor = self.start_service('conductor', manager=CONF.conductor.manager) self.compute = self.start_service('compute') self.scheduter = self.start_service('scheduler') self.network = self.start_service('network') self.image_service = fake.FakeImageService() self.user_id = 'fake' self.project_id = 'fake' self.context = context.RequestContext(self.user_id, self.project_id, is_admin=True) self.EC2_MALFORMED_IDS = ['foobar', '', 123] self.EC2_VALID__IDS = ['i-284f3a41', 'i-001', 'i-deadbeef'] self.ec2_id_exception_map = [(x, exception.InvalidInstanceIDMalformed) for x in self.EC2_MALFORMED_IDS] self.ec2_id_exception_map.extend([(x, exception.InstanceNotFound) for x in self.EC2_VALID__IDS]) self.volume_id_exception_map = [(x, exception.InvalidVolumeIDMalformed) for x in self.EC2_MALFORMED_IDS] self.volume_id_exception_map.extend([(x, exception.VolumeNotFound) for x in self.EC2_VALID__IDS]) def fake_show(meh, context, id, **kwargs): return {'id': id, 'container_format': 'ami', '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(self, context, None) image['name'] = kwargs.get('name') return [image] fake.stub_out_image_service(self.stubs) self.stubs.Set(fake._FakeImageService, 'show', fake_show) self.stubs.Set(fake._FakeImageService, 'detail', fake_detail) 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')
def create(self): if self.obj_attr_is_set('id'): raise exception.ObjectActionError(action='create', reason='already created') db_s3imap = db.s3_image_create(self._context, self.uuid) self._from_db_object(self._context, self, db_s3imap)