Windows support (freezing).

Client notification support.
Hypervisor manager changes.
IOU reload support.
Switch to non-dynamic module loading because of a multiprocessing
problem on Windows.
This commit is contained in:
grossmj committed 2014-03-15 21:41:04 -06:00
1 parent 3df5cdb76f
commit 41a1d16e92
15 files changed
+192 -45

No files matched your search

+52 -6
View File
@@ -45,9 +45,6 @@ class IOU(IModule):
def __init__(self, name, *args, **kwargs):
if not sys.platform.startswith("linux"):
raise IOUError("Sorry the IOU module only works on Linux")
# get the iouyap location
config = Config.instance()
iou_config = config.get_section_config(name.upper())
@@ -74,14 +71,14 @@ class IOU(IModule):
self._udp_start_port_range = 30001
self._udp_end_port_range = 40001
self._current_udp_port = self._udp_start_port_range
self._host = "127.0.0.1" #FIXME: used by ZeroMQ...
self._host = "127.0.0.1" # FIXME: used by ZeroMQ...
self._projects_dir = kwargs["projects_dir"]
self._tempdir = kwargs["temp_dir"]
self._working_dir = self._projects_dir
self._iourc = ""
#self._callback = self.add_periodic_callback(self.test, 1000)
#self._callback.start()
self._iou_callback = self.add_periodic_callback(self._check_iou, 5000)
self._iou_callback.start()
def stop(self):
"""
@@ -95,6 +92,17 @@ class IOU(IModule):
IModule.stop(self) # this will stop the I/O loop
def _check_iou(self):
for iou_id in self._iou_instances:
iou_instance = self._iou_instances[iou_id]
if iou_instance.started and not iou_instance.is_running():
self.send_notification({"module": self.name,
"id": iou_id,
"name": iou_instance.name,
"message": "IOU is not running"})
iou_instance.stop()
@IModule.route("iou.reset")
def reset(self, request):
"""
@@ -115,6 +123,13 @@ class IOU(IModule):
self._remote_server = False
self._current_console_port = self._console_start_port_range
self._current_udp_port = self._udp_start_port_range
if self._iourc and os.path.exists(self._iourc):
try:
os.remove(self._iourc)
except EnvironmentError as e:
log.warn("could not delete iourc file {}: {}".format(self._iourc, e))
log.info("IOU module has been reset")
@IModule.route("iou.settings")
@@ -360,6 +375,37 @@ class IOU(IModule):
return
self.send_response(request)
@IModule.route("iou.reload")
def vm_reload(self, request):
"""
Reloads an IOU instance.
Mandatory request parameters:
- id (IOU identifier)
Response parameters:
- same as original request
:param request: JSON request
"""
if request == None:
self.send_param_error()
return
#TODO: JSON schema validation for the request
log.debug("received request {}".format(request))
iou_id = request["id"]
iou_instance = self._iou_instances[iou_id]
try:
if iou_instance.is_running():
iou_instance.stop()
iou_instance.start()
except IOUError as e:
self.send_custom_error(str(e))
return
self.send_response(request)
@IModule.route("iou.allocate_udp_port")
def allocate_udp_port(self, request):
"""
+13
View File
@@ -79,6 +79,7 @@ class IOUDevice(object):
self._ioucon_thead = None
self._ioucon_thread_stop_event = None
self._host = host
self._started = False
# IOU settings
self._ethernet_adapters = [EthernetAdapter(), EthernetAdapter()] # one adapter = 4 interfaces
@@ -295,6 +296,16 @@ class IOUDevice(object):
log.info("IOU device {name} [id={id}] has been deleted".format(name=self._name,
id=self._id))
@property
def started(self):
"""
Returns either this IOU device has been started or not.
:returns: boolean
"""
return self._started
def _update_iouyap_config(self):
"""
Updates the iouyap.ini file.
@@ -411,6 +422,7 @@ class IOUDevice(object):
cwd=self._working_dir,
env=env)
log.info("IOU instance {} started PID={}".format(self._id, self._process.pid))
self._started = True
except EnvironmentError as e:
log.error("could not start IOU: {}".format(e))
raise IOUError("could not start IOU: {}".format(e))
@@ -437,6 +449,7 @@ class IOUDevice(object):
log.warn("IOU instance {} PID={} is still running".format(self._id,
self._process.pid))
self._process = None
self._started = False
# stop console support
if self._ioucon_thead: