def update_cluster_node(node_gpus): if not node_gpus: return node = ClusterNode.objects.filter(name=conf.get('K8S_NODE_NAME')).first() for node_gpu_index in node_gpus.keys(): node_gpu_value = node_gpus[node_gpu_index] try: node_gpu = NodeGPU.objects.get(cluster_node=node, index=node_gpu_index) except NodeGPU.DoesNotExist: node_gpu = NodeGPU(cluster_node=node, index=node_gpu_index) node_gpu.serial = node_gpu_value['serial'] node_gpu.name = node_gpu_value['name'] node_gpu.memory = node_gpu_value['memory_total'] node_gpu.save()
def update_cluster(node_gpus): celery_app.send_task(CronsCeleryTasks.CLUSTERS_UPDATE_SYSTEM_INFO) celery_app.send_task(CronsCeleryTasks.CLUSTERS_UPDATE_SYSTEM_NODES) if not node_gpus: return node = ClusterNode.objects.filter(name=settings.K8S_NODE_NAME).first() for node_gpu_index in node_gpus.keys(): node_gpu_value = node_gpus[node_gpu_index] try: node_gpu = NodeGPU.objects.get(cluster_node=node, index=node_gpu_index) except NodeGPU.DoesNotExist: node_gpu = NodeGPU(cluster_node=node, index=node_gpu_index) node_gpu.serial = node_gpu_value['serial'] node_gpu.name = node_gpu_value['name'] node_gpu.memory = node_gpu_value['memory_total'] node_gpu.save()