本文整理汇总了Python中enarksh.DataLayer.DataLayer.enk_back_run_get_ports1方法的典型用法代码示例。如果您正苦于以下问题:Python DataLayer.enk_back_run_get_ports1方法的具体用法?Python DataLayer.enk_back_run_get_ports1怎么用?Python DataLayer.enk_back_run_get_ports1使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类enarksh.DataLayer.DataLayer
的用法示例。
在下文中一共展示了DataLayer.enk_back_run_get_ports1方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __load
# 需要导入模块: from enarksh.DataLayer import DataLayer [as 别名]
# 或者: from enarksh.DataLayer.DataLayer import enk_back_run_get_ports1 [as 别名]
def __load(self, sch_id, host_resources):
"""
Loads the schedule from the database.
:param int sch_id: The ID of the schedule.
:param dict host_resources: The host resources.
"""
schedule = DataLayer.enk_back_schedule_get_schedule(sch_id)
# Fetch all data of the run from the database.
nodes_data = DataLayer.enk_back_run_get_run_nodes(schedule['run_id'])
ports_data = DataLayer.enk_back_run_get_ports1(schedule['run_id'])
node_ports_data = DataLayer.enk_back_run_get_ports2(schedule['run_id'])
dependants_data = DataLayer.enk_back_run_get_dependants(schedule['srv_id'])
consumptions_data = DataLayer.enk_back_run_get_consumptions(schedule['run_id'])
resources_data = DataLayer.enk_back_run_get_resources(schedule['run_id'])
# Create a lookup table for all child nodes of a node.
tmp_child_nodes = {}
for node_data in nodes_data.values():
if node_data['rnd_id_parent']:
if node_data['rnd_id_parent'] not in tmp_child_nodes:
tmp_child_nodes[node_data['rnd_id_parent']] = []
tmp_child_nodes[node_data['rnd_id_parent']].append(node_data)
# Create a lookup table for all direct successor nodes of a node.
direct_successors = Schedule.__create_successor_lookup_table1(nodes_data,
tmp_child_nodes,
node_ports_data,
ports_data,
dependants_data)
# Create a lookup table for all direct predecessor nodes of a node.
direct_predecessors = Schedule.__create_predecessor_lookup_table1(direct_successors)
# Create a lookup table for all (direct and indirect) successor nodes of a node.
successors = {}
for rnd_id_predecessor in direct_successors.keys():
successors[rnd_id_predecessor] = {}
for rnd_id_successor in direct_successors[rnd_id_predecessor]:
successors[rnd_id_predecessor][rnd_id_successor] = True
Schedule.__create_successor_lookup_table3(successors[rnd_id_predecessor],
direct_successors,
rnd_id_successor)
# Create all resources.
resources = {}
for node_resource_data in resources_data.values():
for resource_data in node_resource_data:
rsc = resource.create_resource(resource_data)
resources[resource_data['rsc_id']] = rsc
# Observe resource for state changes.
rsc.event_state_change.register_listener(Schedule.slot_resource_state_change)
# Create all consumptions.
consumptions = {}
for node_resource_data in consumptions_data.values():
for consumption_data in node_resource_data:
consumptions[consumption_data['cns_id']] = consumption.create_consumption(consumption_data,
host_resources,
resources)
# Create all nodes.
for node_data in nodes_data.values():
self.__nodes[node_data['rnd_id']] = create_node(node_data)
# Initialize all nodes.
# First initialize all simple nodes. This has the effect that signals via StateChange.notify_observer are
# send first to (simple) successor nodes and then to parent nodes (otherwise it is possible that the schedule
# will be set to run status ENK_RST_ID_ERROR while a simple successor node did not yet receive a signal that
# would put this node in run status ENK_RST_ID_QUEUED.
for node_data in nodes_data.values():
node = self.__nodes[node_data['rnd_id']]
if node.is_simple_node():
node.initialize(node_data,
schedule,
resources,
resources_data,
consumptions,
consumptions_data,
self.__nodes,
tmp_child_nodes,
direct_predecessors,
direct_successors,
successors)
# Observe node for state changes.
node.event_state_change.register_listener(self.slot_node_state_change)
# Second initialize complex nodes.
for node_data in nodes_data.values():
node = self.__nodes[node_data['rnd_id']]
if node.is_complex_node():
node.initialize(node_data,
schedule,
resources,
resources_data,
consumptions,
consumptions_data,
#.........这里部分代码省略.........