<s> import logging <EOL> import json <EOL> import pdb <EOL> from pilot import * <EOL> from bigjob import logger <EOL> from saga import Url as SAGAUrl <EOL> class NoCoordinationAdaptor : <EOL> """<STR_LIT>""" <EOL> BASE_URL = "<STR_LIT>" <EOL> BASE_URL_QUERY_STRING = "<STR_LIT>" <EOL> PILOT_PATH = "<STR_LIT>" <EOL> PILOT_DATA_PATH = PILOT_PATH <EOL> PILOT_DATA_SERVICE_PATH = PILOT_DATA_PATH + "<STR_LIT>" <EOL> DATA_UNIT_SERVICE_PATH = PILOT_DATA_PATH + "<STR_LIT>" <EOL> COMPUTE_DATA_SERVICE_PATH = PILOT_DATA_PATH + "<STR_LIT>" <EOL> @ classmethod <EOL> def get_base_url ( cls , application_id ) : <EOL> surl = SAGAUrl ( cls . BASE_URL ) <EOL> base_url = surl . scheme + "<STR_LIT>" + surl . host + "<STR_LIT:/>" + application_id + "<STR_LIT:/>" <EOL> logger . debug ( base_url ) <EOL> return base_url <EOL> @ classmethod <EOL> def add_pds ( cls , application_url , pds ) : <EOL> pds_url_no_dbtype = cls . get_pds_url ( application_url , pds . id ) <EOL> pds_url = cls . __get_url ( pds_url_no_dbtype ) <EOL> logger . debug ( "<STR_LIT>" % pds_url ) <EOL> return pds_url_no_dbtype <EOL> @ classmethod <EOL> def delete_pds ( cls , pds_url ) : <EOL> pds_url = cls . __get_url ( pds_url ) <EOL> @ classmethod <EOL> def add_pd ( cls , pds_url , pd ) : <EOL> pds_url = cls . __remove_dbtype ( pds_url ) <EOL> pd_url = pds_url + "<STR_LIT:/>" + pd . id <EOL> pd_description_url = cls . __get_url ( pd_url + "<STR_LIT>" ) <EOL> logger . debug ( "<STR_LIT>" % ( pds_url , pd_description_url ) ) <EOL> return pd_url <EOL> @ classmethod <EOL> def update_pd ( cls , pd ) : <EOL> if len ( pd . data_units ) > <NUM_LIT:0> : <EOL> du_urls = [ i . url for i in pd . data_units . values ( ) ] <EOL> @ classmethod <EOL> def get_pd ( cls , pds_url ) : <EOL> logger . debug ( "<STR_LIT>" + pds_url ) <EOL> pd_dict = { } <EOL> @ classmethod <EOL> def list_pd ( cls , pds_url ) : <EOL> """<STR_LIT>""" <EOL> pds_url = cls . __get_url ( pds_url ) <EOL> logger . debug ( "<STR_LIT>" % pds_url ) <EOL> @ classmethod <EOL> def delete_pd ( cls , pds_url ) : <EOL> pds_url = cls . __get_url ( pds_url ) <EOL> @ classmethod <EOL> def add_cds ( cls , application_url , cds ) : <EOL> cds_url_no_dbtype = cls . get_cds_url ( application_url , cds . id ) <EOL> cds_url = cls . __get_url ( cds_url_no_dbtype ) <EOL> logger . debug ( "<STR_LIT>" % cds_url ) <EOL> return cds_url_no_dbtype <EOL> @ classmethod <EOL> def update_cds ( cls , cds_url , cds ) : <EOL> pds_urls = [ cls . __remove_dbtype ( i . url ) for i in cds . pilot_data_services ] <EOL> pjs_urls = [ i . url for i in cds . pilot_job_services ] <EOL> pd_urls = [ i . url for i in cds . data_units . values ( ) ] <EOL> wu_urls = [ i . url for i in cds . compute_units . values ( ) ] <EOL> @ classmethod <EOL> def delete_cds ( cls , cds_url ) : <EOL> cds_url = cls . __get_url ( cls . __remove_dbtype ( cds_url ) ) <EOL> @ classmethod <EOL> def add_du ( cls , dus_url , du ) : <EOL> du_url = cls . __remove_dbtype ( dus_url ) + "<STR_LIT:/>" + du . id <EOL> du_url = cls . __get_url ( du_url ) <EOL> return du_url <EOL> @ classmethod <EOL> def get_du ( cls , du_url ) : <EOL> logger . debug ( "<STR_LIT>" + du_url ) <EOL> du_dict = { } <EOL> return du_dict <EOL> @ classmethod <EOL> def update_du ( cls , du ) : <EOL> logger . debug ( "<STR_LIT>" + du . url ) <EOL> du_urls = [ i . url for i in du . pilot_data ] <EOL> du_dict_list = [ i . to_dict ( ) for i in du . data_unit_items ] <EOL> @ classmethod <EOL> def list_du ( cls , dus_url ) : <EOL> """<STR_LIT>""" <EOL> dus_url = cls . __get_url ( dus_url ) <EOL> logger . debug ( "<STR_LIT>" % dus_url ) <EOL> return du_full_urls <EOL> @ classmethod <EOL> def delete_du ( cls , du_url ) : <EOL> du_url = cls . __get_url ( du_url ) <EOL> @ classmethod <EOL> def get_pds_url ( cls , application_url , pds_id ) : <EOL> pds_url = application_url + NoCoordinationAdaptor . PILOT_DATA_SERVICE_PATH + "<STR_LIT:/>" + pds_id <EOL> logger . debug ( "<STR_LIT>" % ( pds_url ) ) <EOL> return pds_url <EOL> @ classmethod <EOL> def get_cds_url ( cls , application_url , cds_id ) : <EOL> cds_url = application_url + NoCoordinationAdaptor . COMPUTE_DATA_SERVICE_PATH + "<STR_LIT:/>" + cds_id <EOL> logger . debug ( "<STR_LIT>" % ( cds_url ) ) <EOL> return cds_url <EOL> @ classmethod <EOL> def __get_url ( cls , url ) : <EOL> """<STR_LIT>""" <EOL> url = url + NoCoordinationAdaptor . BASE_URL_QUERY_STRING <EOL> return url <EOL> @ classmethod <EOL> def __remove_dbtype ( cls , url ) : <EOL> surl = SAGAUrl ( url ) <EOL> return str ( surl ) <EOL> @ classmethod <EOL> def __store_entry ( cls , entry_url , content ) : <EOL> entry_url = cls . __get_url ( entry_url ) <EOL> @ classmethod <EOL> def __retrieve_entry ( cls , entry_url ) : <EOL> entry_url = cls . __get_url ( entry_url ) <EOL> return content </s>
