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) 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) self.uuid = FAKE_UUID self.url = '/v2/fake/servers/%s/action' % self.uuid self.controller = servers.Controller()
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)
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()
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) 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()
def setUp(self): super(TestGlanceImageService, self).setUp() fakes.stub_out_compute_api_snapshot(self.stubs) client = glance_stubs.StubGlanceClient() self.service = glance.GlanceImageService(client=client) self.context = context.RequestContext("fake", "fake", auth_token=True) self.service.delete_all()
def setUp(self): super(TestGlanceImageService, self).setUp() fakes.stub_out_compute_api_snapshot(self.stubs) client = glance_stubs.StubGlanceClient() self.service = glance.GlanceImageService(client=client) self.context = context.RequestContext('fake', 'fake', auth_token=True) self.service.delete_all()
def setUp(self): super(ServerActionsControllerTest, self).setUp() CONF.set_override('host', 'localhost', group='glance') 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_nw_api(self.stubs) fakes.stub_out_compute_api_snapshot(self.stubs) fake.stub_out_image_service(self.stubs) 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)
def setUp(self): super(TestGlanceImageService, self).setUp() fakes.stub_out_compute_api_snapshot(self.stubs) client = glance_stubs.StubGlanceClient() self.service = self._create_image_service(client) self.context = context.RequestContext('fake', 'fake', auth_token=True)
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()
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)
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()
def setUp(self): super(TestGlanceImageService, self).setUp() fakes.stub_out_compute_api_snapshot(self.stubs) self.client = glance_stubs.StubGlanceClient() self.service = self._create_image_service(self.client) self.context = context.RequestContext('fake', 'fake', auth_token=True) self.files_to_clean = []
def setUp(self): super(TestGlanceImageService, self).setUp() fakes.stub_out_compute_api_snapshot(self.stubs) self.client = glance_stubs.StubGlanceClient() self.service = self._create_image_service(self.client) self.context = context.RequestContext("fake", "fake", auth_token=True) self.mox = mox.Mox() self.files_to_clean = []
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()
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)
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()
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()
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)
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)
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()
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()
def setUp(self): """Run before each test.""" super(ImagesControllerTestV21, 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) self.controller = self.image_controller_class() self.url_prefix = "http://localhost%s/images" % self.url_base self.bookmark_prefix = "http://localhost%s/images" % self.bookmark_base self.uuid = 'fa95aaf5-ab3b-4cd8-88c0-2be7dd051aaf' self.server_uuid = "aa640691-d1a7-4a67-9d3c-d35ee6b3cc74" self.server_href = ( "http://localhost%s/servers/%s" % (self.url_base, self.server_uuid)) self.server_bookmark = ( "http://localhost%s/servers/%s" % (self.bookmark_base, self.server_uuid)) self.alternate = "%s/images/%s" 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": "%s/123" % self.url_prefix }, { "rel": "bookmark", "href": "%s/123" % self.bookmark_prefix }, { "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": "%s/124" % self.url_prefix }, { "rel": "bookmark", "href": "%s/124" % self.bookmark_prefix }, { "rel": "alternate", "type": "application/vnd.openstack.image", "href": self.alternate % (glance.generate_glance_url(), 124), }], }, }
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()