Ejemplo n.º 1
0
        def activate_live_be():
            if set_active:
                if set_active == "bootnext":
                    ret = be.beActivate(self.be_name_clone, temporary=1)
                else:
                    ret = be.beActivate(self.be_name_clone)
                if ret != 0:
                    logger.error(
                        _("pkg: unable to activate "
                          "{0}").format(self.be_name_clone))
                    return

            # Consider the last operation a success, and log it as
            # ending here so that it will be recorded in the new
            # image's history.
            self.img.history.operation_new_be = self.be_name_clone
            self.img.history.operation_new_be_uuid = self.be_name_clone_uuid
            self.img.history.log_operation_end(
                release_notes=self.img.imageplan.pd.release_notes_name)

            if be.beUnmount(self.be_name_clone) != 0:
                logger.error(
                    _("unable to unmount BE "
                      "{be_name} mounted at {be_path}").format(
                          be_name=self.be_name_clone, be_path=self.clone_dir))
                return

            os.rmdir(self.clone_dir)

            if set_active:
                logger.info(
                    _("""
A clone of {be_name} exists and has been updated and activated.
On the next boot the Boot Environment {be_name_clone} will be
mounted on '/'.  Reboot when ready to switch to this updated BE.

*** Reboot required ***
New BE: {be_name_clone}
""").format(**self.__dict__))
            else:
                logger.info(
                    _("""
A clone of {be_name} exists and has been updated.  To set the
new BE as the active one on next boot, execute the following
command as a privileged user and reboot when ready to switch to
the updated BE:

beadm activate {be_name_clone}
""").format(**self.__dict__))
Ejemplo n.º 2
0
        def activate_live_be(cmd):
            cmd += [self.clone_dir]

            # Activate the clone.
            exec_cmd(cmd)

            if be.beActivate(self.be_name_clone) != 0:
                logger.error(_("pkg: unable to activate %s") \
                    % self.be_name_clone)
                return

            # Consider the last operation a success, and log it as
            # ending here so that it will be recorded in the new
            # image's history.
            self.img.history.log_operation_end()

            if be.beUnmount(self.be_name_clone) != 0:
                logger.error(_("pkg: unable to unmount %s") \
                    % self.clone_dir)
                return

            os.rmdir(self.clone_dir)

            logger.info(_("""
A clone of %s exists and has been updated and activated.
On the next boot the Boot Environment %s will be mounted on '/'.
Reboot when ready to switch to this updated BE.
""") % \
                (self.be_name, self.be_name_clone))
Ejemplo n.º 3
0
                def activate_live_be(cmd):
                        cmd += [self.clone_dir]

                        # Activate the clone.
                        exec_cmd(cmd)

                        if be.beActivate(self.be_name_clone) != 0:
                                logger.error(_("pkg: unable to activate %s") \
                                    % self.be_name_clone)
                                return

                        # Consider the last operation a success, and log it as
                        # ending here so that it will be recorded in the new
                        # image's history.
                        self.img.history.log_operation_end()

                        if be.beUnmount(self.be_name_clone) != 0:
                                logger.error(_("pkg: unable to unmount %s") \
                                    % self.clone_dir)
                                return

                        os.rmdir(self.clone_dir)

                        logger.info(_("""
A clone of %s exists and has been updated and activated.
On the next boot the Boot Environment %s will be mounted on '/'.
Reboot when ready to switch to this updated BE.
""") % \
                            (self.be_name, self.be_name_clone))
Ejemplo n.º 4
0
def activate(opts):
    """ 
    Function:    activate

            Description: Activate a Boot Environment.The following is the
                         subcommand, options and args that make up the
                         opts object passed in:

            Parameters:
                opts - A string containing the active subcommand

            Returns:
                0 - Success
                1 - Failure
    """

    if len(opts) != 1:
        msg.printMsg(msg.Msgs.BEADM_ERR_OPT_ARGS, None, -1)
        usage()

    be = BootEnvironment()

    if lb.beVerifyBEName(opts[0]) != 0:
        msg.printMsg(msg.Msgs.BEADM_ERR_BENAME, None, -1)
        return 1

    rc = lb.beActivate(opts[0])
    if rc == 0:
        return 0

    be.msg_buf["0"] = opts[0]
    if rc == msg.Msgs.BE_ERR_BE_NOENT:
        be.msg_buf["1"] = \
            msg.getMsg(msg.Msgs.BEADM_ERR_BE_DOES_NOT_EXIST, opts[0])
    elif rc == msg.Msgs.BE_ERR_PERM or rc == msg.Msgs.BE_ERR_ACCESS:
        be.msg_buf["1"] = msg.getMsg(msg.Msgs.BEADM_ERR_PERMISSIONS, rc)
        msg.printMsg(msg.Msgs.BEADM_ERR_ACTIVATE, be.msg_buf, -1)
        return 1
    else:
        be.msg_buf["1"] = lb.beGetErrDesc(rc)
        if be.msg_buf["1"] == None:
            be.msg_buf["1"] = \
                msg.getMsg(msg.Msgs.BEADM_ERR_NO_MSG, rc)

    msg.printMsg(msg.Msgs.BEADM_ERR_ACTIVATE, be.msg_buf, -1)
    return 1
Ejemplo n.º 5
0
def activate(opts):
    """ 
    Function:    activate

            Description: Activate a Boot Environment.The following is the
                         subcommand, options and args that make up the
                         opts object passed in:

            Parameters:
                opts - A string containing the active subcommand

            Returns:
                0 - Success
                1 - Failure
    """

    if len(opts) != 1:
        msg.printMsg(msg.Msgs.BEADM_ERR_OPT_ARGS, None, -1)
        usage()

    be = BootEnvironment()

    if lb.beVerifyBEName(opts[0]) != 0:
        msg.printMsg(msg.Msgs.BEADM_ERR_BENAME, None, -1)
        return 1

    rc = lb.beActivate(opts[0])
    if rc == 0:
        return 0

    be.msg_buf["0"] = opts[0]
    if rc == msg.Msgs.BE_ERR_BE_NOENT:
        be.msg_buf["1"] = msg.getMsg(msg.Msgs.BEADM_ERR_BE_DOES_NOT_EXIST, opts[0])
    elif rc == msg.Msgs.BE_ERR_PERM or rc == msg.Msgs.BE_ERR_ACCESS:
        be.msg_buf["1"] = msg.getMsg(msg.Msgs.BEADM_ERR_PERMISSIONS, rc)
        msg.printMsg(msg.Msgs.BEADM_ERR_ACTIVATE, be.msg_buf, -1)
        return 1
    else:
        be.msg_buf["1"] = lb.beGetErrDesc(rc)
        if be.msg_buf["1"] == None:
            be.msg_buf["1"] = msg.getMsg(msg.Msgs.BEADM_ERR_NO_MSG, rc)

    msg.printMsg(msg.Msgs.BEADM_ERR_ACTIVATE, be.msg_buf, -1)
    return 1
Ejemplo n.º 6
0
def activateBE(be):
    """
    Activate a BE. Called from create() when -a is provided as CLI
    Option.
    """

    rc = lb.beActivate(be.trgt_be_name_or_snapshot[0])
    if rc == 0:
        return 0

    be.msg_buf["0"] = be.trgt_be_name_or_snapshot[0]
    if rc == msg.Msgs.BE_ERR_BE_NOENT:
        be.msg_buf["1"] = msg.getMsg(msg.Msgs.BEADM_ERR_BE_DOES_NOT_EXIST, opts[0])
    else:
        be.msg_buf["1"] = lb.beGetErrDesc(rc)
        if be.msg_buf["1"] == None:
            be.msg_buf["1"] = msg.getMsg(msg.Msgs.BEADM_ERR_NO_MSG, rc)

    msg.printMsg(msg.Msgs.BEADM_ERR_ACTIVATE, be.msg_buf, -1)

    return 1
Ejemplo n.º 7
0
def activateBE(be):
    """
    Activate a BE. Called from create() when -a is provided as CLI
    Option.
    """

    rc = lb.beActivate(be.trgt_be_name_or_snapshot[0])
    if rc == 0:
        return 0

    be.msg_buf["0"] = be.trgt_be_name_or_snapshot[0]
    if rc == msg.Msgs.BE_ERR_BE_NOENT:
        be.msg_buf["1"] = \
            msg.getMsg(msg.Msgs.BEADM_ERR_BE_DOES_NOT_EXIST, opts[0])
    else:
        be.msg_buf["1"] = lb.beGetErrDesc(rc)
        if be.msg_buf["1"] == None:
            be.msg_buf["1"] = \
                msg.getMsg(msg.Msgs.BEADM_ERR_NO_MSG, rc)

    msg.printMsg(msg.Msgs.BEADM_ERR_ACTIVATE, be.msg_buf, -1)

    return 1
Ejemplo n.º 8
0
 def set_default_be(be_name):
     return be.beActivate(be_name)
Ejemplo n.º 9
0
 def set_default_be(be_name):
         return be.beActivate(be_name)