def setUp(self): super(ResetStateTests, self).setUp() self.uuid = uuidutils.generate_uuid() self.admin_api = admin_actions.AdminActionsController() self.compute_api = self.admin_api.compute_api url = '/fake/servers/%s/action' % self.uuid self.request = fakes.HTTPRequest.blank(url) self.context = self.request.environ['nova.context']
def setUp(self): super(CellsAdminAPITestCase, self).setUp() def _fake_cell_read_only(*args, **kwargs): return False def _fake_validate_cell(*args, **kwargs): return def _fake_compute_api_get(context, instance_id): return { 'id': 1, 'uuid': instance_id, 'vm_state': vm_states.ACTIVE, 'task_state': None, 'cell_name': None } def _fake_instance_update_and_get_original(context, instance_uuid, values): inst = fakes.stub_instance(INSTANCE_IDS.get(instance_uuid), name=values.get('display_name')) return (inst, inst) def fake_cast_to_cells(context, instance, method, *args, **kwargs): """ Makes sure that the cells receive the cast to update the cell state """ self.cells_received_kwargs.update(kwargs) self.admin_api = admin_actions.AdminActionsController() self.admin_api.compute_api = compute_cells_api.ComputeCellsAPI() self.stubs.Set(self.admin_api.compute_api, '_cell_read_only', _fake_cell_read_only) self.stubs.Set(self.admin_api.compute_api, '_validate_cell', _fake_validate_cell) self.stubs.Set(self.admin_api.compute_api, 'get', _fake_compute_api_get) self.stubs.Set(self.admin_api.compute_api.db, 'instance_update_and_get_original', _fake_instance_update_and_get_original) self.stubs.Set(self.admin_api.compute_api, '_cast_to_cells', fake_cast_to_cells) self.uuid = uuidutils.generate_uuid() url = '/fake/servers/%s/action' % self.uuid self.request = fakes.HTTPRequest.blank(url) self.cells_received_kwargs = {}
def setUp(self): super(CommonMixin, self).setUp() self.controller = admin_actions.AdminActionsController() self.compute_api = self.controller.compute_api self.context = nova.context.RequestContext('fake', 'fake') def _fake_controller(*args, **kwargs): return self.controller self.stubs.Set(admin_actions, 'AdminActionsController', _fake_controller) self.flags(osapi_compute_extension=[ 'nova.api.openstack.compute.contrib.select_extensions' ], osapi_compute_ext_list=['Admin_actions']) self.app = fakes.wsgi_app(init_only=('servers', ), fake_auth_context=self.context) self.mox.StubOutWithMock(self.compute_api, 'get')
def setUp(self): super(ResetStateTests, self).setUp() self.exists = True self.kwargs = None self.uuid = uuid.uuid4() def fake_get(inst, context, instance_id): if self.exists: return dict(id=1, uuid=instance_id, vm_state=vm_states.ACTIVE) raise exception.InstanceNotFound() def fake_update(inst, context, instance, **kwargs): self.kwargs = kwargs self.stubs.Set(compute_api.API, 'get', fake_get) self.stubs.Set(compute_api.API, 'update', fake_update) self.admin_api = admin_actions.AdminActionsController() url = '/fake/servers/%s/action' % self.uuid self.request = fakes.HTTPRequest.blank(url)
def setUp(self): super(CreateBackupTestsV2, self).setUp() self.controller = admin_actions_v2.AdminActionsController() self.compute_api = self.controller.compute_api self.context = nova.context.RequestContext('fake', 'fake') def _fake_controller(*args, **kwargs): return self.controller self.stubs.Set(admin_actions_v2, 'AdminActionsController', _fake_controller) self.flags(osapi_compute_extension=[ 'nova.api.openstack.compute.contrib.select_extensions' ], osapi_compute_ext_list=['Admin_actions']) self.app = fakes.wsgi_app(init_only=('servers', ), fake_auth_context=self.context) self.mox.StubOutWithMock(self.compute_api, 'get') self.mox.StubOutWithMock(common, 'check_img_metadata_properties_quota') self.mox.StubOutWithMock(self.compute_api, 'backup')