Permalink
Browse files

CA-66500: Fix metadata backup/restore for non-ASCII VM names

Patch by David Markey.

Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
  • Loading branch information...
1 parent 1faef0e commit cea9c2c6aa3be1683d53db727b0663e6a1f4b920 @robhoes robhoes committed Sep 8, 2011
Showing with 7 additions and 2 deletions.
  1. +3 −2 scripts/backup-sr-metadata.py
  2. +4 −0 scripts/restore-sr-metadata.py
View
5 scripts/backup-sr-metadata.py 100755 → 100644
@@ -6,6 +6,7 @@
import XenAPI
import sys
import getopt
+import codecs
from xml.dom.minidom import Document
def logout():
@@ -43,7 +44,7 @@ def main(argv):
if outfile == None:
usage()
- f = open(outfile, 'w')
+ f = codecs.open(outfile, 'w', encoding="utf-8")
srs = session.xenapi.SR.get_all_records()
vdis = session.xenapi.SR.get_all_records()
@@ -73,7 +74,7 @@ def main(argv):
metaxml.appendChild(srxml)
- doc.writexml(f)
+ doc.writexml(f, encoding="utf-8")
f.close()
session.xenapi.logout()
View
4 scripts/restore-sr-metadata.py 100755 → 100644
@@ -7,6 +7,10 @@
import os, sys, time
import getopt
from xml.dom.minidom import parse
+import codecs
+
+sys.stdout = codecs.getwriter("utf-8")(sys.stdout)
+sys.stderr = codecs.getwriter("utf-8")(sys.stderr)
def logout():
try:

0 comments on commit cea9c2c

Please sign in to comment.