Revision c50c5ae7 image_creator/os_type/windows.py

b/image_creator/os_type/windows.py
37 37
Windows OSs."""
38 38

  
39 39
from image_creator.os_type import OSBase, sysprep
40
from image_creator.util import FatalError, check_guestfs_version
40
from image_creator.util import FatalError, check_guestfs_version, get_command
41 41

  
42 42
import hivex
43 43
import tempfile
44 44
import os
45
import time
46
import random
47

  
48
kvm = get_command('kvm')
45 49

  
46 50

  
47 51
class Windows(OSBase):
48 52
    """OS class for Windows"""
49 53

  
50 54
    @sysprep(enabled=False)
51
    def remove_user_accounts(self, print_header=True):
52
        """Remove all user accounts with id greater than 1000"""
55
    def test(self, print_header=True):
56
        """test sysprep"""
53 57
        pass
54
 
58

  
55 59
    def do_sysprep(self):
56 60
        """Prepare system for image creation."""
57 61

  
......
74 78
            ret = self.g.kill_subprocess()
75 79

  
76 80
        self.out.success('done')
77

  
78
        self.out.output("Starting windows VM ...", False)
79 81
        try:
80
            pass
82
            self.out.output("Starting windows VM ...", False)
83

  
84
            def random_mac():
85
                mac = [0x00, 0x16, 0x3e,
86
                       random.randint(0x00, 0x7f),
87
                       random.randint(0x00, 0xff),
88
                       random.randint(0x00, 0xff)]
89
                return ':'.join(map(lambda x: "%02x" % x, mac))
90

  
91
            vm = kvm('-smp', '1', '-m', '1024', '-drive',
92
                     'file=%s,format=raw,cache=none,if=virtio' %
93
                     self.image.device,
94
                     '-netdev', 'type=user,hostfwd=tcp::445-:445,id=netdev0',
95
                     '-device', 'virtio-net-pci,mac=%s,netdev=netdev0' %
96
                     random_mac(), '-vnc', ':0', _bg=True)
97
            time.sleep(30)
98
            self.out.success('done')
99
            vm.wait()
81 100
        finally:
82 101
            self.out.output("Relaunching helper VM (may take a while) ...",
83 102
                            False)

Also available in: Unified diff