~jcsackett/charmworld/bac-tag-constraints

« back to all changes in this revision

Viewing changes to charmworld/migrations/versions/021_drop_unproofed_bundles.py

  • Committer: Benji York
  • Date: 2013-11-18 20:38:47 UTC
  • mto: This revision was merged to the branch mainline in revision 465.
  • Revision ID: benji@benjiyork.com-20131118203847-2mfs1w7b8aqy64mr
checkpoint

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Drop existing bundles as they have not been run through charm-proof.
 
2
 
 
3
from pyelasticsearch.exceptions import (
 
4
    ElasticHttpNotFoundError,
 
5
)
 
6
 
 
7
def upgrade(db, index_client):
 
8
    """Complete this function with work to be done for the migration/update.
 
9
 
 
10
    db is the pymongo db instance for our datastore. Charms are in db.charms
 
11
    for instance.
 
12
    """
 
13
 
 
14
    # Remove all bundles from elasticsearch.
 
15
    for bundle_data in db.bundles.find():
 
16
        try:
 
17
            index_client.delete_bundle(bundle_data)
 
18
        except ElasticHttpNotFoundError as e:
 
19
            continue
 
20
 
 
21
    # Drop all bundles from mongo.
 
22
    db.bundles.drop()