~hudson-openstack/nova/trunk

« back to all changes in this revision

Viewing changes to nova/tests/scheduler/test_scheduler.py

  • Committer: Tarmac
  • Author(s): Brian Lamar, Dan Prince
  • Date: 2011-08-31 22:55:34 UTC
  • mfrom: (1443.3.61 instance_states)
  • Revision ID: tarmac-20110831225534-upfhtsvcsafyql6x
Fixed and improved the way instance "states" are set. Instead of relying on solely the power_state of a VM, there are now explicitly defined VM states and VM task states which respectively define the current state of the VM and the task which is currently being performed by the VM.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
from nova.scheduler import manager
41
41
from nova.scheduler import multi
42
42
from nova.compute import power_state
 
43
from nova.compute import vm_states
43
44
 
44
45
 
45
46
FLAGS = flags.FLAGS
94
95
        inst['vcpus'] = kwargs.get('vcpus', 1)
95
96
        inst['memory_mb'] = kwargs.get('memory_mb', 10)
96
97
        inst['local_gb'] = kwargs.get('local_gb', 20)
 
98
        inst['vm_state'] = kwargs.get('vm_state', vm_states.ACTIVE)
 
99
        inst['power_state'] = kwargs.get('power_state', power_state.RUNNING)
 
100
        inst['task_state'] = kwargs.get('task_state', None)
97
101
        return db.instance_create(ctxt, inst)
98
102
 
99
103
    def test_fallback(self):
271
275
        inst['memory_mb'] = kwargs.get('memory_mb', 20)
272
276
        inst['local_gb'] = kwargs.get('local_gb', 30)
273
277
        inst['launched_on'] = kwargs.get('launghed_on', 'dummy')
274
 
        inst['state_description'] = kwargs.get('state_description', 'running')
275
 
        inst['state'] = kwargs.get('state', power_state.RUNNING)
 
278
        inst['vm_state'] = kwargs.get('vm_state', vm_states.ACTIVE)
 
279
        inst['task_state'] = kwargs.get('task_state', None)
 
280
        inst['power_state'] = kwargs.get('power_state', power_state.RUNNING)
276
281
        return db.instance_create(self.context, inst)['id']
277
282
 
278
283
    def _create_volume(self):
664
669
                                      block_migration=False)
665
670
 
666
671
        i_ref = db.instance_get(self.context, instance_id)
667
 
        self.assertTrue(i_ref['state_description'] == 'migrating')
 
672
        self.assertTrue(i_ref['vm_state'] == vm_states.MIGRATING)
668
673
        db.instance_destroy(self.context, instance_id)
669
674
        db.volume_destroy(self.context, v_ref['id'])
670
675
 
671
676
    def test_live_migration_src_check_instance_not_running(self):
672
677
        """The instance given by instance_id is not running."""
673
678
 
674
 
        instance_id = self._create_instance(state_description='migrating')
 
679
        instance_id = self._create_instance(power_state=power_state.NOSTATE)
675
680
        i_ref = db.instance_get(self.context, instance_id)
676
681
 
677
682
        try: