def get_uuid_be_dic(): """Return a dictionary of all boot environment names on the system, keyed by uuid""" beList = BootEnv.get_be_list() uuid_bes = {} for be in beList: uuid_bes[be.get("uuid_str")] = be.get("orig_be_name") return uuid_bes
def get_active_be_name(): try: beList = BootEnv.get_be_list() for be in beList: if be.get("active"): return be.get("orig_be_name") except AttributeError: raise api_errors.BENamingNotSupported(be_name)
def get_activated_be_name(): try: beList = BootEnv.get_be_list() for be in beList: # don't look at active but unbootable BEs. # (happens in zones when we have ZBEs # associated with other global zone BEs.) if be.get("active_unbootable", False): continue if be.get("active_boot") and be.get("global_active", True): return be.get("orig_be_name") except AttributeError: raise api_errors.BENamingNotSupported(be_name)
def get_activated_be_name(): try: beList = BootEnv.get_be_list() for be in beList: # don't look at active but unbootable BEs. # (happens in zones when we have ZBEs # associated with other global zone BEs.) if be.get("active_unbootable", False): continue if be.get("active_boot"): return be.get("orig_be_name") except AttributeError: raise api_errors.BENamingNotSupported(be_name)
def get_be_name(path): """Looks for the name of the boot environment corresponding to an image root, returning name and uuid """ beList = BootEnv.get_be_list() for be in beList: be_name = be.get("orig_be_name") be_uuid = be.get("uuid_str") if not be_name or not be.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 path argument passed in by the user. if path == '/': if be.get("active"): return be_name, be_uuid else: if be.get("mountpoint") == path: return be_name, be_uuid return None, None
def check_be_name(be_name): try: if be_name is None: return if be.beVerifyBEName(be_name) != 0: raise api_errors.InvalidBENameException(be_name) beList = BootEnv.get_be_list() # If there is already a BE with the same name as # be_name, then raise an exception. if be_name in (be.get("orig_be_name") for be in beList): raise api_errors.DuplicateBEName(be_name) except AttributeError: raise api_errors.BENamingNotSupported(be_name)
def check_be_name(be_name): try: if be_name is None: return if be.beVerifyBEName(be_name) != 0: raise api_errors.InvalidBENameException(be_name) # 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, beList = beVals else: beList = beVals # If there is already a BE with the same name as # be_name, then raise an exception. if be_name in (be.get("orig_be_name") for be in beList): raise api_errors.DuplicateBEName(be_name) except AttributeError: raise api_errors.BENamingNotSupported(be_name)