Example #1
0
    def process_cric_sites(cric_sites_file):
        with open(cric_sites_file) as file:
            sites = json.load(file)
            for site_name, site in sites.items():
                if site_name == "NULL":
                    continue
                # print(site_name)
                site = CRICService.cric_sites_location_patch(site_name, site)
                site_obj = SiteService.get_or_create(site_name)
                site_obj.sources.append('cric_sites')
                site_obj.latitude = site['latitude']
                site_obj.longitude = site['longitude']
                site_obj.hepspec06 = site['capacity']
                site_obj.cores = site['cores']
                for site_vo in site['sites']:
                    vo_obj = VOService.get_or_create(site_vo['vo_name'])
                    site_vo_obj = SiteVOService.get_or_create(
                        site_vo['name'], site_obj, vo_obj)

                    site_obj.supported_vos.add(vo_obj)
                    site_obj.sitevo_set.add(site_vo_obj)

                    vo_obj.sitevo_set.add(site_vo_obj)
                    vo_obj.site_set.add(site_obj)
                if site['country'] == "NULL":
                    if "KISTI" in site_name:
                        site_obj.country = "South Korea"
                    else:
                        site_obj.country = get_country(site['latitude'],
                                                       site['longitude']).name
                else:
                    site_obj.country = site['country']
                if site['country_code'] is not None or len(
                        site['country_code']) > 0:
                    site_obj.country_code = site['country_code']
                else:
                    if "KISTI" in site_name:
                        site_obj.country_code = "KR"
                    else:
                        site_obj.country = get_country(
                            site['latitude'], site['longitude']).alpha_2
                SiteService.save(site_obj)
Example #2
0
 def process_cric_federations(cric_federations_file):
     with open(cric_federations_file) as file:
         federations = json.load(file)
         for federation_name, federation in federations.items():
             if federation_name == "NULL":
                 continue
             fed_obj = FederationsService.get_or_create(federation_name)
             fed_obj.accounting_name = federation['accounting_name']
             fed_obj.tier = federation['tier_level']
             for vo_name in federation['vos']:
                 vo = VOService.get_or_create(vo_name)
                 fed_obj.supported_vos.add(vo)
             pledges = federation['pledges']
             if federation['rcsites'] is not None:
                 for site in federation['rcsites']:
                     site_obj = SiteService.get_or_create(site)
                     site_obj.federation = fed_obj
                     site_obj.sources.append('cric-federations')
                     site_obj.tier = federation['tier_level']
                     SiteService.save(site_obj)
                     fed_obj.site_set.add(site_obj)
             for year, vos in pledges.items():
                 for vo, pledge in vos.items():
                     vo_obj = VOService.get_or_create(vo)
                     pledge_obj = PledgeService.get_or_create(
                         fed_obj, vo_obj)
                     pledge_obj.year = year
                     if 'CPU' in pledge:
                         pledge_obj.cpu = pledge['CPU']
                     if 'Disk' in pledge:
                         pledge_obj.disk = pledge['Disk']
                     if 'Tape' in pledge:
                         pledge_obj.tape = pledge['Tape']
                     PledgeService.save(pledge_obj)
                     fed_obj.pledge_set.add(pledge_obj)
             FederationsService.save(fed_obj)