def setUp(self):
        super(ServerActionsControllerTest, self).setUp()

        CONF.set_override('glance_host', 'localhost')
        self.stubs.Set(db, 'instance_get_by_uuid',
                       fakes.fake_instance_get(vm_state=vm_states.ACTIVE,
                                               host='fake_host'))
        self.stubs.Set(db, 'instance_update_and_get_original',
                       instance_update_and_get_original)

        fakes.stub_out_glance(self.stubs)
        fakes.stub_out_nw_api(self.stubs)
        fakes.stub_out_compute_api_snapshot(self.stubs)
        fake.stub_out_image_service(self.stubs)
        service_class = 'nova.image.glance.GlanceImageService'
        self.service = importutils.import_object(service_class)
        self.sent_to_glance = {}
        fakes.stub_out_glanceclient_create(self.stubs, self.sent_to_glance)
        self.flags(allow_instance_snapshots=True,
                   enable_instance_password=True)
        self.uuid = FAKE_UUID
        self.url = '/servers/%s/action' % self.uuid
        self._image_href = '155d900f-4e14-4e4c-a73d-069cbf4541e6'

        ext_info = plugins.LoadedExtensionInfo()
        self.controller = servers.ServersController(extension_info=ext_info)
        self.compute_api = self.controller.compute_api
        self.context = context.RequestContext('fake', 'fake')
        self.app = fakes.wsgi_app_v3(init_only=('servers',),
                                     fake_auth_context=self.context)
Example #2
0
    def setUp(self):
        super(ServerActionsControllerTest, self).setUp()

        self.stubs.Set(nova.db, 'instance_get_by_uuid',
                       fakes.fake_instance_get(vm_state=vm_states.ACTIVE,
                                               host='fake_host'))
        self.stubs.Set(nova.db, 'instance_update_and_get_original',
                       instance_update)

        fakes.stub_out_glance(self.stubs)
        fakes.stub_out_nw_api(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)
        fakes.stub_out_compute_api_snapshot(self.stubs)
        nova.tests.image.fake.stub_out_image_service(self.stubs)
        service_class = 'nova.image.glance.GlanceImageService'
        self.service = importutils.import_object(service_class)
        self.sent_to_glance = {}
        fakes.stub_out_glanceclient_create(self.stubs, self.sent_to_glance)
        self.flags(allow_instance_snapshots=True,
                   enable_instance_password=True)
        self.uuid = FAKE_UUID
        self.url = '/v2/fake/servers/%s/action' % self.uuid
        self._image_href = '155d900f-4e14-4e4c-a73d-069cbf4541e6'

        self.controller = servers.Controller()
Example #3
0
    def setUp(self):
        super(ServerActionsControllerTest, self).setUp()

        self.stubs.Set(db, "instance_get_by_uuid", fakes.fake_instance_get(vm_state=vm_states.ACTIVE, host="fake_host"))
        self.stubs.Set(db, "instance_update_and_get_original", instance_update_and_get_original)

        fakes.stub_out_glance(self.stubs)
        fakes.stub_out_nw_api(self.stubs)
        fakes.stub_out_compute_api_snapshot(self.stubs)
        fake.stub_out_image_service(self.stubs)
        service_class = "nova.image.glance.GlanceImageService"
        self.service = importutils.import_object(service_class)
        self.sent_to_glance = {}
        fakes.stub_out_glanceclient_create(self.stubs, self.sent_to_glance)
        self.flags(allow_instance_snapshots=True, enable_instance_password=True)
        self.uuid = FAKE_UUID
        self.url = "/v2/fake/servers/%s/action" % self.uuid
        self._image_href = "155d900f-4e14-4e4c-a73d-069cbf4541e6"

        class FakeExtManager(object):
            def is_loaded(self, ext):
                return False

        self.controller = servers.Controller(ext_mgr=FakeExtManager())
        self.compute_api = self.controller.compute_api
        self.context = context.RequestContext("fake", "fake")
        self.app = fakes.wsgi_app(init_only=("servers",), fake_auth_context=self.context)
