def _external_integration(self, protocol, goal=None, settings=None, libraries=None, **kwargs): integration = None if not libraries: integration, ignore = get_one_or_create(self._db, ExternalIntegration, protocol=protocol, goal=goal) else: if not isinstance(libraries, list): libraries = [libraries] # Try to find an existing integration for one of the given # libraries. for library in libraries: integration = ExternalIntegration.lookup(self._db, protocol, goal, library=libraries[0]) if integration: break if not integration: # Otherwise, create a brand new integration specifically # for the library. integration = ExternalIntegration( protocol=protocol, goal=goal, ) integration.libraries.extend(libraries) self._db.add(integration) for attr, value in kwargs.items(): setattr(integration, attr, value) settings = settings or dict() for key, value in settings.items(): integration.set_setting(key, value) return integration
def _external_integration(self, protocol, goal=None, settings=None, libraries=None, **kwargs ): integration = None if not libraries: integration, ignore = get_one_or_create( self._db, ExternalIntegration, protocol=protocol, goal=goal ) else: if not isinstance(libraries, list): libraries = [libraries] # Try to find an existing integration for one of the given # libraries. for library in libraries: integration = ExternalIntegration.lookup( self._db, protocol, goal, library=libraries[0] ) if integration: break if not integration: # Otherwise, create a brand new integration specifically # for the library. integration = ExternalIntegration( protocol=protocol, goal=goal, ) integration.libraries.extend(libraries) self._db.add(integration) for attr, value in kwargs.items(): setattr(integration, attr, value) settings = settings or dict() for key, value in settings.items(): integration.set_setting(key, value) return integration
log_import(cdn) # Import Elasticsearch configuration. elasticsearch_conf = Configuration.integration(u'Elasticsearch') if elasticsearch_conf: url = elasticsearch_conf.get('url') works_index = elasticsearch_conf.get( ExternalSearchIndex.WORKS_INDEX_KEY) integration = EI(protocol=EI.ELASTICSEARCH, goal=EI.SEARCH_GOAL) _db.add(integration) if url: integration.url = unicode(url) if works_index: integration.set_setting(ExternalSearchIndex.WORKS_INDEX_KEY, works_index) log_import(integration) # Import S3 configuration. s3_conf = Configuration.integration('S3') if s3_conf: username = s3_conf.get('access_key') password = s3_conf.get('secret_key') del s3_conf['access_key'] del s3_conf['secret_key'] integration = EI(protocol=EI.S3, goal=EI.STORAGE_GOAL) _db.add(integration) integration.username = username integration.password = password
log_import(cdn) # Import Elasticsearch configuration. elasticsearch_conf = Configuration.integration(u'Elasticsearch') if elasticsearch_conf: url = elasticsearch_conf.get('url') works_index = elasticsearch_conf.get(ExternalSearchIndex.WORKS_INDEX_KEY) integration = EI(protocol=EI.ELASTICSEARCH, goal=EI.SEARCH_GOAL) _db.add(integration) if url: integration.url = unicode(url) if works_index: integration.set_setting( ExternalSearchIndex.WORKS_INDEX_KEY, works_index ) log_import(integration) # Import S3 configuration. s3_conf = Configuration.integration('S3') if s3_conf: username = s3_conf.get('access_key') password = s3_conf.get('secret_key') del s3_conf['access_key'] del s3_conf['secret_key'] integration = EI(protocol=EI.S3, goal=EI.STORAGE_GOAL) _db.add(integration) integration.username = username