예제 #1
0
def main(app):
    argparser = utils.getArgParser()
    logger = utils.getLogger('var/log/cregsync_link_rs2rsc.log')
    args = argparser.parse_args()
    logger.info("'link_rs2rsc.py' called with '%s'" % args)

    site = utils.getSite(app, args.site_id, args.admin_id)
    logger.info("Got site '%s' as '%s'" % (args.site_id, args.admin_id))

    creg_links = utils.getData(args.path, args.filename)   # returns a csv.DictReader instance
    link_data = utils.prepare_links(creg_links, site)   # returns a dict; keys are RS uids, values RSC uids
    catalog = site.portal_catalog
        
    logger.info("Iterating over the link data")

    for k, v in link_data.items():
        search = catalog(UID=k)
        rs = search[0].getObject()
        logger.info("Linking '%s' to '%s'" % (rs.Title(),v))
        rs.setService_components(v)
        rs.reindexObject()

    if not args.dry:
        logger.info("Committing changes to database")
        import transaction
        transaction.commit()
    else:
        logger.info("dry run; not committing anything")
            
    logger.info("Done")
예제 #2
0
def main(app):
    argparser = utils.getArgParser()
    logger = utils.getLogger('var/log/cregsync_link_rs2rsc.log')
    args = argparser.parse_args()
    logger.info("'link_rs2rsc.py' called with '%s'" % args)

    site = utils.getSite(app, args.site_id, args.admin_id)
    logger.info("Got site '%s' as '%s'" % (args.site_id, args.admin_id))

    creg_links = utils.getData(
        args.path, args.filename)  # returns a csv.DictReader instance
    link_data = utils.prepare_links(
        creg_links, site)  # returns a dict; keys are RS uids, values RSC uids
    catalog = site.portal_catalog

    logger.info("Iterating over the link data")

    for k, v in link_data.items():
        search = catalog(UID=k)
        rs = search[0].getObject()
        logger.info("Linking '%s' to '%s'" % (rs.Title(), v))
        rs.setService_components(v)
        rs.reindexObject()

    if not args.dry:
        logger.info("Committing changes to database")
        import transaction
        transaction.commit()
    else:
        logger.info("dry run; not committing anything")

    logger.info("Done")
예제 #3
0
def main(app):
    argparser = utils.getArgParser()
    logger = utils.getLogger('var/log/cregsync_services.log')
    args = argparser.parse_args()
    logger.info("'services.py' called with '%s'" % args)

    site = utils.getSite(app, args.site_id, args.admin_id)
    logger.info("Got site '%s' as '%s'" % (args.site_id, args.admin_id))

    targetfolder = site.catalog
    # returns a list of dicts with service data
    spmt_services = utils.getServiceData(args.path, args.filename)
    email2puid = utils.email2puid(site)

    logger.info("Iterating over the service data")
    for entry in spmt_services:
        shortname = entry['name']
        id = prepareid(shortname)
        if id is None:
            logger.warning("Couldn't generate id for ", values)
            continue
        if id not in targetfolder.objectIds():
            targetfolder.invokeFactory('Service', id)
            logger.info("Added %s to the 'catalog' folder" % id)

        # retrieve data to extended rather than overwrite
        additional = targetfolder[id].getAdditional()
        data = preparedata(entry, site, additional, email2puid)
        logger.debug(data)
        targetfolder[id].edit(**data)
        targetfolder[id].reindexObject()
        site.portal_repository.save(obj=targetfolder[id],
                                    comment="Synchronization from SPMT")
        logger.info("Updated %s in the 'catalog' folder" % id)
        if args.top: continue
        try:
            data = entry['service_details_list']['service_details'][0]
            # we assume there is at most one
            addDetails(site, targetfolder[id], data, logger)
        except IndexError:
            pass

    if not args.dry:
        logger.info("Committing changes to database")
        import transaction
        transaction.commit()
    else:
        logger.info("dry run; not committing anything")

    logger.info("Done")
