~rlane/nova/lp773690

« back to all changes in this revision

Viewing changes to nova/scheduler/driver.py

  • Committer: rlane at wikimedia
  • Date: 2011-04-29 22:30:40 UTC
  • mfrom: (382.1.655 nova)
  • Revision ID: rlane@wikimedia.org-20110429223040-i0x3ds9eqwrabyru
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
129
129
        if (power_state.RUNNING != instance_ref['state'] or \
130
130
           'running' != instance_ref['state_description']):
131
131
            ec2_id = instance_ref['hostname']
132
 
            raise exception.Invalid(_('Instance(%s) is not running') % ec2_id)
 
132
            raise exception.InstanceNotRunning(instance_id=ec2_id)
133
133
 
134
134
        # Checing volume node is running when any volumes are mounted
135
135
        # to the instance.
136
136
        if len(instance_ref['volumes']) != 0:
137
137
            services = db.service_get_all_by_topic(context, 'volume')
138
138
            if len(services) < 1 or  not self.service_is_up(services[0]):
139
 
                raise exception.Invalid(_("volume node is not alive"
140
 
                                          "(time synchronize problem?)"))
 
139
                raise exception.VolumeServiceUnavailable()
141
140
 
142
141
        # Checking src host exists and compute node
143
142
        src = instance_ref['host']
145
144
 
146
145
        # Checking src host is alive.
147
146
        if not self.service_is_up(services[0]):
148
 
            raise exception.Invalid(_("%s is not alive(time "
149
 
                                      "synchronize problem?)") % src)
 
147
            raise exception.ComputeServiceUnavailable(host=src)
150
148
 
151
149
    def _live_migration_dest_check(self, context, instance_ref, dest):
152
150
        """Live migration check routine (for destination host).
163
161
 
164
162
        # Checking dest host is alive.
165
163
        if not self.service_is_up(dservice_ref):
166
 
            raise exception.Invalid(_("%s is not alive(time "
167
 
                                      "synchronize problem?)") % dest)
 
164
            raise exception.ComputeServiceUnavailable(host=dest)
168
165
 
169
166
        # Checking whether The host where instance is running
170
167
        # and dest is not same.
171
168
        src = instance_ref['host']
172
169
        if dest == src:
173
170
            ec2_id = instance_ref['hostname']
174
 
            raise exception.Invalid(_("%(dest)s is where %(ec2_id)s is "
175
 
                                       "running now. choose other host.")
176
 
                                       % locals())
 
171
            raise exception.UnableToMigrateToSelf(instance_id=ec2_id,
 
172
                                                  host=dest)
177
173
 
178
174
        # Checking dst host still has enough capacities.
179
175
        self.assert_compute_node_has_enough_resources(context,
204
200
            oservice_refs = db.service_get_all_compute_by_host(context,
205
201
                                           instance_ref['launched_on'])
206
202
        except exception.NotFound:
207
 
            raise exception.Invalid(_("host %s where instance was launched "
208
 
                                      "does not exist.")
209
 
                                       % instance_ref['launched_on'])
 
203
            raise exception.SourceHostUnavailable()
210
204
        oservice_ref = oservice_refs[0]['compute_node'][0]
211
205
 
212
206
        # Checking hypervisor is same.
213
207
        orig_hypervisor = oservice_ref['hypervisor_type']
214
208
        dest_hypervisor = dservice_ref['hypervisor_type']
215
209
        if orig_hypervisor != dest_hypervisor:
216
 
            raise exception.Invalid(_("Different hypervisor type"
217
 
                                      "(%(orig_hypervisor)s->"
218
 
                                      "%(dest_hypervisor)s)')" % locals()))
 
210
            raise exception.InvalidHypervisorType()
219
211
 
220
212
        # Checkng hypervisor version.
221
213
        orig_hypervisor = oservice_ref['hypervisor_version']
222
214
        dest_hypervisor = dservice_ref['hypervisor_version']
223
215
        if orig_hypervisor > dest_hypervisor:
224
 
            raise exception.Invalid(_("Older hypervisor version"
225
 
                                      "(%(orig_hypervisor)s->"
226
 
                                      "%(dest_hypervisor)s)") % locals())
 
216
            raise exception.DestinationHypervisorTooOld()
227
217
 
228
218
        # Checking cpuinfo.
229
219
        try: