1
0
Fork 0

units manager: assign devices in order specified by the plugin

This commit is contained in:
Jan Vcelak 2013-01-20 17:01:34 +01:00
parent 0791b88403
commit b7d719bfa3
2 changed files with 7 additions and 4 deletions

View file

@ -124,7 +124,7 @@ class Plugin(object):
self._assigned_devices = set()
self._free_devices = set()
def assign_free_devices(self, instance):
def _assign_free_devices_to_instance(self, instance):
# devices are not supported
if self._devices is None:
return
@ -147,6 +147,11 @@ class Plugin(object):
self._assigned_devices |= to_assign
self._free_devices -= to_assign
def assign_free_devices(self):
log.debug("assigning devices to all instances")
for instance in reversed(self._instances):
self._assign_free_devices_to_instance(self._instances[instance])
def release_devices(self, instance):
# devices are not supported
if self._devices is None:

View file

@ -60,9 +60,7 @@ class Manager(object):
new_instance = plugin.create_instance(instance_info.name, instance_info.devices, instance_info.options)
created_instances.append(new_instance)
for instance in reversed(created_instances):
log.debug("assigning devices to '%s'" % instance.name)
plugin.assign_free_devices(instance)
plugin.assign_free_devices()
for instance in created_instances:
log.debug("initializing '%s'" % instance.name)