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 = {
'boot_timeout', int, 300, "Boot Timeout (seconds)", _POSINT)
@add_sysprep_param(
'connection_retries', int, 5, "Connection Retries", _POSINT)
+ @add_sysprep_param(
+ 'smp', int, 1, "Number of CPUs for the helper VM", _POSINT)
+ @add_sysprep_param(
+ 'mem', int, 1024, "Virtual RAM size for the helper VM (MiB)", _POSINT)
@add_sysprep_param('password', str, None, 'Image Administrator Password')
def __init__(self, image, **kargs):
super(Windows, self).__init__(image, **kargs)
raise FatalError(
'For windows support libguestfs 1.16.11 or above is required')
+ # Check if winexe is installed
+ if not WinEXE.is_installed():
+ raise FatalError(
+ "For windows support `Winexe' needs to be installed")
+
device = self.image.g.part_to_dev(self.root)
self.last_part_num = self.image.g.part_list(device)[-1]['part_num']
self._guest_exec(
r"cmd /q /c for /f %l in ('wevtutil el') do wevtutil cl %l")
- @sysprep('Executing Sysprep on the image (may take more that 10 minutes)')
+ @sysprep('Executing Sysprep on the image (may take more that 10 min)')
def microsoft_sysprep(self):
"""Run the Microsoft System Preparation Tool. This will remove
system-specific data and will make the image ready to be deployed.
# 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! "
monitorfd, monitor = tempfile.mkstemp()
os.close(monitorfd)
vm = _VM(self.image.device, monitor, self.sysprep_params)
- self.out.success("started (console on vnc display: %d)." %
+ self.out.success("started (console on VNC display: %d)" %
vm.display)
self.out.output("Waiting for OS to boot ...", False)
args.extend(needed_args)
args.extend([
- '-smp', '1', '-m', '1024', '-drive',
- 'file=%s,format=raw,cache=unsafe,if=virtio' % self.disk,
+ '-smp', str(self.params['smp']), '-m', str(self.params['mem']),
+ '-drive', 'file=%s,format=raw,cache=unsafe,if=virtio' % self.disk,
'-netdev', 'type=user,hostfwd=tcp::445-:445,id=netdev0',
'-device', 'virtio-net-pci,mac=%s,netdev=netdev0' % random_mac(),
'-vnc', ':%d' % self.display, '-serial', 'file:%s' % self.serial,