def start_duplicate(design, meter=None): """ Actually perform the duplication: cloning disks if needed and defining the new clone xml. """ logging.debug("Starting duplicate.") if not meter: meter = progress.BaseMeter() dom = None try: # Replace orig VM if required design.remove_original_vm() # Define domain early to catch any xml errors before duping storage dom = design.original_conn.defineXML(design.clone_xml) if design.preserve == True: _do_duplicate(design, meter) except Exception, e: logging.debug("Duplicate failed: %s" % str(e)) if dom: dom.undefine() raise
def _compare(self, guest, filebase, do_install, do_disk_boot=False): filename = build_xmlfile(filebase) guest._prepare_install(progress.BaseMeter()) try: actualXML = guest.get_config_xml(install=do_install, disk_boot=do_disk_boot) tests.diff_compare(actualXML, filename) self._testCreate(guest.conn, actualXML) finally: guest._cleanup_install()
def _compare(self, guest, filebase, do_install, do_disk_boot=False, do_create=True): filename = filebase and build_xmlfile(filebase) or None guest._prepare_install(progress.BaseMeter()) try: actualXML = guest.get_config_xml(install=do_install, disk_boot=do_disk_boot) if filename: utils.diff_compare(actualXML, filename) if do_create: utils.test_create(guest.conn, actualXML) finally: guest._cleanup_install()
def _create_guest(self, consolecb, meter, wait, meter_label, log_label, disk_boot=False, first_create=True): """ Actually do the XML logging, guest defining/creating, console launching and waiting """ if meter == None: meter = progress.BaseMeter() start_xml = self.get_config_xml(install=True, disk_boot=disk_boot) final_xml = self.get_config_xml(install=False) logging.debug("Generated %s XML: %s" % (log_label, (start_xml and ("\n" + start_xml) or "None required"))) if start_xml: meter.start(size=None, text=meter_label) if first_create: dom = self.conn.createLinux(start_xml, 0) else: dom = self.conn.defineXML(start_xml) dom.create() self.domain = dom meter.end(0) logging.debug("Started guest, looking to see if it is running") (self.domain, self._consolechild) = self._wait_and_connect_console(consolecb) logging.debug("Generated boot XML: \n%s" % final_xml) self.domain = self.conn.defineXML(final_xml) # if we connected the console, wait for it to finish self._waitpid_console(self._consolechild, wait) return self.conn.lookupByName(self.name)
def setup(self, meter=None): """ Build storage (if required) If storage doesn't exist (a non-existent file 'path', or 'vol_install' was specified), we create it. @param meter: Progress meter to report file creation on @type meter: instanceof urlgrabber.BaseMeter """ if not meter: meter = progress.BaseMeter() if not self._storage_creator: return volobj = self._storage_creator.create(meter) self._storage_creator = None if volobj: self._change_backend(None, volobj)