def __init__(self, root): self.be_name = None self.dataset = None self.be_name_clone = None self.clone_dir = None self.img = None self.is_live_BE = False self.is_valid = False self.snapshot_name = None self.root = root rc = 0 assert root != None # Check for the old beList() API since pkg(1) can be # back published and live on a system without the latest libbe. beVals = be.beList() if isinstance(beVals[0], int): rc, self.beList = beVals else: self.beList = beVals # Happens e.g. in zones (at least, for now) if not self.beList or rc != 0: raise RuntimeError, "nobootenvironments" # Need to find the name of the BE we're operating on in order # to create a snapshot and/or a clone of the BE. for i, beVals in enumerate(self.beList): # pkg(1) expects a directory as the target of an # operation. BootEnv needs to determine if this target # directory maps to a BE. If a bogus directory is # provided to pkg(1) via -R, then pkg(1) just updates # '/' which also causes BootEnv to manage '/' as well. # This should be fixed before this class is ever # instantiated. be_name = beVals.get("orig_be_name") # If we're not looking at a boot env entry or an # entry that is not mounted then continue. if not be_name or not beVals.get("mounted"): continue # Check if we're operating on the live BE. # If so it must also be active. If we are not # operating on the live BE, then verify # that the mountpoint of the BE matches # the -R argument passed in by the user. if root == '/': if not beVals.get("active"): continue else: self.is_live_BE = True else: if beVals.get("mountpoint") != root: continue # Set the needed BE components so snapshots # and clones can be managed. self.be_name = be_name self.dataset = beVals.get("dataset") # Let libbe provide the snapshot name err, snapshot_name = be.beCreateSnapshot(self.be_name) self.clone_dir = tempfile.mkdtemp() # Check first field for failure. # 2nd field is the returned snapshot name if err == 0: self.snapshot_name = snapshot_name else: emsg( _("pkg: unable to create an auto " "snapshot. pkg recovery is disabled.")) raise RuntimeError, "recoveryDisabled" self.is_valid = True break else: # We will get here if we don't find find any BE's. e.g # if were are on UFS. raise RuntimeError, "recoveryDisabled"
def __init__(self, img, progress_tracker=None): self.be_name = None self.dataset = None self.be_name_clone = None self.be_name_clone_uuid = None self.clone_dir = None self.img = img self.is_live_BE = False self.is_valid = False self.snapshot_name = None self.progress_tracker = progress_tracker # record current location of image root so we can remember # original source BE if we clone existing image self.root = self.img.get_root() rc = 0 assert self.root != None # Need to find the name of the BE we're operating on in order # to create a snapshot and/or a clone of the BE. self.beList = self.get_be_list(raise_error=True) for i, beVals in enumerate(self.beList): # pkg(1) expects a directory as the target of an # operation. BootEnv needs to determine if this target # directory maps to a BE. If a bogus directory is # provided to pkg(1) via -R, then pkg(1) just updates # '/' which also causes BootEnv to manage '/' as well. # This should be fixed before this class is ever # instantiated. be_name = beVals.get("orig_be_name") # If we're not looking at a boot env entry or an # entry that is not mounted then continue. if not be_name or not beVals.get("mounted"): continue # Check if we're operating on the live BE. # If so it must also be active. If we are not # operating on the live BE, then verify # that the mountpoint of the BE matches # the -R argument passed in by the user. if self.root == '/': if not beVals.get("active"): continue else: self.is_live_BE = True else: if beVals.get("mountpoint") != self.root: continue # Set the needed BE components so snapshots # and clones can be managed. self.be_name = be_name self.dataset = beVals.get("dataset") # Let libbe provide the snapshot name err, snapshot_name = be.beCreateSnapshot(self.be_name) self.clone_dir = tempfile.mkdtemp() # Check first field for failure. # 2nd field is the returned snapshot name if err == 0: self.snapshot_name = snapshot_name # we require BootEnv to be initialised within # the context of a history operation, i.e. # after img.history.operation_name has been set. img.history.operation_snapshot = snapshot_name else: logger.error( _("pkg: unable to create an auto " "snapshot. pkg recovery is disabled.")) raise RuntimeError("recoveryDisabled") self.is_valid = True break else: # We will get here if we don't find find any BE's. e.g # if were are on UFS. raise RuntimeError("recoveryDisabled")
def __init__(self, root): self.be_name = None self.dataset = None self.be_name_clone = None self.clone_dir = None self.img = None self.is_live_BE = False self.is_valid = False self.snapshot_name = None self.root = root rc = 0 assert root != None # Check for the old beList() API since pkg(1) can be # back published and live on a system without the latest libbe. beVals = be.beList() if isinstance(beVals[0], int): rc, self.beList = beVals else: self.beList = beVals # Happens e.g. in zones (at least, for now) if not self.beList or rc != 0: raise RuntimeError, "nobootenvironments" # Need to find the name of the BE we're operating on in order # to create a snapshot and/or a clone of the BE. for i, beVals in enumerate(self.beList): # pkg(1) expects a directory as the target of an # operation. BootEnv needs to determine if this target # directory maps to a BE. If a bogus directory is # provided to pkg(1) via -R, then pkg(1) just updates # '/' which also causes BootEnv to manage '/' as well. # This should be fixed before this class is ever # instantiated. be_name = beVals.get("orig_be_name") # If we're not looking at a boot env entry or an # entry that is not mounted then continue. if not be_name or not beVals.get("mounted"): continue # Check if we're operating on the live BE. # If so it must also be active. If we are not # operating on the live BE, then verify # that the mountpoint of the BE matches # the -R argument passed in by the user. if root == '/': if not beVals.get("active"): continue else: self.is_live_BE = True else: if beVals.get("mountpoint") != root: continue # Set the needed BE components so snapshots # and clones can be managed. self.be_name = be_name self.dataset = beVals.get("dataset") # Let libbe provide the snapshot name err, snapshot_name = be.beCreateSnapshot(self.be_name) self.clone_dir = tempfile.mkdtemp() # Check first field for failure. # 2nd field is the returned snapshot name if err == 0: self.snapshot_name = snapshot_name else: emsg(_("pkg: unable to create an auto " "snapshot. pkg recovery is disabled.")) raise RuntimeError, "recoveryDisabled" self.is_valid = True break else: # We will get here if we don't find find any BE's. e.g # if were are on UFS. raise RuntimeError, "recoveryDisabled"
def __init__(self, img): self.be_name = None self.dataset = None self.be_name_clone = None self.be_name_clone_uuid = None self.clone_dir = None self.img = img self.is_live_BE = False self.is_valid = False self.snapshot_name = None # record current location of image root so we can remember # original source BE if we clone existing image self.root = self.img.get_root() rc = 0 assert self.root != None # Need to find the name of the BE we're operating on in order # to create a snapshot and/or a clone of the BE. self.beList = self.get_be_list(raise_error=True) for i, beVals in enumerate(self.beList): # pkg(1) expects a directory as the target of an # operation. BootEnv needs to determine if this target # directory maps to a BE. If a bogus directory is # provided to pkg(1) via -R, then pkg(1) just updates # '/' which also causes BootEnv to manage '/' as well. # This should be fixed before this class is ever # instantiated. be_name = beVals.get("orig_be_name") # If we're not looking at a boot env entry or an # entry that is not mounted then continue. if not be_name or not beVals.get("mounted"): continue # Check if we're operating on the live BE. # If so it must also be active. If we are not # operating on the live BE, then verify # that the mountpoint of the BE matches # the -R argument passed in by the user. if self.root == '/': if not beVals.get("active"): continue else: self.is_live_BE = True else: if beVals.get("mountpoint") != self.root: continue # Set the needed BE components so snapshots # and clones can be managed. self.be_name = be_name self.dataset = beVals.get("dataset") # Let libbe provide the snapshot name err, snapshot_name = be.beCreateSnapshot(self.be_name) self.clone_dir = tempfile.mkdtemp() # Check first field for failure. # 2nd field is the returned snapshot name if err == 0: self.snapshot_name = snapshot_name # we require BootEnv to be initialised within # the context of a history operation, i.e. # after img.history.operation_name has been set. img.history.operation_snapshot = snapshot_name else: logger.error(_("pkg: unable to create an auto " "snapshot. pkg recovery is disabled.")) raise RuntimeError, "recoveryDisabled" self.is_valid = True break else: # We will get here if we don't find find any BE's. e.g # if were are on UFS. raise RuntimeError, "recoveryDisabled"