Example #4
0
    def setUp(self):
        self.maxDiff = None
        super(ServerActionsControllerTest, self).setUp()

        self.stubs = stubout.StubOutForTesting()
        fakes.stub_out_auth(self.stubs)
        self.stubs.Set(nova.db, 'instance_get_by_uuid',
                fakes.fake_instance_get(vm_state=vm_states.ACTIVE,
                        host='fake_host'))
        self.stubs.Set(nova.db, 'instance_update', instance_update)

        fakes.stub_out_glance(self.stubs)
        fakes.stub_out_nw_api(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)
        fakes.stub_out_compute_api_snapshot(self.stubs)
        fakes.stub_out_image_service(self.stubs)
        service_class = 'nova.image.glance.GlanceImageService'
        self.service = utils.import_object(service_class)
        self.context = context.RequestContext(1, None)
        self.service.delete_all()
        self.sent_to_glance = {}
        fakes.stub_out_glance_add_image(self.stubs, self.sent_to_glance)
        self.flags(allow_instance_snapshots=True,
                   enable_instance_password=True)
        self.uuid = FAKE_UUID
        self.url = '/v2/fake/servers/%s/action' % self.uuid
        self._image_href = '155d900f-4e14-4e4c-a73d-069cbf4541e6'

        self.controller = servers.Controller()
Example #5
0
    def setUp(self):
        self.maxDiff = None
        super(ServerActionsControllerTest, self).setUp()

        self.stubs = stubout.StubOutForTesting()
        fakes.stub_out_auth(self.stubs)
        self.stubs.Set(nova.db, 'instance_get', return_server_by_id)
        self.stubs.Set(nova.db, 'instance_get_by_uuid', return_server_by_uuid)
        self.stubs.Set(nova.db, 'instance_update', instance_update)

        fakes.stub_out_glance(self.stubs)
        fakes.stub_out_nw_api(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)
        self.snapshot = fakes.stub_out_compute_api_snapshot(self.stubs)
        self.backup = fakes.stub_out_compute_api_backup(self.stubs)
        service_class = 'nova.image.glance.GlanceImageService'
        self.service = utils.import_object(service_class)
        self.context = context.RequestContext(1, None)
        self.service.delete_all()
        self.sent_to_glance = {}
        fakes.stub_out_glance_add_image(self.stubs, self.sent_to_glance)
        self.flags(allow_instance_snapshots=True)
        self.uuid = FAKE_UUID
        self.url = '/v2/fake/servers/%s/action' % self.uuid

        self.controller = servers.Controller()
Example #6
0
    def setUp(self):
        self.maxDiff = None
        super(ServerActionsControllerTest, self).setUp()

        self.stubs = stubout.StubOutForTesting()
        fakes.stub_out_auth(self.stubs)
        self.stubs.Set(nova.db, 'instance_get', return_server_by_id)
        self.stubs.Set(nova.db, 'instance_get_by_uuid', return_server_by_uuid)
        self.stubs.Set(nova.db, 'instance_update', instance_update)

        fakes.stub_out_glance(self.stubs)
        fakes.stub_out_nw_api(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)
        self.snapshot = fakes.stub_out_compute_api_snapshot(self.stubs)
        self.backup = fakes.stub_out_compute_api_backup(self.stubs)
        service_class = 'nova.image.glance.GlanceImageService'
        self.service = utils.import_object(service_class)
        self.context = context.RequestContext(1, None)
        self.service.delete_all()
        self.sent_to_glance = {}
        fakes.stub_out_glance_add_image(self.stubs, self.sent_to_glance)
        self.flags(allow_instance_snapshots=True)
        self.uuid = FAKE_UUID
        self.url = '/v1.1/fake/servers/%s/action' % self.uuid

        self.controller = servers.Controller()
Example #7
0
    def setUp(self):
        self.maxDiff = None
        super(ServerActionsControllerTest, self).setUp()

        self.stubs = stubout.StubOutForTesting()
        fakes.stub_out_auth(self.stubs)
        self.stubs.Set(
            nova.db, 'instance_get_by_uuid',
            fakes.fake_instance_get(vm_state=vm_states.ACTIVE,
                                    host='fake_host'))
        self.stubs.Set(nova.db, 'instance_update', instance_update)

        fakes.stub_out_glance(self.stubs)
        fakes.stub_out_nw_api(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)
        fakes.stub_out_compute_api_snapshot(self.stubs)
        fakes.stub_out_image_service(self.stubs)
        service_class = 'nova.image.glance.GlanceImageService'
        self.service = utils.import_object(service_class)
        self.context = context.RequestContext(1, None)
        self.service.delete_all()
        self.sent_to_glance = {}
        fakes.stub_out_glance_add_image(self.stubs, self.sent_to_glance)
        self.flags(allow_instance_snapshots=True,
                   enable_instance_password=True)
        self.uuid = FAKE_UUID
        self.url = '/v2/fake/servers/%s/action' % self.uuid
        self._image_href = '155d900f-4e14-4e4c-a73d-069cbf4541e6'

        self.controller = servers.Controller()
