~benji/charmworld/jam-bundle

« back to all changes in this revision

Viewing changes to charmworld/models.py

  • Committer: Tarmac
  • Author(s): Benji York
  • Date: 2013-07-29 15:15:25 UTC
  • mfrom: (320.1.8 bundle-indexing)
  • Revision ID: tarmac-20130729151525-b5f27i57ac23xewe
[r=benji,abentley][bug=][author=benji] Index bundles as part of ingest.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    quote_key,
29
29
)
30
30
from charmworld.search import ElasticSearchClient
 
31
from charmworld.jobs.config import settings
31
32
 
32
33
OBSOLETE_SERIES = set(['oneiric'])
33
34
 
1213
1214
    return options
1214
1215
 
1215
1216
 
1216
 
def store_bundles(collection, deployer_data, basket_id):
1217
 
    for key in deployer_data:
 
1217
def store_bundles(collection, deployer_config, basket_id):
 
1218
    """Store a basket of bundles into both MongoDB and ElasticSearch."""
 
1219
    index_client = ElasticSearchClient.from_settings(settings)
 
1220
    index_client.index_bundles(deployer_config.values())
 
1221
    for key in deployer_config:
1218
1222
        bundle_doc = {
1219
1223
            '_id': '%s/%s' % (basket_id, key),
1220
 
            'data': get_flattened_deployment(deployer_data, key),
 
1224
            'data': get_flattened_deployment(deployer_config, key),
1221
1225
        }
1222
1226
        collection.save(bundle_doc)
1223
1227