예제 #4
0
def main(app):
    argparser = utils.getArgParser()
    logger = utils.getLogger('var/log/cregsync_services.log')
    args = argparser.parse_args()
    logger.info("'services.py' called with '%s'" % args)

    site = utils.getSite(app, args.site_id, args.admin_id)
    logger.info("Got site '%s' as '%s'" % (args.site_id, args.admin_id))

    targetfolder = site.catalog
    # returns a list of dicts with service data
    spmt_services = utils.getServiceData(args.path, args.filename)   
    email2puid = utils.email2puid(site)
        
    logger.info("Iterating over the service data")
    for entry in spmt_services:
        shortname = entry['name']
        id = prepareid(shortname)
        if id is None:
            logger.warning("Couldn't generate id for ", values)
            continue
        if id not in targetfolder.objectIds():
            targetfolder.invokeFactory('Service', id)
            logger.info("Added %s to the 'catalog' folder" % id)

        # retrieve data to extended rather than overwrite
        additional = targetfolder[id].getAdditional()
        data = preparedata(entry, site, additional, email2puid)
        logger.debug(data)
        targetfolder[id].edit(**data)
        targetfolder[id].reindexObject()
        site.portal_repository.save(obj=targetfolder[id], 
                                    comment="Synchronization from SPMT")
        logger.info("Updated %s in the 'catalog' folder" % id)
        if args.top: continue
        try:
            data = entry['service_details_list']['service_details'][0]  
            # we assume there is at most one
            addDetails(site, targetfolder[id], data, logger)
        except IndexError:
            pass

    if not args.dry:
        logger.info("Committing changes to database")
        import transaction
        transaction.commit()
    else:
        logger.info("dry run; not committing anything")
            
    logger.info("Done")
def main(app):
    argparser = utils.getArgParser()
    logger = utils.getLogger('var/log/cregsync_reg_service_components.log')
    args = argparser.parse_args()
    logger.info("'reg_service_components.py' called with '%s'" % args)

    site = utils.getSite(app, args.site_id, args.admin_id)
    logger.info("Got site '%s' as '%s'" % (args.site_id, args.admin_id))

    creg_services = utils.getData(
        args.path, args.filename)  # returns a csv.DictReader instance
    extension_properties = utils.getProperties(
        args.path, 'SERVICE_PROPERTIES_DATA_TABLE.csv')
    email2puid = utils.email2puid(site)

    logger.info("Iterating over the service data")
    for entry in creg_services:
        id = prepareid('_'.join([entry['HOSTNAME'], entry['ID']]))
        if id is None:
            logger.warning("Couldn't generate id for ", entry)
            continue
        targetfolder = getTargetFolder(site, entry)
        if targetfolder is None:
            continue
        if id not in targetfolder.objectIds():
            targetfolder.invokeFactory('RegisteredServiceComponent', id)
            logger.info("Added '%s' to '%s'" % (id, targetfolder.Title()))

        # retrieve data to extended rather than overwritten
        additional = targetfolder[id].getAdditional()
        extensions = extension_properties.get(entry['ID'], [])
        data = preparedata(entry, site, additional, extensions, email2puid)
        logger.debug(data)
        targetfolder[id].edit(**data)
        targetfolder[id].reindexObject()
        site.portal_repository.save(
            obj=targetfolder[id],
            comment="Syncronization from Central Registry")
        logger.info("Updated '%s' in '%s'" % (id, targetfolder.Title()))

    if not args.dry:
        logger.info("Committing changes to database")
        import transaction
        transaction.commit()
    else:
        logger.info("dry run; not committing anything")

    logger.info("Done")
예제 #6
0
def main(app):
    argparser = utils.getArgParser()
    logger = utils.getLogger('var/log/cregsync_providers.log')
    args = argparser.parse_args()
    logger.info("'providers.py' called with '%s'" % args)

    site = utils.getSite(app, args.site_id, args.admin_id)
    logger.info("Got site '%s' as '%s'" % (args.site_id, args.admin_id))

    targetfolder = site.providers
    creg_sites = utils.getData(
        args.path, args.filename)  # returns a csv.DictReader instance
    email2puid = utils.email2puid(site)

    logger.info("Iterating over the provider data")
    for entry in creg_sites:
        shortname = entry['SHORTNAME']
        # our one hard-coded exception here:
        if shortname == 'RZG':
            shortname = "MPCDF"
        id = prepareid(shortname)
        if id is None:
            logger.warning("Couldn't generate id for ", values)
            continue
        if id not in targetfolder.objectIds():
            targetfolder.invokeFactory('Provider', id)
            logger.info("Added %s to the providers folder" % id)

        # retrieve data to extended rather than overwritten
        additional = targetfolder[id].getAdditional()
        data = preparedata(entry, site, additional, email2puid)
        logger.debug(data)
        targetfolder[id].edit(**data)
        targetfolder[id].reindexObject()
        site.portal_repository.save(
            obj=targetfolder[id],
            comment="Syncronization from Central Registry")
        logger.info("Updated %s in the providers folder" % id)

    if not args.dry:
        logger.info("Committing changes to database")
        import transaction
        transaction.commit()
    else:
        logger.info("dry run; not committing anything")

    logger.info("Done")
