completed api changes. still need plugin changes
This commit is contained in:
@@ -912,15 +912,10 @@ class API(base.Base):
|
||||
"""Unpause the given instance."""
|
||||
self._cast_compute_message('unpause_instance', context, instance_id)
|
||||
|
||||
def disable_host(self, context, instance_id=None, host=None):
|
||||
"""Sets the specified to not receive new instances."""
|
||||
return self._call_compute_message("disable_host", context,
|
||||
instance_id=None, host=host)
|
||||
|
||||
def enable_host(self, context, instance_id=None, host=None):
|
||||
"""Sets the specified to receive new instances."""
|
||||
return self._call_compute_message("enable_host", context,
|
||||
instance_id=None, host=host)
|
||||
def set_host_enabled(self, context, host, enabled):
|
||||
"""Sets the specified host's ability to accept new instances."""
|
||||
return self._call_compute_message("set_host_enabled", context,
|
||||
instance_id=None, host=host, enabled=enabled)
|
||||
|
||||
@scheduler_api.reroute_compute("diagnostics")
|
||||
def get_diagnostics(self, context, instance_id):
|
||||
|
||||
@@ -875,14 +875,10 @@ class ComputeManager(manager.SchedulerDependentManager):
|
||||
result))
|
||||
|
||||
@exception.wrap_exception
|
||||
def disable_host(self, context, instance_id=None, host=None):
|
||||
"""Set a host so that it can not accept new instances."""
|
||||
return self.driver.disable_host(host)
|
||||
|
||||
@exception.wrap_exception
|
||||
def enable_host(self, context, instance_id=None, host=None):
|
||||
"""Set a host so that it can accept new instances."""
|
||||
return self.driver.enable_host(host)
|
||||
def set_host_enabled(self, context, instance_id=None, host=None,
|
||||
enabled=None):
|
||||
"""Sets the specified host's ability to accept new instances."""
|
||||
return self.driver.set_host_enabled(host, enabled)
|
||||
|
||||
@exception.wrap_exception
|
||||
def get_diagnostics(self, context, instance_id):
|
||||
|
||||
@@ -249,3 +249,7 @@ class ComputeDriver(object):
|
||||
def poll_rescued_instances(self, timeout):
|
||||
"""Poll for rescued instances"""
|
||||
raise NotImplementedError()
|
||||
|
||||
def set_host_enabled(self, host, enabled):
|
||||
"""Sets the specified host's ability to accept new instances."""
|
||||
raise NotImplementedError()
|
||||
|
||||
@@ -514,3 +514,7 @@ class FakeConnection(driver.ComputeDriver):
|
||||
def get_host_stats(self, refresh=False):
|
||||
"""Return fake Host Status of ram, disk, network."""
|
||||
return self.host_status
|
||||
|
||||
def set_host_enabled(self, host, enabled):
|
||||
"""Sets the specified host's ability to accept new instances."""
|
||||
pass
|
||||
|
||||
@@ -499,3 +499,7 @@ class HyperVConnection(driver.ComputeDriver):
|
||||
def get_host_stats(self, refresh=False):
|
||||
"""See xenapi_conn.py implementation."""
|
||||
pass
|
||||
|
||||
def set_host_enabled(self, host, enabled):
|
||||
"""Sets the specified host's ability to accept new instances."""
|
||||
pass
|
||||
|
||||
@@ -1591,3 +1591,7 @@ class LibvirtConnection(driver.ComputeDriver):
|
||||
def get_host_stats(self, refresh=False):
|
||||
"""See xenapi_conn.py implementation."""
|
||||
pass
|
||||
|
||||
def set_host_enabled(self, host, enabled):
|
||||
"""Sets the specified host's ability to accept new instances."""
|
||||
pass
|
||||
|
||||
@@ -190,6 +190,10 @@ class VMWareESXConnection(driver.ComputeDriver):
|
||||
"""This method is supported only by libvirt."""
|
||||
return
|
||||
|
||||
def set_host_enabled(self, host, enabled):
|
||||
"""Sets the specified host's ability to accept new instances."""
|
||||
pass
|
||||
|
||||
|
||||
class VMWareAPISession(object):
|
||||
"""
|
||||
|
||||
@@ -24,6 +24,7 @@ import json
|
||||
import M2Crypto
|
||||
import os
|
||||
import pickle
|
||||
import random
|
||||
import subprocess
|
||||
import time
|
||||
import uuid
|
||||
@@ -932,6 +933,23 @@ class VMOps(object):
|
||||
# TODO: implement this!
|
||||
return 'http://fakeajaxconsole/fake_url'
|
||||
|
||||
def set_host_enabled(self, host, enabled):
|
||||
"""Sets the specified host's ability to accept new instances."""
|
||||
return self._call_xenhost("set_enabled", {"enabled": enabled})
|
||||
|
||||
def _call_xenhost(self, method, arg_dict):
|
||||
# Create a task ID as something that won't match any instance ID
|
||||
task_id = random.randint(-80000, -70000)
|
||||
try:
|
||||
task = self._session.async_call_plugin("xenhost", method,
|
||||
args=arg_dict)
|
||||
ret = self._session.wait_for_task(task, task_id)
|
||||
except self.XenAPI.Failure as e:
|
||||
ret = None
|
||||
LOG.error(_("The call to %(method)s returned an error: %(e)s.")
|
||||
% locals())
|
||||
return ret
|
||||
|
||||
def inject_network_info(self, instance, network_info, vm_ref=None):
|
||||
"""
|
||||
Generate the network info and make calls to place it into the
|
||||
|
||||
@@ -336,6 +336,10 @@ class XenAPIConnection(driver.ComputeDriver):
|
||||
True, run the update first."""
|
||||
return self.HostState.get_host_stats(refresh=refresh)
|
||||
|
||||
def set_host_enabled(self, host, enabled):
|
||||
"""Sets the specified host's ability to accept new instances."""
|
||||
return self._vmops.set_host_enabled(host, enabled)
|
||||
|
||||
|
||||
class XenAPISession(object):
|
||||
"""The session to invoke XenAPI SDK calls"""
|
||||
|
||||
Reference in New Issue
Block a user