Merge "Remove use of service_* conductor calls from xenapi host.py"
This commit is contained in:
@@ -21,11 +21,11 @@ import re
|
||||
|
||||
from nova.compute import task_states
|
||||
from nova.compute import vm_states
|
||||
from nova import conductor
|
||||
from nova import context
|
||||
from nova import exception
|
||||
from nova.objects import aggregate as aggregate_obj
|
||||
from nova.objects import instance as instance_obj
|
||||
from nova.objects import service as service_obj
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import jsonutils
|
||||
from nova.openstack.common import log as logging
|
||||
@@ -41,7 +41,6 @@ class Host(object):
|
||||
def __init__(self, session, virtapi):
|
||||
self._session = session
|
||||
self._virtapi = virtapi
|
||||
self._conductor_api = conductor.API()
|
||||
|
||||
def host_power_action(self, _host, action):
|
||||
"""Reboots or shuts down the host."""
|
||||
@@ -118,18 +117,11 @@ class Host(object):
|
||||
"""Sets the specified host's ability to accept new instances."""
|
||||
# Since capabilities are gone, use service table to disable a node
|
||||
# in scheduler
|
||||
status = {'disabled': not enabled,
|
||||
'disabled_reason': 'set by xenapi host_state'
|
||||
}
|
||||
cntxt = context.get_admin_context()
|
||||
service = self._conductor_api.service_get_by_args(
|
||||
cntxt,
|
||||
host,
|
||||
'nova-compute')
|
||||
self._conductor_api.service_update(
|
||||
cntxt,
|
||||
service,
|
||||
status)
|
||||
service = service_obj.Service.get_by_args(cntxt, host, 'nova-compute')
|
||||
service.disabled = not enabled
|
||||
service.disabled_reason = 'set by xenapi host_state'
|
||||
service.save()
|
||||
|
||||
args = {"enabled": jsonutils.dumps(enabled)}
|
||||
response = call_xenhost(self._session, "set_host_enabled", args)
|
||||
|
||||
Reference in New Issue
Block a user