Commit 69e53d9e authored by Tomáš Peterka's avatar Tomáš Peterka

Merge remote-tracking branch 'origin/master' into amarisoft

Conflicts:
	slapos/format.py
	slapos/tests/slapformat.py
parents 515d3366 ca70b595
...@@ -61,12 +61,14 @@ from slapos.util import mkdir_p ...@@ -61,12 +61,14 @@ from slapos.util import mkdir_p
import slapos.slap as slap import slapos.slap as slap
from slapos import version from slapos import version
logger = logging.getLogger("slapos.format") logger = logging.getLogger("slapos.format")
# dict[str: ManagerClass] used in configuration and XML dump of computer # dict[str: ManagerClass] used in configuration and XML dump of computer
# this dictionary is intended to be filled after each definition of a Manager # this dictionary is intended to be filled after each definition of a Manager
available_managers = {} available_managers = {}
def prettify_xml(xml): def prettify_xml(xml):
root = lxml.etree.fromstring(xml) root = lxml.etree.fromstring(xml)
return lxml.etree.tostring(root, pretty_print=True) return lxml.etree.tostring(root, pretty_print=True)
......
...@@ -554,17 +554,21 @@ def getAllocatedSlaveInstance(slave_reference, requested_computer_id): ...@@ -554,17 +554,21 @@ def getAllocatedSlaveInstance(slave_reference, requested_computer_id):
return execute_db(table, q, args, one=True) return execute_db(table, q, args, one=True)
def getRootPartition(reference): def getRootPartition(reference):
"""Climb the partitions tree up by 'requested_by' link to get the root partition."""
p = 'SELECT * FROM %s WHERE reference=?' p = 'SELECT * FROM %s WHERE reference=?'
parent_partition = execute_db('partition', p, [reference], one=True) partition = execute_db('partition', p, [reference], one=True)
if partition is None:
return
while parent_partition is not None: parent_partition = execute_db('partition', p, [partition['requested_by']], one=True)
parent_reference = parent_partition['requested_by'] while (parent_partition is not None and
if not parent_reference or parent_reference == reference: parent_partition['requested_by'] and
break parent_partition['requested_by'] != reference):
reference = parent_reference partition = parent_partition
reference = parent_partition['requested_by']
parent_partition = execute_db('partition', p, [reference], one=True) parent_partition = execute_db('partition', p, [reference], one=True)
return parent_partition return partition
def requestNotSlave(software_release, software_type, partition_reference, partition_id, partition_parameter_kw, filter_kw, requested_state): def requestNotSlave(software_release, software_type, partition_reference, partition_id, partition_parameter_kw, filter_kw, requested_state):
instance_xml = dict2xml(partition_parameter_kw) instance_xml = dict2xml(partition_parameter_kw)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment