now can capture instances with chinese characters
remove prefix('\u') of chinese unicode when snapshotting or booting an instance the image name will store as the format without prefix,like: '\u6d4b\u8bd5\u7528\u4f8b' --> '6d4b8bd575284f8b' add a function in util.py for code reuse add a test for this function Change-Id: I1bfc6ace2b74e4cfab3a6c6a36c31629e4290bf4
This commit is contained in:
parent
c91759e280
commit
dbcf0f53ac
|
@ -2400,6 +2400,12 @@ class ZVMUtilsTestCases(ZVMTestCase):
|
|||
self.assertEqual(20, zvmutils.convert_to_mb('20M'))
|
||||
self.assertEqual(1153433.6, zvmutils.convert_to_mb('1.1T'))
|
||||
|
||||
def test_remove_prefix_of_unicode(self):
|
||||
self.assertEqual(u'6d4b8bd575284f8b',
|
||||
zvmutils.remove_prefix_of_unicode(u'\u6d4b\u8bd5\u7528\u4f8b'))
|
||||
self.assertEqual('uuuuasd81m.qw38927u',
|
||||
zvmutils.remove_prefix_of_unicode('uuuuasd81m.qw38927u'))
|
||||
|
||||
|
||||
class ZVMConfigDriveTestCase(test.NoDBTestCase):
|
||||
|
||||
|
|
|
@ -537,9 +537,9 @@ class ZVMDriver(driver.ComputeDriver):
|
|||
|
||||
LOG.debug("Generating the manifest.xml as a part of bundle file for "
|
||||
"image %s", image_meta['id'], instance=instance)
|
||||
image_name = image_name.encode('unicode_escape')
|
||||
image_name = image_name.replace('\u', '')
|
||||
image_name = image_name.decode('utf-8')
|
||||
|
||||
image_name = zvmutils.remove_prefix_of_unicode(image_name)
|
||||
|
||||
self._zvm_images.generate_manifest_file(image_meta, image_name,
|
||||
disk_file, bundle_file_path)
|
||||
|
||||
|
@ -787,6 +787,7 @@ class ZVMDriver(driver.ComputeDriver):
|
|||
# remove user names special characters, this name will only be used
|
||||
# to pass to xcat and combine with UUID in xcat.
|
||||
image_name = ''.join(i for i in image_meta['name'] if i.isalnum())
|
||||
image_name = zvmutils.remove_prefix_of_unicode(image_name)
|
||||
image_name_xcat = None
|
||||
|
||||
# Make sure the instance's power_state is running and unpaused before
|
||||
|
|
|
@ -291,6 +291,13 @@ def get_xcat_url():
|
|||
return _XCAT_URL
|
||||
|
||||
|
||||
def remove_prefix_of_unicode(str_unicode):
|
||||
str_unicode = str_unicode.encode('unicode_escape')
|
||||
str_unicode = str_unicode.replace('\u', '')
|
||||
str_unicode = str_unicode.decode('utf-8')
|
||||
return str_unicode
|
||||
|
||||
|
||||
class XCATConnection(object):
|
||||
"""Https requests to xCAT web service."""
|
||||
|
||||
|
|
Loading…
Reference in New Issue