Example #8
0
    def setUp(self):
        super(ServerActionsControllerTest, self).setUp()

        self.stubs.Set(
            db, 'instance_get_by_uuid',
            fakes.fake_instance_get(vm_state=vm_states.ACTIVE,
                                    host='fake_host'))
        self.stubs.Set(db, 'instance_update_and_get_original', instance_update)

        fakes.stub_out_glance(self.stubs)
        fakes.stub_out_nw_api(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)
        fakes.stub_out_compute_api_snapshot(self.stubs)
        fake.stub_out_image_service(self.stubs)
        service_class = 'nova.image.glance.GlanceImageService'
        self.service = importutils.import_object(service_class)
        self.sent_to_glance = {}
        fakes.stub_out_glanceclient_create(self.stubs, self.sent_to_glance)
        self.flags(allow_instance_snapshots=True,
                   enable_instance_password=True)
        self.uuid = FAKE_UUID
        self.url = '/v2/fake/servers/%s/action' % self.uuid
        self._image_href = '155d900f-4e14-4e4c-a73d-069cbf4541e6'

        self.controller = servers.Controller()
Example #9
0
 def setUp(self):
     super(ImageMetaDataTest, self).setUp()
     self.flags(image_service='nova.image.glance.GlanceImageService')
     # NOTE(dprince) max out properties/metadata in image 3 for testing
     img3 = self.IMAGE_FIXTURES[2]
     for num in range(FLAGS.quota_metadata_items):
         img3['properties']['key%i' % num] = "blah"
     fakes.stub_out_glance(self.stubs, self.IMAGE_FIXTURES)
Example #10
0
 def setUp(self):
     self.stubs = stubout.StubOutForTesting()
     fakes.stub_out_glance(self.stubs)
     fakes.stub_out_compute_api_snapshot(self.stubs)
     service_class = 'nova.image.glance.GlanceImageService'
     self.service = utils.import_object(service_class)
     self.context = context.RequestContext(None, None)
     self.service.delete_all()
Example #11
0
 def setUp(self):
     super(ImageMetaDataTest, self).setUp()
     self.flags(image_service='nova.image.glance.GlanceImageService')
     # NOTE(dprince) max out properties/metadata in image 3 for testing
     img3 = self.IMAGE_FIXTURES[2]
     for num in range(FLAGS.quota_metadata_items):
         img3['properties']['key%i' % num] = "blah"
     fakes.stub_out_glance(self.stubs, self.IMAGE_FIXTURES)
Example #12
0
 def setUp(self):
     super(GlanceImageServiceTest, self).setUp()
     self.stubs = stubout.StubOutForTesting()
     fakes.stub_out_glance(self.stubs)
     fakes.stub_out_compute_api_snapshot(self.stubs)
     service_class = 'nova.image.glance.GlanceImageService'
     self.service = utils.import_object(service_class)
     self.context = context.RequestContext(None, None)
     self.service.delete_all()
Example #13
0
 def setUp(self):
     """Run before each test."""
     super(ImagesTest, self).setUp()
     self.stubs = stubout.StubOutForTesting()
     fakes.stub_out_networking(self.stubs)
     fakes.stub_out_rate_limiting(self.stubs)
     fakes.stub_out_key_pair_funcs(self.stubs)
     fakes.stub_out_compute_api_snapshot(self.stubs)
     fakes.stub_out_compute_api_backup(self.stubs)
     fakes.stub_out_glance(self.stubs)
Example #14
0
    def setUp(self):
        """Run before each test."""
        super(ImagesControllerTest, self).setUp()
        fakes.stub_out_networking(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)
        fakes.stub_out_key_pair_funcs(self.stubs)
        fakes.stub_out_compute_api_snapshot(self.stubs)
        fakes.stub_out_compute_api_backup(self.stubs)
        fakes.stub_out_glance(self.stubs)

        self.controller = images.Controller()