예제 #7
0
def main(app):
    argparser = utils.getArgParser()
    logger = utils.getLogger('var/log/cregsync_stypes.log')
    args = argparser.parse_args()
    logger.info("'stypes_vocab.py' called with '%s'" % args)

    site = utils.getSite(app, args.site_id, args.admin_id)
    logger.info("Got site '%s' as '%s'" % (args.site_id, args.admin_id))

    # sneak in default filename if not given
    filename = args.filename
    if not filename:
        filename = "SERVICETYPES_DATA_TABLE.csv"

    tool = site.portal_vocabularies
    creg_types = utils.getData(args.path, filename)   # returns a csv.DictReader instance

    # make sure the vocab exists
    vocab_id = 'service_types'
    if vocab_id not in tool.objectIds():
        tool.invokeFactory('SimpleVocabulary', 
                           vocab_id, 
                           title='Service Types for Registered Service Components'
        )
    targetfolder = tool[vocab_id]

    logger.info("Iterating over the service types data")
    for entry in creg_types:
        id = entry['ID']
        if id not in targetfolder.objectIds():
            targetfolder.invokeFactory('SimpleVocabularyTerm', id)
            logger.info("Added '%s' to the service types vocablary" % id)
        data = {'title':entry['NAME'],
                'description':entry['DESCRIPTION']}
        logger.debug(data)
        targetfolder[id].edit(**data)
        logger.info("Updated '%s' in the service types vocabulary" % id)

    if not args.dry:
        logger.info("Committing changes to database")
        import transaction
        transaction.commit()
    else:
        logger.info("dry run; not committing anything")
            
    logger.info("Done")
def main(app):
    argparser = utils.getArgParser()
    logger = utils.getLogger('var/log/cregsync_reg_service_components.log')
    args = argparser.parse_args()
    logger.info("'reg_service_components.py' called with '%s'" % args)

    site = utils.getSite(app, args.site_id, args.admin_id)
    logger.info("Got site '%s' as '%s'" % (args.site_id, args.admin_id))

    creg_services = utils.getData(args.path, args.filename)   # returns a csv.DictReader instance
    extension_properties = utils.getProperties(args.path, 'SERVICE_PROPERTIES_DATA_TABLE.csv')
    email2puid = utils.email2puid(site)

    logger.info("Iterating over the service data")
    for entry in creg_services:
        id = prepareid('_'.join([entry['HOSTNAME'], entry['ID']]))
        if id is None:
            logger.warning("Couldn't generate id for ", entry)
            continue
        targetfolder = getTargetFolder(site, entry)
        if targetfolder is None:
            continue
        if id not in targetfolder.objectIds():
            targetfolder.invokeFactory('RegisteredServiceComponent', id)
            logger.info("Added '%s' to '%s'" % (id, targetfolder.Title()))

        # retrieve data to extended rather than overwritten
        additional = targetfolder[id].getAdditional()
        extensions = extension_properties.get(entry['ID'], [])
        data = preparedata(entry, site, additional, extensions, email2puid)
        logger.debug(data)
        targetfolder[id].edit(**data)
        targetfolder[id].reindexObject()
        site.portal_repository.save(obj=targetfolder[id], 
                                    comment="Syncronization from Central Registry")
        logger.info("Updated '%s' in '%s'" % (id, targetfolder.Title()))

    if not args.dry:
        logger.info("Committing changes to database")
        import transaction
        transaction.commit()
    else:
        logger.info("dry run; not committing anything")
            
    logger.info("Done")
예제 #9
0
def main(app):
    argparser = utils.getArgParser()
    logger = utils.getLogger('var/log/cregsync_providers.log')
    args = argparser.parse_args()
    logger.info("'providers.py' called with '%s'" % args)

    site = utils.getSite(app, args.site_id, args.admin_id)
    logger.info("Got site '%s' as '%s'" % (args.site_id, args.admin_id))

    targetfolder = site.providers
    creg_sites = utils.getData(args.path, args.filename)   # returns a csv.DictReader instance
    email2puid = utils.email2puid(site)
        
    logger.info("Iterating over the provider data")
    for entry in creg_sites:
        shortname = entry['SHORTNAME']
        # our one hard-coded exception here:
        if shortname == 'RZG':
            shortname = "MPCDF"
        id = prepareid(shortname)
        if id is None:
            logger.warning("Couldn't generate id for ", values)
            continue
        if id not in targetfolder.objectIds():
            targetfolder.invokeFactory('Provider', id)
            logger.info("Added %s to the providers folder" % id)

        # retrieve data to extended rather than overwritten
        additional = targetfolder[id].getAdditional()
        data = preparedata(entry, site, additional, email2puid)
        logger.debug(data)
        targetfolder[id].edit(**data)
        targetfolder[id].reindexObject()
        site.portal_repository.save(obj=targetfolder[id], 
                                    comment="Syncronization from Central Registry")
        logger.info("Updated %s in the providers folder" % id)

    if not args.dry:
        logger.info("Committing changes to database")
        import transaction
        transaction.commit()
    else:
        logger.info("dry run; not committing anything")
            
    logger.info("Done")