def update_nids(self, nid_list):
# Although this is creating/deleting a NID it actually rewrites the whole NID configuration for the node
# this is all in here for now, but as we move to dynamic lnet it will probably get it's own file.
with self._lock:
lnet_configurations = set()
lnet_nid_data = defaultdict(lambda: {'nid_updates': {}, 'nid_deletes': {}})
for nid_data in nid_list:
network_interface = NetworkInterface.objects.get(id = nid_data['network_interface'])
lnet_configuration = LNetConfiguration.objects.get(host = network_interface.host_id)
lnet_configurations.add(lnet_configuration)
if str(nid_data['lnd_network']) == '-1':
lnet_nid_data[lnet_configuration]['nid_deletes'][network_interface.id] = nid_data
else:
lnet_nid_data[lnet_configuration]['nid_updates'][network_interface.id] = nid_data
jobs = []
for lnet_configuration in lnet_configurations:
jobs.append(ConfigureLNetJob(lnet_configuration = lnet_configuration,
config_changes = json.dumps(lnet_nid_data[lnet_configuration])))
with transaction.commit_on_success():
command = Command.objects.create(message = "Configuring NIDS for hosts")
self.CommandPlan.add_jobs(jobs, command)
self.progress.advance()
return command.id
job_scheduler.py 文件源码
python
阅读 27
收藏 0
点赞 0
评论 0
评论列表
文章目录