Skip to content

Instantly share code, notes, and snippets.

@mgagne
Created October 22, 2015 18:21
Show Gist options
  • Save mgagne/644bf23038c439e38b91 to your computer and use it in GitHub Desktop.
Save mgagne/644bf23038c439e38b91 to your computer and use it in GitHub Desktop.

For windows support libguestfs 1.17.17 or above is needed. Ubuntu 12.10 (Quantal Quetzal) or above is required.

A patch written by the CERN is also required for Windows customization support: https://twiki.cern.ch/twiki/bin/view/Sandbox/LuisFernandezAlvarezSandbox

def customize(self, libvirt_xml):
    def is_generalize():
        g_handle = self._guestfs_handle_setup(libvirt_xml)
        try:
            state = os.path.join(self.icicle_tmp, "state.ini")
            path = g_handle.case_sensitive_path("/windows/setup/state/state.ini")
            g_handle.download(path, state)
            generalize = 'IMAGE_STATE_GENERALIZE_RESEAL_TO_OOBE' in open(state).read()
            if generalize:
                self.log.debug("Image generalized, ready to upload.")
                return True
            else:
                self.log.debug("Image not generalized.")
                return False
        finally:
            self._guestfs_handle_cleanup(g_handle)

    while not is_generalize():
        libvirt_dom = self.libvirt_conn.createXML(libvirt_xml, 0)
        self._wait_for_install_finish(libvirt_dom, 860000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment