- ."""
if cell_name is None:
return item
return cell_name + _CELL_ITEM_SEP + str(item)
**** CubicPower OpenStack Study ****
def split_cell_and_item(cell_and_item):
"""Split a combined cell@item and return them."""
result = cell_and_item.rsplit(_CELL_ITEM_SEP, 1)
if len(result) == 1:
return (None, cell_and_item)
else:
return result
**** CubicPower OpenStack Study ****
def _add_cell_to_service(service, cell_name):
service['id'] = cell_with_item(cell_name, service['id'])
service['host'] = cell_with_item(cell_name, service['host'])
**** CubicPower OpenStack Study ****
def add_cell_to_compute_node(compute_node, cell_name):
"""Fix compute_node attributes that should be unique. Allows
API cell to query the 'id' by cell@id.
"""
compute_node['id'] = cell_with_item(cell_name, compute_node['id'])
# Might have a 'service' backref. But if is_primitive() was used
# on this and it recursed too deep, 'service' may be "?".
service = compute_node.get('service')
if isinstance(service, dict):
_add_cell_to_service(service, cell_name)
**** CubicPower OpenStack Study ****
def add_cell_to_service(service, cell_name):
"""Fix service attributes that should be unique. Allows
API cell to query the 'id' or 'host' by cell@id/host.
"""
_add_cell_to_service(service, cell_name)
compute_node = service.get('compute_node')
if compute_node:
add_cell_to_compute_node(compute_node[0], cell_name)
**** CubicPower OpenStack Study ****
def add_cell_to_task_log(task_log, cell_name):
"""Fix task_log attributes that should be unique. In particular,
the 'id' and 'host' fields should be prepended with cell name.
"""
task_log['id'] = cell_with_item(cell_name, task_log['id'])
task_log['host'] = cell_with_item(cell_name, task_log['host'])