Example #15
0
 def setUp(self):
     self.orig_image_service = FLAGS.image_service
     FLAGS.image_service = 'nova.image.glance.GlanceImageService'
     self.stubs = stubout.StubOutForTesting()
     fakes.FakeAuthManager.auth_data = {}
     fakes.FakeAuthDatabase.data = {}
     fakes.stub_out_networking(self.stubs)
     fakes.stub_out_rate_limiting(self.stubs)
     fakes.stub_out_auth(self.stubs)
     fakes.stub_out_key_pair_funcs(self.stubs)
     fakes.stub_out_glance(self.stubs, initial_fixtures=self.IMAGE_FIXTURES)
Example #16
0
    def setUp(self):
        """Run before each test."""
        super(ImagesControllerTest, self).setUp()
        fakes.stub_out_networking(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)
        fakes.stub_out_key_pair_funcs(self.stubs)
        fakes.stub_out_compute_api_snapshot(self.stubs)
        fakes.stub_out_compute_api_backup(self.stubs)
        fakes.stub_out_glance(self.stubs)

        self.controller = images.Controller()
Example #17
0
 def setUp(self):
     super(ImageControllerWithGlanceServiceTest, self).setUp()
     self.orig_image_service = FLAGS.image_service
     FLAGS.image_service = "nova.image.glance.GlanceImageService"
     self.stubs = stubout.StubOutForTesting()
     fakes.FakeAuthManager.reset_fake_data()
     fakes.FakeAuthDatabase.data = {}
     fakes.stub_out_networking(self.stubs)
     fakes.stub_out_rate_limiting(self.stubs)
     fakes.stub_out_auth(self.stubs)
     fakes.stub_out_key_pair_funcs(self.stubs)
     fakes.stub_out_glance(self.stubs, initial_fixtures=self.IMAGE_FIXTURES)
Example #18
0
 def setUp(self):
     super(ImageControllerWithGlanceServiceTest, self).setUp()
     self.orig_image_service = FLAGS.image_service
     FLAGS.image_service = 'nova.image.glance.GlanceImageService'
     self.stubs = stubout.StubOutForTesting()
     fakes.FakeAuthManager.reset_fake_data()
     fakes.FakeAuthDatabase.data = {}
     fakes.stub_out_networking(self.stubs)
     fakes.stub_out_rate_limiting(self.stubs)
     fakes.stub_out_auth(self.stubs)
     fakes.stub_out_key_pair_funcs(self.stubs)
     fakes.stub_out_glance(self.stubs, initial_fixtures=self.IMAGE_FIXTURES)
Example #19
0
 def setUp(self):
     super(ImageMetaDataTest, self).setUp()
     self.stubs = stubout.StubOutForTesting()
     self.orig_image_service = FLAGS.image_service
     FLAGS.image_service = 'nova.image.glance.GlanceImageService'
     fakes.FakeAuthManager.auth_data = {}
     fakes.FakeAuthDatabase.data = {}
     fakes.stub_out_auth(self.stubs)
     # NOTE(dprince) max out properties/metadata in image 3 for testing
     img3 = self.IMAGE_FIXTURES[2]
     for num in range(FLAGS.quota_metadata_items):
         img3['properties']['key%i' % num] = "blah"
     fakes.stub_out_glance(self.stubs, self.IMAGE_FIXTURES)
 def setUp(self):
     super(ImageMetaDataTest, self).setUp()
     self.stubs = stubout.StubOutForTesting()
     self.orig_image_service = FLAGS.image_service
     FLAGS.image_service = 'nova.image.glance.GlanceImageService'
     fakes.FakeAuthManager.auth_data = {}
     fakes.FakeAuthDatabase.data = {}
     fakes.stub_out_auth(self.stubs)
     # NOTE(dprince) max out properties/metadata in image 3 for testing
     img3 = self.IMAGE_FIXTURES[2]
     for num in range(FLAGS.quota_metadata_items):
         img3['properties']['key%i' % num] = "blah"
     fakes.stub_out_glance(self.stubs, self.IMAGE_FIXTURES)
Example #21
0
    def test_image_get_disk_config_no_image_fails(self):
        self.flags(image_service='nova.image.glance.GlanceImageService')
        fakes.stub_out_glance(self.stubs)

        def fake_image_service_show(*args, **kwargs):
            raise exception.NotFound()

        self.stubs.Set(image.glance.GlanceImageService, 'show',
                       fake_image_service_show)

        req = webob.Request.blank('/v1.1/openstack/images/10/os-disk-config')
        req.headers['Accept'] = 'application/json'
        res = req.get_response(fakes.wsgi_app())
        self.assertEqual(res.status_int, 404)
Example #22
0
 def setUp(self):
     """Run before each test."""
     super(ImageControllerWithGlanceServiceTest, self).setUp()
     self.orig_image_service = FLAGS.image_service
     FLAGS.image_service = 'nova.image.glance.GlanceImageService'
     self.stubs = stubout.StubOutForTesting()
     fakes.FakeAuthManager.reset_fake_data()
     fakes.FakeAuthDatabase.data = {}
     fakes.stub_out_networking(self.stubs)
     fakes.stub_out_rate_limiting(self.stubs)
     fakes.stub_out_auth(self.stubs)
     fakes.stub_out_key_pair_funcs(self.stubs)
     self.fixtures = self._make_image_fixtures()
     fakes.stub_out_glance(self.stubs, initial_fixtures=self.fixtures)
    def setUp(self):
        self.maxDiff = None
        super(ServerActionsTestV11, self).setUp()
        self.stubs = stubout.StubOutForTesting()
        fakes.stub_out_auth(self.stubs)
        self.stubs.Set(nova.db.api, 'instance_get', return_server_by_id)
        self.stubs.Set(nova.db.api, 'instance_update', instance_update)

        fakes.stub_out_glance(self.stubs)
        fakes.stub_out_compute_api_snapshot(self.stubs)
        service_class = 'nova.image.glance.GlanceImageService'
        self.service = utils.import_object(service_class)
        self.context = context.RequestContext(1, None)
        self.service.delete_all()
        self.sent_to_glance = {}
        fakes.stub_out_glance_add_image(self.stubs, self.sent_to_glance)
        self.flags(allow_instance_snapshots=True)
Example #24
0
    def setUp(self):
        self.maxDiff = None
        super(ServerActionsTestV11, self).setUp()
        self.stubs = stubout.StubOutForTesting()
        fakes.stub_out_auth(self.stubs)
        self.stubs.Set(nova.db.api, 'instance_get', return_server_by_id)
        self.stubs.Set(nova.db.api, 'instance_update', instance_update)

        fakes.stub_out_glance(self.stubs)
        fakes.stub_out_compute_api_snapshot(self.stubs)
        service_class = 'nova.image.glance.GlanceImageService'
        self.service = utils.import_object(service_class)
        self.context = context.RequestContext(1, None)
        self.service.delete_all()
        self.sent_to_glance = {}
        fakes.stub_out_glance_add_image(self.stubs, self.sent_to_glance)
        self.flags(allow_instance_snapshots=True)
Example #25
0
    def test_image_get_disk_config(self):
        self.flags(image_service='nova.image.glance.GlanceImageService')
        fakes.stub_out_glance(self.stubs)

        def fake_image_service_show(*args, **kwargs):
            return {'properties': {'managed_disk': True}}

        self.stubs.Set(image.glance.GlanceImageService, 'show',
                       fake_image_service_show)

        req = webob.Request.blank('/v1.1/openstack/images/10/os-disk-config')
        req.headers['Accept'] = 'application/json'
        res = req.get_response(fakes.wsgi_app())
        self.assertEqual(res.status_int, 200)

        body = json.loads(res.body)

        self.assertEqual(body['image']['managed_disk'], True)
        self.assertEqual(int(body['image']['id']), 10)
Example #26
0
    def setUp(self):
        super(ServerActionsControllerTest, self).setUp()

        CONF.set_override("glance_host", "localhost")
        self.stubs.Set(db, "instance_get_by_uuid", fakes.fake_instance_get(vm_state=vm_states.ACTIVE, host="fake_host"))
        self.stubs.Set(db, "instance_update_and_get_original", instance_update_and_get_original)

        fakes.stub_out_glance(self.stubs)
        fakes.stub_out_nw_api(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)
        fakes.stub_out_compute_api_snapshot(self.stubs)
        fake.stub_out_image_service(self.stubs)
        service_class = "nova.image.glance.GlanceImageService"
        self.service = importutils.import_object(service_class)
        self.sent_to_glance = {}
        fakes.stub_out_glanceclient_create(self.stubs, self.sent_to_glance)
        self.flags(allow_instance_snapshots=True, enable_instance_password=True)
        self.uuid = FAKE_UUID
        self.url = "/servers/%s/action" % self.uuid
        self._image_href = "155d900f-4e14-4e4c-a73d-069cbf4541e6"

        ext_info = plugins.LoadedExtensionInfo()
        self.controller = servers.ServersController(extension_info=ext_info)
Example #27
0
    def setUp(self):
        super(ServerActionsControllerTest, self).setUp()

        self.stubs.Set(
            nova.db, "instance_get_by_uuid", fakes.fake_instance_get(vm_state=vm_states.ACTIVE, host="fake_host")
        )
        self.stubs.Set(nova.db, "instance_update", instance_update)

        fakes.stub_out_glance(self.stubs)
        fakes.stub_out_nw_api(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)
        fakes.stub_out_compute_api_snapshot(self.stubs)
        fakes.stub_out_image_service(self.stubs)
        service_class = "nova.image.glance.GlanceImageService"
        self.service = importutils.import_object(service_class)
        self.service.delete_all()
        self.sent_to_glance = {}
        fakes.stub_out_glance_add_image(self.stubs, self.sent_to_glance)
        self.flags(allow_instance_snapshots=True, enable_instance_password=True)
        self.uuid = FAKE_UUID
        self.url = "/v2/fake/servers/%s/action" % self.uuid
        self._image_href = "155d900f-4e14-4e4c-a73d-069cbf4541e6"

        self.controller = servers.Controller()
Example #28
0
 def setUp(self):
     super(ImageMetaDataTest, self).setUp()
     fakes.stub_out_glance(self.stubs)
     self.controller = image_metadata.Controller()
Example #29
0
 def setUp(self):
     super(ImageMetaDataTest, self).setUp()
     fakes.stub_out_glance(self.stubs)
Example #30
0
    def setUp(self):
        """Run before each test."""
        super(ImagesControllerTest, self).setUp()
        fakes.stub_out_networking(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)
        fakes.stub_out_key_pair_funcs(self.stubs)
        fakes.stub_out_compute_api_snapshot(self.stubs)
        fakes.stub_out_compute_api_backup(self.stubs)
        fakes.stub_out_glance(self.stubs)

        self.controller = images.Controller()
        self.uuid = 'fa95aaf5-ab3b-4cd8-88c0-2be7dd051aaf'
        self.url = '/v2/fake/images/detail?server=' + self.uuid
        self.server_uuid = "aa640691-d1a7-4a67-9d3c-d35ee6b3cc74"
        self.server_href = (
            "http://localhost/v2/fake/servers/" + self.server_uuid)
        self.server_bookmark = (
            "http://localhost/fake/servers/" + self.server_uuid)
        self.alternate = "%s/fake/images/%s"
        self.fake_req = fakes.HTTPRequest.blank('/v2/fake/images/123')
        self.actual_image = self.controller.show(self.fake_req, '124')

        self.expected_image_123 = {
            "image": {'id': '123',
                      'name': 'public image',
                      'metadata': {'key1': 'value1'},
                      'updated': NOW_API_FORMAT,
                      'created': NOW_API_FORMAT,
                      'status': 'ACTIVE',
                      'minDisk': 10,
                      'progress': 100,
                      'minRam': 128,
                      "links": [{
                                    "rel": "self",
                                    "href":
                                        "http://localhost/v2/fake/images/123",
                                },
                                {
                                    "rel": "bookmark",
                                    "href":
                                        "http://localhost/fake/images/123",
                                },
                                {
                                    "rel": "alternate",
                                    "type": "application/vnd.openstack.image",
                                    "href": self.alternate %
                                            (glance.generate_glance_url(),
                                             123),
                                }],
            },
        }

        self.expected_image_124 = {
            "image": {'id': '124',
                      'name': 'queued snapshot',
                      'metadata': {
                          u'instance_uuid': self.server_uuid,
                          u'user_id': u'fake',
                      },
                      'updated': NOW_API_FORMAT,
                      'created': NOW_API_FORMAT,
                      'status': 'SAVING',
                      'progress': 25,
                      'minDisk': 0,
                      'minRam': 0,
                      'server': {
                          'id': self.server_uuid,
                          "links": [{
                                        "rel": "self",
                                        "href": self.server_href,
                                    },
                                    {
                                        "rel": "bookmark",
                                        "href": self.server_bookmark,
                                    }],
                      },
                      "links": [{
                                    "rel": "self",
                                    "href":
                                        "http://localhost/v2/fake/images/124",
                                },
                                {
                                    "rel": "bookmark",
                                    "href":
                                        "http://localhost/fake/images/124",
                                },
                                {
                                    "rel": "alternate",
                                    "type":
                                        "application/vnd.openstack.image",
                                    "href": self.alternate %
                                            (glance.generate_glance_url(),
                                             124),
                                }],
            },
        }

        self.image_service = self.mox.CreateMockAnything()
