diff options
| author | Dan Smith <danms@us.ibm.com> | 2013-05-30 09:43:34 -0700 |
|---|---|---|
| committer | Dan Smith <danms@us.ibm.com> | 2013-06-07 11:43:37 -0700 |
| commit | d431218f6aaae4541bd75e1a04a83e06f43e15bd (patch) | |
| tree | 4fa8ec464e52d13efe7b451cf4cb7f8f2adbdbec | |
| parent | 168ff33d104c76606079748ea09cb97ff8fc97fe (diff) | |
Make xenapi use Instance object for host_maintenance_mode()
This makes xenapi grab an Instance object in host_maintenance_mode()
instead of calling into virtapi. This removes the one and only use
of instance_get_by_uuid() in nova/virt.
The existing tests for host_maintenance_mode() need no changes
since they just stub out the database call that eventually gets
called in the same way.
Related to blueprint unified-object-model
Change-Id: Iff4b5de1741653fad8c59e311341aeb3d0bb3539
| -rw-r--r-- | nova/virt/xenapi/host.py | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/nova/virt/xenapi/host.py b/nova/virt/xenapi/host.py index 5fa2b55db..31854696f 100644 --- a/nova/virt/xenapi/host.py +++ b/nova/virt/xenapi/host.py @@ -72,7 +72,7 @@ class Host(object): ' ping migration to a new host') LOG.info(msg % locals()) continue - instance = self._virtapi.instance_get_by_uuid(ctxt, uuid) + instance = instance_obj.Instance.get_by_uuid(ctxt, uuid) vm_counter = vm_counter + 1 aggregate = self._virtapi.aggregate_get_by_host( @@ -84,27 +84,24 @@ class Host(object): dest = _host_find(ctxt, self._session, aggregate[0], host_ref) - self._virtapi.instance_update( - ctxt, instance['uuid'], - {'host': dest, - 'task_state': task_states.MIGRATING}) + instance.host = dest + instance.task_state = task_states.MIGRATING + instance.save() self._session.call_xenapi('VM.pool_migrate', vm_ref, host_ref, {}) migrations_counter = migrations_counter + 1 - self._virtapi.instance_update( - ctxt, instance['uuid'], - {'vm_state': vm_states.ACTIVE}) + instance.vm_state = vm_states.ACTIVE + instance.save() break except self._session.XenAPI.Failure: LOG.exception(_('Unable to migrate VM %(vm_ref)s' 'from %(host)s') % locals()) - self._virtapi.instance_update( - ctxt, instance['uuid'], - {'host': host, - 'vm_state': vm_states.ACTIVE}) + instance.host = host + instance.vm_state = vm_states.ACTIVE + instance.save() if vm_counter == migrations_counter: return 'on_maintenance' |
