From 86acc6e5546a78abb5cdf4514e5e8e0d52785c72 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Tue, 5 Oct 2010 19:43:07 +0000 Subject: Hack to remove obsolete elements from entitydb files. svn path=/scripts/convert-https-to-http.py; revision=3460 --- scripts/convert-https-to-http.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'scripts/convert-https-to-http.py') diff --git a/scripts/convert-https-to-http.py b/scripts/convert-https-to-http.py index ac5e7adf..9cfcd991 100644 --- a/scripts/convert-https-to-http.py +++ b/scripts/convert-https-to-http.py @@ -25,8 +25,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """ -import getopt, sys, os -from xml.etree.ElementTree import (Element, SubElement, ElementTree) +import getopt, sys, os, lxml.etree cfg_file = "myrpki.conf" entitydb_dir = "entitydb" @@ -56,13 +55,28 @@ for root, dirs, files in os.walk(entitydb_dir): for filename in files: if filename.endswith(".xml"): filename = os.path.join(root, filename) - tree = ElementTree(file = filename).getroot() + tree = lxml.etree.ElementTree(file = filename) changed = False for e in tree.getiterator(): + p = e.getparent() + if (e.tag in ("{http://www.hactrn.net/uris/rpki/myrpki/}bpki_https_cert", + "{http://www.hactrn.net/uris/rpki/myrpki/}bpki_https_glue", + "{http://www.hactrn.net/uris/rpki/myrpki/}bpki_https_certificate") or + (e.tag == "{http://www.hactrn.net/uris/rpki/myrpki/}bpki_server_ta" and + p.tag == "{http://www.hactrn.net/uris/rpki/myrpki/}parent")): + p.remove(e) + changed = True + continue for k, v in e.items(): if v.startswith("https://"): e.set(k, v.replace("https://", "http://")) changed = True if changed: - ElementTree(tree).write(filename + ".new") + tree.write(filename + ".new") os.rename(filename + ".new", filename) + +# Also need to do something about changes to SQL schemas? svn diff +# old and new to calculate full set of changes (including replay +# protection stuff) and include static set of ALTER COLUMN (etc) +# instructions here? Use config file to figure out SQL passwords and +# make changes automatically? Ask for permission first? -- cgit v1.2.3