Example #31
0
 def setUp(self):
     super(ImageMetaDataTest, self).setUp()
     fakes.stub_out_glance(self.stubs)
     self.controller = image_metadata.Controller()
Example #32
0
    def setUp(self):
        """Run before each test."""
        super(ImagesControllerTest, self).setUp()
        fakes.stub_out_networking(self.stubs)
        fakes.stub_out_rate_limiting(self.stubs)
        fakes.stub_out_key_pair_funcs(self.stubs)
        fakes.stub_out_compute_api_snapshot(self.stubs)
        fakes.stub_out_compute_api_backup(self.stubs)
        fakes.stub_out_glance(self.stubs)

        self.controller = images.Controller()
        self.uuid = 'fa95aaf5-ab3b-4cd8-88c0-2be7dd051aaf'
        self.url = '/v2/fake/images/detail?server=' + self.uuid
        self.server_uuid = "aa640691-d1a7-4a67-9d3c-d35ee6b3cc74"
        self.server_href = ("http://localhost/v2/fake/servers/" +
                            self.server_uuid)
        self.server_bookmark = ("http://localhost/fake/servers/" +
                                self.server_uuid)
        self.alternate = "%s/fake/images/%s"
        self.fake_req = fakes.HTTPRequest.blank('/v2/fake/images/123')
        self.actual_image = self.controller.show(self.fake_req, '124')

        self.expected_image_123 = {
            "image": {
                'id':
                '123',
                'name':
                'public image',
                'metadata': {
                    'key1': 'value1'
                },
                'updated':
                NOW_API_FORMAT,
                'created':
                NOW_API_FORMAT,
                'status':
                'ACTIVE',
                'minDisk':
                10,
                'progress':
                100,
                'minRam':
                128,
                "links": [{
                    "rel": "self",
                    "href": "http://localhost/v2/fake/images/123",
                }, {
                    "rel": "bookmark",
                    "href": "http://localhost/fake/images/123",
                }, {
                    "rel":
                    "alternate",
                    "type":
                    "application/vnd.openstack.image",
                    "href":
                    self.alternate % (glance.generate_glance_url(), 123),
                }],
            },
        }

        self.expected_image_124 = {
            "image": {
                'id':
                '124',
                'name':
                'queued snapshot',
                'metadata': {
                    u'instance_uuid': self.server_uuid,
                    u'user_id': u'fake',
                },
                'updated':
                NOW_API_FORMAT,
                'created':
                NOW_API_FORMAT,
                'status':
                'SAVING',
                'progress':
                25,
                'minDisk':
                0,
                'minRam':
                0,
                'server': {
                    'id':
                    self.server_uuid,
                    "links": [{
                        "rel": "self",
                        "href": self.server_href,
                    }, {
                        "rel": "bookmark",
                        "href": self.server_bookmark,
                    }],
                },
                "links": [{
                    "rel": "self",
                    "href": "http://localhost/v2/fake/images/124",
                }, {
                    "rel": "bookmark",
                    "href": "http://localhost/fake/images/124",
                }, {
                    "rel":
                    "alternate",
                    "type":
                    "application/vnd.openstack.image",
                    "href":
                    self.alternate % (glance.generate_glance_url(), 124),
                }],
            },
        }

        self.image_service = self.mox.CreateMockAnything()
Example #33
0
 def setUp(self):
     super(ImageMetaDataTest, self).setUp()
     fakes.stub_out_glance(self.stubs)