Example #1
0
def recordUrls(record):
    '''
    Returns an ordered list of URL endpoints for this record.
    Note: the URL parts must match the values used by _services_js.html.
    '''
    
    urls = []
    
    #record.printme()
        
    # add all existing URL endpoints (THREDDS, LAS etc...)
    if 'url' in record.fields:
        for value in record.fields['url']:
            urls.append(value)
        
    # add special WGET endpoint
    urls.append( ("javascript:wgetScript('%s','%s','%s')" % (record.fields['index_node'][0], record.fields.get('shard', [''])[0], record.id) , 
                  "application/wget", 
                  "WGET Script") )
    
    # add Globus endpoints
    if siteManager.isGlobusEnabled():  # only if this node has been registered with Globus
        if 'access' in record.fields and 'index_node' in record.fields and 'data_node' in record.fields:
            index_node = record.fields['index_node'][0]
            data_node = record.fields['data_node'][0]
            
            for value in record.fields['access']:
            	if value.lower() == 'globus':
                	gurl = '/globus/download?dataset=%s@%s' %(record.id, index_node)
                	if record.fields.get('shard', None):
                		gurl += "&shard="+record.fields.get('shard')[0]
                	urls.append( (gurl, 'application/gridftp', 'GridFTP') )
                	            
    return sorted(urls, key = lambda url: url_order(url[1]))
Example #2
0
def recordUrls(record):
    '''
    Returns an ordered list of URL endpoints for this record.
    Note: the URL parts must match the values used by _services_js.html.
    '''
    
    urls = []
    
    #record.printme()
        
    # add all existing URL endpoints (THREDDS, LAS etc...)
    if 'url' in record.fields:
        for value in record.fields['url']:
            urls.append(value)
        
    # add special WGET endpoint
    urls.append( ("javascript:wgetScript('%s','%s','%s')" % (record.fields['index_node'][0], record.fields.get('shard', [''])[0], record.id) , 
                  "application/wget", 
                  "WGET Script") )
    
    # add GridFTP endpoint
    if siteManager.isGlobusEnabled():  # only if this node has been registered with Globus
        if 'access' in record.fields and 'index_node' in record.fields and 'data_node' in record.fields:
            index_node = record.fields['index_node'][0]
            data_node = record.fields['data_node'][0]
            
            # try adding "Globus" access first
            globusAccess = False
            for value in record.fields['access']:
            	if value.lower() == 'globus':
                	gurl = '/globus/download?dataset=%s@%s' %(record.id, index_node)
                	if record.fields.get('shard', None):
                		gurl += "&shard="+record.fields.get('shard')[0]
                	urls.append( (gurl, 'application/gridftp', 'GridFTP') )
                	globusAccess = True
                	
            # if not found, try to add GridFTP access
            if not globusAccess:
	            for value in record.fields['access']:
					if value.lower() == 'gridftp':
						# data_node must appear in list of valid Globus endpoints (example: "esg-datanode.jpl.nasa.gov:2811")
						for gridftp_url in GLOBUS_ENDPOINTS.endpointDict().keys():
							gurl = '/globus/download?dataset=%s@%s' %(record.id, index_node)
							if record.fields.get('shard', None):
								gurl += "&shard="+record.fields.get('shard')[0]
							if data_node in gridftp_url:
								urls.append( (gurl,
											  'application/gridftp', # must match: var GRIDFTP = 'application/gridftp'
											  'GridFTP') )
            
    return sorted(urls, key = lambda url: url_order(url[1]))
Example #3
0
	def _decorator(request, *args, **kwargs):
		
		if siteManager.isGlobusEnabled():
			return view_func(request, *args, **kwargs)
		else:
			return HttpResponseForbidden(GLOBUS_NOT_ENABLED_MESSAGE)
Example #4
0
DOWNLOAD_METHOD_SCRIPT = 'script'
DOWNLOAD_LIMIT = 10000 # default maximum number of files to download for each dataset

# session attribute keys
GLOBUS_DOWNLOAD_MAP = 'globus_download_map'
GLOBUS_ACCESS_TOKEN = 'globus_access_token'
GLOBUS_USERNAME = '******'
TARGET_ENDPOINT = 'target_endpoint'
TARGET_FOLDER = 'target_folder'
ESGF_PASSWORD = '******'

# external URLs
GLOBUS_SELECT_DESTINATION_URL = 'https://www.globus.org/app/browse-endpoint'
GLOBUS_AUTH_URL = 'https://auth.globus.org'

if siteManager.isGlobusEnabled():

	from base64 import urlsafe_b64encode
	from oauth2client import client as oauth_client
	from cog.plugins.globus.transfer import activateEndpoint, submitTransfer, generateGlobusDownloadScript
	from globusonline.transfer.api_client import TransferAPIClient

	client_id = siteManager.get('OAUTH_CLIENT_ID', section=SECTION_GLOBUS)
	client_secret = siteManager.get('OAUTH_CLIENT_SECRET', section=SECTION_GLOBUS)


def establishFlow(request):
	basic_auth_str = urlsafe_b64encode("{}:{}".format(client_id, client_secret))
	auth_header = "Basic " + basic_auth_str
	return oauth_client.OAuth2WebServerFlow(
		client_id = client_id,
Example #5
0
    def _decorator(request, *args, **kwargs):

        if siteManager.isGlobusEnabled():
            return view_func(request, *args, **kwargs)
        else:
            return HttpResponseForbidden(GLOBUS_NOT_ENABLED_MESSAGE)
Example #6
0
DOWNLOAD_METHOD_SCRIPT = 'script'
DOWNLOAD_LIMIT = 10000  # default maximum number of files to download for each dataset

# session attribute keys
GLOBUS_DOWNLOAD_MAP = 'globus_download_map'
GLOBUS_ACCESS_TOKEN = 'globus_access_token'
GLOBUS_USERNAME = '******'
TARGET_ENDPOINT = 'target_endpoint'
TARGET_FOLDER = 'target_folder'
ESGF_PASSWORD = '******'

# external URLs
GLOBUS_SELECT_DESTINATION_URL = 'https://www.globus.org/app/browse-endpoint'
GLOBUS_AUTH_URL = 'https://auth.globus.org'

if siteManager.isGlobusEnabled():

    from base64 import urlsafe_b64encode
    from oauth2client import client as oauth_client
    from cog.plugins.globus.transfer import activateEndpoint, submitTransfer, generateGlobusDownloadScript
    from globusonline.transfer.api_client import TransferAPIClient

    client_id = siteManager.get('OAUTH_CLIENT_ID', section=SECTION_GLOBUS)
    client_secret = siteManager.get('OAUTH_CLIENT_SECRET',
                                    section=SECTION_GLOBUS)


def establishFlow(request):
    basic_auth_str = urlsafe_b64encode("{}:{}".format(client_id,
                                                      client_secret))
    auth_header = "Basic " + basic_auth_str