Created
June 24, 2016 18:47
-
-
Save ytjohn/a4f4f99ac9146a21e23c04c558b329a1 to your computer and use it in GitHub Desktop.
add interface-map to rubicon catalog data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# requires: `pip install pymongo` | |
from pymongo import MongoClient | |
INTERFACE_MAP = {"p3p2": "eth1", "p3p1": "eth0"} | |
def update_catalogs(db): | |
result = db.catalogs.update_many( | |
{u'source': u'rubicon'}, | |
{ | |
"$set": { | |
"data.interface-map": INTERFACE_MAP | |
}, | |
} | |
) | |
print(result.matched_count) | |
print(result.modified_count) | |
if __name__ == '__main__': | |
client = MongoClient() | |
db = client.pxe | |
r1 = db.catalogs.find({"source": "rubicon"}) | |
print("{0} found".format(r1.count())) | |
print r1[0] | |
update_catalogs(db) | |
r2 = db.catalogs.find({"source": "rubicon"}) | |
print("{0} found".format(r2.count())) | |
print r1[0]['data']['interface-map'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is heavy fisted because it updates any catalog of source rubicon. Once we get away from Dell Ark nodes, we will not want to run this.