コード例 #1
0
 def __save_service_relations(self, tenant, service_relations_list, old_new_service_id_map):
     new_service_relation_list = []
     if service_relations_list:
         for relation in service_relations_list:
             relation.pop("ID")
             new_service_relation = TenantServiceRelation(**relation)
             new_service_relation.tenant_id = tenant.tenant_id
             new_service_relation.service_id = old_new_service_id_map[relation["service_id"]]
             if old_new_service_id_map.get(relation["dep_service_id"]):
                 new_service_relation.dep_service_id = old_new_service_id_map[relation["dep_service_id"]]
             else:
                 new_service_relation.dep_service_id = relation["dep_service_id"]
             new_service_relation_list.append(new_service_relation)
         TenantServiceRelation.objects.bulk_create(new_service_relation_list)
コード例 #2
0
 def __save_service_relations(self, tenant, service_relations_list,
                              old_new_service_id_map, same_team,
                              same_region):
     new_service_relation_list = []
     if service_relations_list:
         for relation in service_relations_list:
             relation.pop("ID")
             new_service_relation = TenantServiceRelation(**relation)
             new_service_relation.tenant_id = tenant.tenant_id
             new_service_relation.service_id = old_new_service_id_map[
                 relation["service_id"]]
             if old_new_service_id_map.get(relation["dep_service_id"]):
                 new_service_relation.dep_service_id = old_new_service_id_map[
                     relation["dep_service_id"]]
             elif same_team and same_region:
                 # check new app region is same as old app
                 new_service_relation.dep_service_id = relation[
                     "dep_service_id"]
             else:
                 continue
             new_service_relation_list.append(new_service_relation)
         TenantServiceRelation.objects.bulk_create(
             new_service_relation_list)