示例#1
0
def migrateDomains(catalog):
    print "Migrating domains...",
    dh=DomainHolder()
    count=0
    for dom in catalog.dump():
        dh._getIdx()[dom.getId()]=dom
        count+=1
    print "[Done:%s]"%count
示例#2
0
def migrateDomains(catalog):
    print "Migrating domains...",
    dh = DomainHolder()
    count = 0
    for dom in catalog.dump():
        dh._getIdx()[dom.getId()] = dom
        count += 1
    print "[Done:%s]" % count
示例#3
0
def index(req, **params):

    DBMgr.getInstance().startRequest()
    Factory.getDALManager().connect()

    ################### checking protection ###################

    # check if it is a machine that belongs to the CERN domain
    cernDomain = DomainHolder().getById(0) # id 0 means CERN
    if not cernDomain.belongsTo(get_remote_ip(req)):
        return "Only CERN users can access to this export resource"

    ################### checking params ###################
    if not (params.has_key("sd") and params.has_key("ed") and params.has_key("r")):
        return """Missing parameters. The request should be like this: http://indico.cern.ch/exportReservations.py?sd=2010-09-24&ed=2010-09-25&r=1,18,114,42"""

    try:
        sd = parseDate(params.get("sd"), "%Y-%m-%d")
        ed = parseDate(params.get("ed"), "%Y-%m-%d")
    except ValueError, e:
        return """The format for the dates (sd and ed) must be like this: YYYY-MM-DD"""
示例#4
0
def index(req, **params):

    DBMgr.getInstance().startRequest()
    Factory.getDALManager().connect()

    ################### checking protection ###################

    # check if it is a machine that belongs to the CERN domain
    cernDomain = DomainHolder().getById(0)  # id 0 means CERN
    if not cernDomain.belongsTo(_get_remote_ip(req)):
        return "Only CERN users can access to this export resource"

    ################### checking params ###################
    if not (params.has_key("sd") and params.has_key("ed")
            and params.has_key("r")):
        return """Missing parameters. The request should be like this: http://indico.cern.ch/exportReservations.py?sd=2010-09-24&ed=2010-09-25&r=1,18,114,42"""

    try:
        sd = parseDate(params.get("sd"), "%Y-%m-%d")
        ed = parseDate(params.get("ed"), "%Y-%m-%d")
    except ValueError, e:
        return """The format for the dates (sd and ed) must be like this: YYYY-MM-DD"""
示例#5
0
        try:
            hostIP = socket.gethostbyname(host)
            minfo = HelperMaKaCInfo.getMaKaCInfoInstance()
            if minfo.useProxy():
                # if we're behind a proxy, use X-Forwarded-For
                xff = req.headers_in.get("X-Forwarded-For",hostIP).split(", ")[-1]
                return socket.gethostbyname(xff)
            else:
                return hostIP
        except socket.gaierror, e:
            # in case host resolution fails
            raise HostnameResolveError("Error resolving host '%s' : %s" % (host, e))


    # check if it is a machine that belongs to the CERN domain
    cernDomain = DomainHolder().getById(0) # id 0 means CERN
    if not cernDomain.belongsTo(getHostIP(req)):
        return "Only CERN users can access to this export resource"

    ################### checking params ###################
    if not (params.has_key("sd") and params.has_key("ed") and params.has_key("r")):
        return """Missing parameters. The request should be like this: http://indico.cern.ch/exportReservations.py?sd=2010-09-24&ed=2010-09-25&r=1,18,114,42"""

    try:
        sd = parseDate(params.get("sd"), "%Y-%m-%d")
        ed = parseDate(params.get("ed"), "%Y-%m-%d")
    except ValueError, e:
        return """The format for the dates (sd and ed) must be like this: YYYY-MM-DD"""
    if sd > ed:
        return """'sd' must be <= than 'ed'"""
    if ed - sd > timedelta(35):