def __init__(self): self.init = False if siteManager.hasConfig(SECTION_EMAIL): self.server = siteManager.get('EMAIL_SERVER', section=SECTION_EMAIL) if self.server is not None and self.server.strip() != '': self.port = siteManager.get('EMAIL_PORT', section=SECTION_EMAIL) self.sender = siteManager.get('EMAIL_SENDER', section=SECTION_EMAIL) self.username = siteManager.get('EMAIL_USERNAME', section=SECTION_EMAIL) self.password = siteManager.get('EMAIL_PASSWORD', section=SECTION_EMAIL) self.security = siteManager.get('EMAIL_SECURITY', section=SECTION_EMAIL) print 'Using email server=%s' % self.server print 'Using email port=%s' % self.port print 'Using email sender=%s' % self.sender print 'Using email username=%s' % self.username #print 'Using email password=%s' % self.password print 'Using email security=%s' % self.security self.init = True if not self.init: print "Email configuration not found, email notification disabled"
def __init__(self): print 'Executing CoG initialization tasks' # update name, domain of current site into database current_site = Site.objects.get_current() current_site.name = settings.SITE_NAME current_site.domain = settings.SITE_DOMAIN current_site.save() print 'Updated current site: name=%s domain=%s' % (current_site.name, current_site.domain) # update list of ESGF peers into database filepath = siteManager.get('PEER_NODES') try: pnl = PeerNodesList(filepath) pnl.reload() # delete=False except Exception, error: print "Could not update peer nodes from xml file", error
def __init__(self): print 'Executing CoG initialization tasks' # update name, domain of current site into database current_site = Site.objects.get_current() current_site.name = settings.SITE_NAME current_site.domain = settings.SITE_DOMAIN current_site.save() print 'Updated current site: name=%s domain=%s' % (current_site.name, current_site.domain) # update list of ESGF peers into database filepath = siteManager.get('PEER_NODES') pnl = PeerNodesList(filepath) pnl.reload() # delete=False # read IdP whitelist # remove this class from the middleware that is invoked for every request raise MiddlewareNotUsed('Do not invoke ever again')
def __init__(self): self.init = False if siteManager.hasConfig(SECTION_EMAIL): self.server = siteManager.get("EMAIL_SERVER", section=SECTION_EMAIL) if self.server is not None and self.server.strip() != "": self.port = siteManager.get("EMAIL_PORT", section=SECTION_EMAIL) self.sender = siteManager.get("EMAIL_SENDER", section=SECTION_EMAIL) self.username = siteManager.get("EMAIL_USERNAME", section=SECTION_EMAIL) self.password = siteManager.get("EMAIL_PASSWORD", section=SECTION_EMAIL) self.security = siteManager.get("EMAIL_SECURITY", section=SECTION_EMAIL) print "Using email server=%s" % self.server print "Using email port=%s" % self.port print "Using email sender=%s" % self.sender print "Using email username=%s" % self.username # print 'Using email password=%s' % self.password print "Using email security=%s" % self.security self.init = True if not self.init: print "Email configuration not found, email notification disabled"
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, authorization_header = auth_header, scope = ['openid', 'profile', 'urn:globus:auth:scope:transfer.api.globus.org:all'], redirect_uri = request.build_absolute_uri(reverse("globus_token")).replace('http:','https:'), auth_uri = GLOBUS_AUTH_URL + '/v2/oauth2/authorize', token_uri = GLOBUS_AUTH_URL + '/v2/oauth2/token')
import logging import re from cog.utils import str2bool rel = lambda *x: os.path.join(os.path.abspath(os.path.dirname(__file__)), *x) ''' SITE SPECIFIC CONFIGURATION These parameters are read from file 'cog_settings.cfg' located in directory COG_CONFIG_DIR (or by default '/usr/local/cog/cog_config'). Each parameter has a default value. ''' from cog.site_manager import siteManager from cog.constants import SECTION_ESGF, SECTION_PID SITE_NAME = siteManager.get('SITE_NAME', default='Local CoG') SITE_DOMAIN = siteManager.get('SITE_DOMAIN', default='localhost:8000') TIME_ZONE = siteManager.get('TIME_ZONE', default='America/Denver') COG_MAILING_LIST = siteManager.get('COG_MAILING_LIST', default='*****@*****.**') SECRET_KEY = siteManager.get('SECRET_KEY', default='ds4sjjj(76K=={%$HHH1@#b:l;') # for SQLLite back-end DATABASE_PATH = siteManager.get('DATABASE_PATH', default="%s/django.data" % siteManager.cog_config_dir) # for postgres back-end DATABASE_NAME = siteManager.get('DATABASE_NAME', default='cogdb') DATABASE_USER = siteManager.get('DATABASE_USER') DATABASE_PASSWORD = siteManager.get('DATABASE_PASSWORD') DATABASE_HOST = siteManager.get('DATABASE_HOST', default='localhost')
python manage.py sync_sites [--delete] ''' from optparse import make_option from xml.etree.ElementTree import fromstring from django.contrib.sites.models import Site from django.core.exceptions import ObjectDoesNotExist from django.core.management.base import BaseCommand from cog.plugins.esgf.registry import PeerNodesList from cog.site_manager import siteManager # read /esg/config/esgf_cogs.xml FILEPATH = siteManager.get('PEER_NODES') class Command(BaseCommand): help = 'Updates the list of CoG peers in the local database' def add_arguments(self, parser): # Named (optional) arguments parser.add_argument('--delete', action='store_true', dest='delete', default=False, help='Delete stale sites that are found in database but not in the XML file')
Execute as: python manage.py sync_sites [--delete] ''' from optparse import make_option from xml.etree.ElementTree import fromstring from django.contrib.sites.models import Site from django.core.exceptions import ObjectDoesNotExist from django.core.management.base import BaseCommand from cog.plugins.esgf.registry import PeerNodesList from cog.site_manager import siteManager # read /esg/config/esgf_cogs.xml FILEPATH = siteManager.get('PEER_NODES') class Command(BaseCommand): help = 'Updates the list of CoG peers in the local database' def add_arguments(self, parser): # Named (optional) arguments parser.add_argument( '--delete', action='store_true', dest='delete', default=False, help=
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) endpoints_filepath = siteManager.get('ENDPOINTS', section=SECTION_GLOBUS) GLOBUS_ENDPOINTS= LocalEndpointDict(endpoints_filepath) 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, authorization_header = auth_header, scope = 'urn:globus:auth:scope:transfer.api.globus.org:all', redirect_uri = request.build_absolute_uri(reverse("globus_token")).replace('http:','https:'), auth_uri = GLOBUS_AUTH_URL + '/v2/oauth2/authorize',
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, authorization_header=auth_header, scope=[ 'openid', 'profile', 'urn:globus:auth:scope:transfer.api.globus.org:all' ],
import re from cog.utils import str2bool rel = lambda *x: os.path.join(os.path.abspath(os.path.dirname(__file__)), *x) """ SITE SPECIFIC CONFIGURATION These parameters are read from file 'cog_settings.cfg' located in directory COG_CONFIG_DIR (or by default '/usr/local/cog/cog_config'). Each parameter has a default value. """ from cog.site_manager import siteManager from cog.constants import SECTION_ESGF SITE_NAME = siteManager.get("SITE_NAME", default="Local CoG") SITE_DOMAIN = siteManager.get("SITE_DOMAIN", default="localhost:8000") TIME_ZONE = siteManager.get("TIME_ZONE", default="America/Denver") COG_MAILING_LIST = siteManager.get("COG_MAILING_LIST", default="*****@*****.**") SECRET_KEY = siteManager.get("SECRET_KEY", default="ds4sjjj(76K=={%$HHH1@#b:l;") # for SQLLite back-end DATABASE_PATH = siteManager.get("DATABASE_PATH", default="%s/django.data" % siteManager.cog_config_dir) # for postgres back-end DATABASE_NAME = siteManager.get("DATABASE_NAME", default="cogdb") DATABASE_USER = siteManager.get("DATABASE_USER") DATABASE_PASSWORD = siteManager.get("DATABASE_PASSWORD") DATABASE_HOST = siteManager.get("DATABASE_HOST", default="localhost") DATABASE_PORT = siteManager.get("DATABASE_PORT", default=5432) MY_PROJECTS_REFRESH_SECONDS = int(siteManager.get("MY_PROJECTS_REFRESH_SECONDS", default=3600)) # one hour PWD_EXPIRATION_DAYS = int(siteManager.get("PWD_EXPIRATION_DAYS", default=0)) # 0: no expiration IDP_REDIRECT = siteManager.get("IDP_REDIRECT", default=None)