Example #1
0
    def setUp(self):
        super(CellsComputeAPITestCase, self).setUp()
        global ORIG_COMPUTE_API
        ORIG_COMPUTE_API = self.compute_api
        self.flags(enable=True, group='cells')

        def _fake_cell_read_only(*args, **kwargs):
            return False

        def _fake_validate_cell(*args, **kwargs):
            return

        def _nop_update(context, instance, **kwargs):
            return instance

        self.compute_api = compute_cells_api.ComputeCellsAPI()
        self.stubs.Set(self.compute_api, '_cell_read_only',
                       _fake_cell_read_only)
        self.stubs.Set(self.compute_api, '_validate_cell', _fake_validate_cell)

        # NOTE(belliott) Don't update the instance state
        # for the tests at the API layer.  Let it happen after
        # the stub cast to cells so that expected_task_states
        # match.
        self.stubs.Set(self.compute_api, 'update', _nop_update)

        deploy_stubs(self.stubs, self.compute_api)
Example #2
0
    def setUp(self):
        super(CellsConductorAPIRPCRedirect, self).setUp()

        self.compute_api = compute_cells_api.ComputeCellsAPI()
        self.cells_rpcapi = mock.MagicMock()
        self.compute_api.compute_task_api.cells_rpcapi = self.cells_rpcapi

        self.context = context.RequestContext('fake', 'fake')
Example #3
0
    def setUp(self):
        super(CellsShelveComputeAPITestCase, self).setUp()
        global ORIG_COMPUTE_API
        ORIG_COMPUTE_API = self.compute_api
        self.compute_api = compute_cells_api.ComputeCellsAPI()

        def _fake_validate_cell(*args, **kwargs):
            return

        self.stub_out('nova.compute.api.API._validate_cell',
                      _fake_validate_cell)
Example #4
0
    def setUp(self):
        super(CellsComputeAPITestCase, self).setUp()
        global ORIG_COMPUTE_API
        ORIG_COMPUTE_API = self.compute_api
        self.flags(enable=True, group='cells')

        def _fake_validate_cell(*args, **kwargs):
            return

        self.compute_api = compute_cells_api.ComputeCellsAPI()
        self.stubs.Set(self.compute_api, '_validate_cell', _fake_validate_cell)

        deploy_stubs(self.stubs, self.compute_api)
    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 = {}
Example #6
0
    def setUp(self):
        super(CellsShelveComputeAPITestCase, self).setUp()
        global ORIG_COMPUTE_API
        ORIG_COMPUTE_API = self.compute_api
        self.compute_api = compute_cells_api.ComputeCellsAPI()

        def _fake_validate_cell(*args, **kwargs):
            return

        def _fake_cast_to_cells(self, context, instance, method, *args,
                                **kwargs):
            fn = getattr(ORIG_COMPUTE_API, method)
            fn(context, instance, *args, **kwargs)

        self.stub_out('nova.compute.api.API._validate_cell',
                      _fake_validate_cell)
        self.stub_out('nova.compute.cells_api.ComputeCellsAPI._cast_to_cells',
                      _fake_cast_to_cells)
Example #7
0
    def setUp(self):
        super(CellsComputeAPITestCase, self).setUp()
        global ORIG_COMPUTE_API
        ORIG_COMPUTE_API = self.compute_api
        self.flags(enable=True, group='cells')

        def _fake_cell_read_only(*args, **kwargs):
            return False

        def _fake_validate_cell(*args, **kwargs):
            return

        def _nop_update(context, instance, **kwargs):
            return instance

        self.compute_api = compute_cells_api.ComputeCellsAPI()
        self.stubs.Set(self.compute_api, '_cell_read_only',
                       _fake_cell_read_only)
        self.stubs.Set(self.compute_api, '_validate_cell', _fake_validate_cell)

        deploy_stubs(self.stubs, self.compute_api)
Example #8
0
 def setUp(self):
     super(CellsComputePolicyTestCase, self).setUp()
     global ORIG_COMPUTE_API
     ORIG_COMPUTE_API = self.compute_api
     self.compute_api = compute_cells_api.ComputeCellsAPI()
     deploy_stubs(self.stubs, self.compute_api)
Example #9
0
 def setUp(self):
     super(ComputeCellsAPIUnitTestCase, self).setUp()
     self.flags(cell_type='api', enable=True, group='cells')
     self.compute_api = compute_cells_api.ComputeCellsAPI()
     self.is_cells = True
Example #10
0
 def setUp(self):
     super(ComputeCellsAPIUnitTestCase, self).setUp()
     self.compute_api = compute_cells_api.ComputeCellsAPI()
     self.is_cells = True