From 0f0137fc157f898ebc253250d577ca162f512935 Mon Sep 17 00:00:00 2001 From: Nikos Skalkotos Date: Thu, 19 Dec 2013 10:41:54 +0200 Subject: [PATCH] Fix windows filesystem shrink Make it work with Windows Server 2012 R2. The format of shrink querymax command has changed. --- image_creator/os_type/windows.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/image_creator/os_type/windows.py b/image_creator/os_type/windows.py index ddf6059..7c4c127 100644 --- a/image_creator/os_type/windows.py +++ b/image_creator/os_type/windows.py @@ -49,6 +49,7 @@ import random import string import subprocess import struct +import re # For more info see: http://technet.microsoft.com/en-us/library/jj612867.aspx KMS_CLIENT_SETUP_KEYS = { @@ -255,9 +256,14 @@ class Windows(OSBase): # The maximum number of reclaimable bytes is: xxxx MB # if line.find('reclaimable') >= 0: - querymax = line.split(':')[1].split()[0].strip() - assert querymax.isdigit(), \ - "Number of reclaimable bytes not a number" + answer = line.split(':')[1].strip() + m = re.search('(\d+) MB', answer) + if m: + querymax = m.group(1) + else: + FatalError( + "Unexpected output for `shrink querymax' command: %s" % + line) if querymax is None: FatalError("Error in shrinking! " -- 1.7.10.4