def restore_image(self): """Restore a failed image-update attempt.""" self.__reset_image_state(failure=True) # Leave the clone around for debugging purposes if we're # operating on the live BE. if self.is_live_BE: logger.error(_(" The running system has not been " "modified. Modifications were only made to a clone " "of the running system. This clone is mounted at " "%s should you wish to inspect it.") % \ self.clone_dir) else: # Rollback and destroy the snapshot. try: if be.beRollback(self.be_name, self.snapshot_name) != 0: logger.error( _("pkg: unable to " "rollback BE %s and restore " "image") % self.be_name) self.destroy_snapshot() os.rmdir(self.clone_dir) except Exception, e: self.img.history.log_operation_error(error=e) raise e logger.error( _("%s failed to be updated. No changes " "have been made to %s.") % (self.be_name, self.be_name))
def restore_image(self): """Restore a failed image-update attempt.""" self.__reset_image_state(failure=True) # Leave the clone around for debugging purposes if we're # operating on the live BE. if self.is_live_BE: logger.error(_(" The running system has not been " "modified. Modifications were only made to a clone " "of the running system. This clone is mounted at " "%s should you wish to inspect it.") % \ self.clone_dir) else: # Rollback and destroy the snapshot. try: if be.beRollback(self.be_name, self.snapshot_name) != 0: logger.error(_("pkg: unable to " "rollback BE %s and restore " "image") % self.be_name) self.destroy_snapshot() os.rmdir(self.clone_dir) except Exception, e: self.img.history.log_operation_error(error=e) raise e logger.error(_("%s failed to be updated. No changes " "have been made to %s.") % (self.be_name, self.be_name))
def restore_install_uninstall(self): """Restore a failed install or uninstall attempt. Clone the snapshot, mount the BE and notify user of its existence. Rollback if not operating on a live BE""" if self.is_live_BE: # Create a new BE based on the previously taken # snapshot. ret, self.be_name_clone, not_used = \ be.beCopy(None, self.be_name, self.snapshot_name) if ret != 0: # If the above beCopy() failed we will try it # without expecting the BE clone name to be # returned by libbe. We do this in case an old # version of libbe is on a system with # a new version of pkg. self.be_name_clone = self.be_name + "_" + \ self.snapshot_name ret, not_used, not_used2 = \ be.beCopy(self.be_name_clone, \ self.be_name, self.snapshot_name) if ret != 0: logger.error(_("pkg: unable to create " "BE %s") % self.be_name_clone) return if be.beMount(self.be_name_clone, self.clone_dir) != 0: logger.error(_("pkg: unable to mount BE " "%(name)s on %(clone_dir)s") % { "name": self.be_name_clone, "clone_dir": self.clone_dir }) return logger.error(_("The Boot Environment %(name)s failed " "to be updated. A snapshot was taken before the " "failed attempt and is mounted here %(clone_dir)s. " "Use 'beadm unmount %(clone_name)s' and then " "'beadm activate %(clone_name)s' if you wish to " "boot to this BE.") % { "name": self.be_name, "clone_dir": self.clone_dir, "clone_name": self.be_name_clone }) else: if be.beRollback(self.be_name, self.snapshot_name) != 0: logger.error("pkg: unable to rollback BE " "%s" % self.be_name) self.destroy_snapshot() logger.error(_("The Boot Environment %s failed to be " "updated. A snapshot was taken before the failed " "attempt and has been restored so no changes have " "been made to %s.") % (self.be_name, self.be_name))
def restore_image(self): """Restore a failed update attempt.""" # flush() is necessary here so that the warnings get printed # on a new line. if self.progress_tracker: self.progress_tracker.flush() self.__reset_image_state(failure=True) # Leave the clone around for debugging purposes if we're # operating on the live BE. if self.is_live_BE: logger.error( _("The running system has not been " "modified. Modifications were only made to a clone " "({0}) of the running system. This clone is " "mounted at {1} should you wish to inspect " "it.").format(self.be_name_clone, self.clone_dir)) else: # Rollback and destroy the snapshot. try: if be.beRollback(self.be_name, self.snapshot_name) != 0: logger.error( _("pkg: unable to " "rollback BE {0} and restore " "image").format(self.be_name)) self.destroy_snapshot() os.rmdir(self.clone_dir) except Exception as e: self.img.history.log_operation_error(error=e) raise e logger.error( _("{bename} failed to be updated. No " "changes have been made to {bename}.").format( bename=self.be_name))
def restore_install_uninstall(self): """Restore a failed install or uninstall attempt. Clone the snapshot, mount the BE and notify user of its existence. Rollback if not operating on a live BE""" # flush() is necessary here so that the warnings get printed # on a new line. if self.progress_tracker: self.progress_tracker.flush() if self.is_live_BE: # Create a new BE based on the previously taken # snapshot. ret, self.be_name_clone, not_used = \ be.beCopy(None, self.be_name, self.snapshot_name) if ret != 0: # If the above beCopy() failed we will try it # without expecting the BE clone name to be # returned by libbe. We do this in case an old # version of libbe is on a system with # a new version of pkg. self.be_name_clone = self.be_name + "_" + \ self.snapshot_name ret, not_used, not_used2 = \ be.beCopy(self.be_name_clone, \ self.be_name, self.snapshot_name) if ret != 0: logger.error( _("pkg: unable to create " "BE {0}").format(self.be_name_clone)) return if be.beMount(self.be_name_clone, self.clone_dir) != 0: logger.error( _("pkg: unable to mount BE " "{name} on {clone_dir}").format( name=self.be_name_clone, clone_dir=self.clone_dir)) return logger.error( _("The Boot Environment {name} failed " "to be updated. A snapshot was taken before the " "failed attempt and is mounted here {clone_dir}. " "Use 'beadm unmount {clone_name}' and then " "'beadm activate {clone_name}' if you wish to " "boot to this BE.").format(name=self.be_name, clone_dir=self.clone_dir, clone_name=self.be_name_clone)) else: if be.beRollback(self.be_name, self.snapshot_name) != 0: logger.error("pkg: unable to rollback BE " "{0}".format(self.be_name)) self.destroy_snapshot() logger.error( _("The Boot Environment {bename} failed " "to be updated. A snapshot was taken before the " "failed attempt and has been restored so no " "changes have been made to {bename}.").format( bename=self.be_name))
def restore_install_uninstall(self): """Restore a failed install or uninstall attempt. Clone the snapshot, mount the BE and notify user of its existence. Rollback if not operating on a live BE""" if self.is_live_BE: # Create a new BE based on the previously taken # snapshot. ret, self.be_name_clone, not_used = \ be.beCopy(None, self.be_name, self.snapshot_name) if ret != 0: # If the above beCopy() failed we will try it # without expecting the BE clone name to be # returned by libbe. We do this in case an old # version of libbe is on a system with # a new version of pkg. self.be_name_clone = self.be_name + "_" + \ self.snapshot_name ret, not_used, not_used2 = \ be.beCopy(self.be_name_clone, \ self.be_name, self.snapshot_name) if ret != 0: logger.error( _("pkg: unable to create " "BE %s") % self.be_name_clone) return if be.beMount(self.be_name_clone, self.clone_dir) != 0: logger.error( _("pkg: unable to mount BE " "%(name)s on %(clone_dir)s") % { "name": self.be_name_clone, "clone_dir": self.clone_dir }) return logger.error( _("The Boot Environment %(name)s failed " "to be updated. A snapshot was taken before the " "failed attempt and is mounted here %(clone_dir)s. " "Use 'beadm unmount %(clone_name)s' and then " "'beadm activate %(clone_name)s' if you wish to " "boot to this BE.") % { "name": self.be_name, "clone_dir": self.clone_dir, "clone_name": self.be_name_clone }) else: if be.beRollback(self.be_name, self.snapshot_name) != 0: logger.error("pkg: unable to rollback BE " "%s" % self.be_name) self.destroy_snapshot() logger.error( _("The Boot Environment %s failed to be " "updated. A snapshot was taken before the failed " "attempt and has been restored so no changes have " "been made to %s.") % (self.be_name, self.be_name))